大连融科 WMS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

275 lines
9.3 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data;
namespace SiaSun.LMS.WPFClient.WH
{
/// <summary>
/// WH_CELL_STATUS.xaml 的交互逻辑
/// </summary>
public partial class WH_CELL_STATUS : AvalonDock.DocumentContent
{
bool boolAllowEdit = true;
string strTableName = string.Empty;
string strOrderField = string.Empty;
string strTotalColumn = string.Empty;
string strWhere = string.Empty;
DataRowView[] listDataRowView = null;
public WH_CELL_STATUS(string TabText,
string TableName,
string QueryWhere,
string OrderField,
bool AllowEdit,
string TotalColumnName)
{
InitializeComponent();
//设置空间属性
this.Title = TabText;
this.boolAllowEdit = AllowEdit;
this.strTableName = TableName;
this.strOrderField = OrderField;
this.strTotalColumn = TotalColumnName;
this.strWhere = QueryWhere;
this.ucQKQuery.U_Query += new UC.ucQuickQuery.U_QueryEventHandler(ucQKQuery_U_Query);
}
//加载窗体
private void DocumentContent_Loaded(object sender, RoutedEventArgs e)
{
//初始化查询控件
InitQueryControl();
//加载数据
LoadDataGrid();
CELL_STATUS_Bind();
RUN_STATUS_Bind();
}
/// <summary>
/// 初始化查询控件
/// </summary>
private void InitQueryControl()
{
try
{
this.ucQKQuery.U_WindowName = this.GetType().Name;
this.ucQKQuery.U_XmlTableName = this.strTableName;
this.ucQKQuery.U_InitControl();
}
catch (Exception ex)
{
MainApp._MessageDialog.ShowException(ex);
}
}
/// <summary>
/// 加载数据
/// </summary>
private void LoadDataGrid()
{
try
{
this.gridQuery.U_WindowName = this.GetType().Name;
this.gridQuery.U_TableName = this.strTableName;
this.gridQuery.U_Where = this.strWhere;
this.gridQuery.U_OrderField = this.strOrderField;
this.gridQuery.U_TotalColumnName = this.strTotalColumn;
this.gridQuery.U_AllowOperatData = this.boolAllowEdit;
this.gridQuery.U_AllowPage = true;
this.gridQuery.U_AllowChecked = true;
this.gridQuery.U_InitControl();
}
catch (Exception ex)
{
MainApp._MessageDialog.ShowException(ex);
}
}
private void CELL_STATUS_Bind()
{
this.cbbCELL_STATUS.DisplayMemberPath = "ITEM_LIST_NAME";
this.cbbCELL_STATUS.SelectedValuePath = "ITEM_LIST_CODE";
try
{
this.cbbCELL_STATUS.ItemsSource = MainApp._I_SystemService.ITEM_LIST_GetList_ITEM_CODE("CELL_STATUS");
}
catch (Exception ex)
{
MainApp._MessageDialog.ShowException(ex);
}
}
private void RUN_STATUS_Bind()
{
this.cbbRUN_STATUS.DisplayMemberPath = "ITEM_LIST_NAME";
this.cbbRUN_STATUS.SelectedValuePath = "ITEM_LIST_CODE";
try
{
this.cbbRUN_STATUS.ItemsSource = MainApp._I_SystemService.ITEM_LIST_GetList_ITEM_CODE("RUN_STATUS");
}
catch (Exception ex)
{
MainApp._MessageDialog.ShowException(ex);
}
}
void ucQKQuery_U_Query(string QueryWhere)
{
try
{
//查询
this.strWhere = string.IsNullOrEmpty(strWhere) ? "1=1" : strWhere;
this.gridQuery.U_Where = string.IsNullOrEmpty(QueryWhere) ? strWhere : (QueryWhere.Length == 0 ? string.Empty : QueryWhere + " AND " + strWhere);
this.gridQuery.U_InitControl();
}
catch (Exception ex)
{
MainApp._MessageDialog.ShowException(ex);
}
}
//点击按钮
private void WrapPanel_Click(object sender, RoutedEventArgs e)
{
Button btn = e.OriginalSource as Button;
if (btn != null)
{
switch (btn.Name)
{
case "btnConfirm":
this.Confirm();
break;
case "btnRefresh":
this.Refresh();
break;
default:
break;
}
}
}
private void Confirm()
{
string strCELL_ID=string.Empty;
string strCELL_NAME = string.Empty;
try
{
#region 校验所选记录
listDataRowView = this.gridQuery.U_GetCheckedDataRows();
if (listDataRowView.Length == 0)
{
MainApp._MessageDialog.Show(false, "请选中要维护的货位记录");
return;
}
#endregion
#region 校验货位状态、运行状态
if (this.cbbCELL_STATUS.SelectedValue == null && this.cbbRUN_STATUS.SelectedValue == null)
{
MainApp._MessageDialog.Show(false, "请选择[货位状态]或[运行状态]");
return;
}
#endregion
string CELL_STATUS = string.Empty;
if (this.cbbCELL_STATUS.SelectedValue != null)
{
CELL_STATUS = this.cbbCELL_STATUS.SelectedValue.ToString();
}
string RUN_STATUS = string.Empty;
if (this.cbbRUN_STATUS.SelectedValue != null)
{
RUN_STATUS = this.cbbRUN_STATUS.SelectedValue.ToString();
}
if (MainApp._MessageDialog.ShowDialog(string.Format("确认编辑所选记录:{0} {1}", string.IsNullOrEmpty(CELL_STATUS) ? string.Empty : string.Format("货位状态[{0}]", CELL_STATUS), string.IsNullOrEmpty(RUN_STATUS) ? string.Empty : string.Format("运行状态[{0}]", RUN_STATUS))) == Sid.Windows.Controls.TaskDialogResult.Cancel)
{
return;
}
var cell_id_group = from v in listDataRowView
group v by v["CELL_ID"].ToString() into a
select a;
var cell_name_group = from v in listDataRowView
group v by v["CELL_NAME"].ToString() into a
select a;
foreach (var cell_id in cell_id_group)
{
strCELL_ID += "," + cell_id.Key;
}
foreach (var cell_name in cell_name_group)
{
strCELL_NAME += "," + cell_name.Key;
}
strCELL_ID = strCELL_ID.Substring(1, strCELL_ID.Length-1);
strCELL_NAME = strCELL_NAME.Substring(1, strCELL_NAME.Length - 1);
string strUPDATE = string.Format(@"UPDATE WH_CELL SET LOGIC_ID=0{0}{1} WHERE CELL_ID IN ({2})",
string.IsNullOrEmpty(CELL_STATUS)?string.Empty:string.Format(",CELL_STATUS='{0}'",CELL_STATUS),
string.IsNullOrEmpty(RUN_STATUS)?string.Empty:string.Format(",RUN_STATUS='{0}'",RUN_STATUS),
strCELL_ID);
int sCount = MainApp._I_BaseService.ExecuteNonQuery_ReturnInt(strUPDATE);
#region 生成日志
MainApp._I_BaseService.CreateSYS_LOG("货位状态维护", MainApp._USER.USER_NAME, "1", string.Format("{0} {1} 货位[{2}]",
string.IsNullOrEmpty(CELL_STATUS)?string.Empty:string.Format("货位状态[{0}]",CELL_STATUS),
string.IsNullOrEmpty(RUN_STATUS)?string.Empty:string.Format("运行状态[{0}]",RUN_STATUS),
strCELL_NAME));
if (sCount > 0)
{
MainApp._MessageDialog.Show(true, "操作成功");
this.Refresh();
}
#endregion
}
catch (Exception ex)
{
MainApp._MessageDialog.ShowException(ex);
}
}
/// <summary>
/// 刷新
/// </summary>
private void Refresh()
{
this.LoadDataGrid();
CELL_STATUS_Bind();
RUN_STATUS_Bind();
}
}
}