using System; using System.Collections.Generic; using System.Data; 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 SiaSun.LMS.Persistence; namespace SiaSun.LMS.WPFClient.MANAGE { /// /// MANAGE_MANUAL_MOVE.xaml 的交互逻辑 /// public partial class MANAGE_MANUAL_MOVE : AvalonDock.DocumentContent { public MANAGE_MANUAL_MOVE() { InitializeComponent(); } private void btnSave_Click1(object sender, RoutedEventArgs e) { string strResult = string.Empty; string Barcode =string.Empty; bool bResult = true; try { MainWindow.mainWin.Cursor = Cursors.Wait; if(this.txtbarcode.Text.Length!=6||this.txtbarcode.Text.Substring(0,1)!="T") { bResult = false; strResult = "托盘条码格式不正确"; MainApp._MessageDialog.ShowResult(bResult, strResult); return; } if (MainApp._MessageDialog.ShowDialog(Enum.MessageConverter.ConfirmExecute, "搬运任务") == Sid.Windows.Controls.TaskDialogResult.Ok) { if (!string.IsNullOrEmpty(this.cmbStartPosition.Text.TrimEnd()) && !string.IsNullOrEmpty(this.cmbEndPosition.Text.TrimEnd())) { SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = new Model.MANAGE_MAIN(); Barcode = this.txtbarcode.Text.TrimEnd(); string StartCode = this.cmbStartPosition.Text.TrimEnd().Substring(0,5); string EndCode = this.cmbEndPosition.Text.TrimEnd().Substring(0,5); DataTable dtIOTask = MainApp._I_BaseService.GetList(string.Format("select * from IO_CONTROL where start_device_code='{0}' and end_device_code='{1}'", StartCode, EndCode)); if(dtIOTask.Rows.Count> 0) { bResult = false; strResult = string.Format("起始位置{0}和目标位置{1}存在控制任务,请检查",StartCode,EndCode); MainApp._MessageDialog.ShowResult(bResult, strResult); return; } if (StartCode == EndCode) { bResult = false; strResult = "起始位置和目标位置相同,请重新选择"; MainApp._MessageDialog.ShowResult(bResult, strResult); return; } DataTable dtReturnRoute = MainApp._I_BaseService.GetList(string.Format(@"select top 1 *from IO_CONTROL_ROUTE where control_route_type =4 and start_device ='{0}' and end_device ='{1}'", StartCode,EndCode)); if (dtReturnRoute.Rows.Count == 0) { bResult = false; strResult = string.Format("起始位置{0}和目标位置{1}路径不通,请检查", StartCode, EndCode); MainApp._MessageDialog.ShowResult(bResult, strResult); return; } string str = string.Format(@"INSERT INTO IO_CONTROL(STOCK_BARCODE, CONTROL_TASK_LEVEL,START_DEVICE_CODE,END_DEVICE_CODE, CONTROL_TASK_TYPE,CONTROL_BEGIN_TIME,CONTROL_STATUS, START_WAREHOUSE_CODE,END_WAREHOUSE_CODE) values('{0}',0, '{1}','{2}', 4, '{3}',0,1,1)", Barcode, StartCode, EndCode, Common.StringUtil.GetDateTime()); int iResult = MainApp._I_BaseService.ExecuteNonQuery_ReturnInt(str); if (iResult == 1) { this.txtbarcode.Text = ""; strResult = string.Format("托盘条码'{0}'下达搬运任务成功", Barcode); MainApp._MessageDialog.ShowResult(bResult, strResult); } else { strResult = string.Format("托盘条码'{0}'下达搬运任务失败", Barcode); MainApp._MessageDialog.ShowResult(bResult, strResult); } strResult = String.Format("用户:{0}-",MainApp._USER.USER_NAME)+strResult; MainApp._I_BaseService.AddLog(strResult); } else { bResult = false; strResult = "起始位置或目标位置不能为空"; MainApp._MessageDialog.ShowResult(bResult, strResult); } } } catch (Exception ex) { MainApp._MessageDialog.ShowException(ex); } finally { MainWindow.mainWin.Cursor = Cursors.Arrow; } } private void btnRefresh_Click(object sender, RoutedEventArgs e) { this.txtbarcode.Text = ""; this.cmbStartPosition.Text = ""; this.cmbEndPosition.Text = ""; } private void Grid_Loaded(object sender, RoutedEventArgs e) { DataTable dtStation = MainApp._I_BaseService.GetList(string.Format("select CELL_CODE,CELL_NAME from wh_cell where cell_type='Station' and BELONG_ZCQ_ID=1 order by CELL_CODE")); this.cmbStartPosition.DisplayMemberPath = "CELL_NAME"; this.cmbStartPosition.SelectedValuePath = "CELL_CODE"; this.cmbStartPosition.ItemsSource = dtStation.DefaultView; this.cmbEndPosition.DisplayMemberPath = "CELL_NAME"; this.cmbEndPosition.SelectedValuePath = "CELL_CODE"; this.cmbEndPosition.ItemsSource = dtStation.DefaultView; } } }