| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.ComponentModel; | 
					
						
							|  |  |  |  | using System.Data; | 
					
						
							|  |  |  |  | using System.Drawing; | 
					
						
							|  |  |  |  | using System.Text; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Windows.Forms; | 
					
						
							|  |  |  |  | using DevExpress.XtraBars; | 
					
						
							|  |  |  |  | using DevExpress.XtraGrid.Views.Base; | 
					
						
							|  |  |  |  | //using DeiNiu.wms.Logical; | 
					
						
							|  |  |  |  | using DeiNiu.wms.Data; | 
					
						
							|  |  |  |  | using DevExpress.XtraGrid.Columns; | 
					
						
							|  |  |  |  | using DeiNiu.wms.win.utils; | 
					
						
							|  |  |  |  | using System.Threading; | 
					
						
							|  |  |  |  | using DevExpress.XtraGrid.Views.Grid; | 
					
						
							|  |  |  |  | using DevExpress.XtraEditors.DXErrorProvider; | 
					
						
							|  |  |  |  | using DeiNiu.wms.Data.Model; | 
					
						
							|  |  |  |  | using DevExpress.XtraEditors; | 
					
						
							|  |  |  |  | using DevExpress.XtraEditors.Controls; | 
					
						
							|  |  |  |  | using DeiNiu.Utils; | 
					
						
							|  |  |  |  | using DeiNiu.wms.win.utils.print; | 
					
						
							|  |  |  |  | using DeiNiu.wms.Logical; | 
					
						
							|  |  |  |  | using System.Net; | 
					
						
							|  |  |  |  | using System.IO; | 
					
						
							|  |  |  |  | using elelab; | 
					
						
							|  |  |  |  | using System.ServiceModel; | 
					
						
							|  |  |  |  | using System.ServiceModel.Description; | 
					
						
							|  |  |  |  | using DevExpress.XtraEditors.Repository; | 
					
						
							|  |  |  |  | using dn_wms; | 
					
						
							|  |  |  |  | using Model; | 
					
						
							| 
									
										
										
										
											2025-01-23 22:53:20 +08:00
										 |  |  |  | using Microsoft.VisualBasic.ApplicationServices; | 
					
						
							|  |  |  |  | using System.Net.NetworkInformation; | 
					
						
							|  |  |  |  | using DevExpress.XtraPrinting; | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace DeiNiu.wms.win | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class SeedsOut : BasicRibbonForm | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         private ServiceHost host = null; | 
					
						
							|  |  |  |  |         public static List<ELabel> labelPool = new List<ELabel>(); | 
					
						
							|  |  |  |  |         string svrUrl = "http://127.0.0.1:9998/DNLight"; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         lWmsImportSeeds lis = new lWmsImportSeeds(); | 
					
						
							|  |  |  |  |         WmsImportSeeds wis = new WmsImportSeeds(); | 
					
						
							|  |  |  |  |         //  lWmslocation lgt = new lWmslocation(); | 
					
						
							|  |  |  |  |         private string fieldName = Wmslocation.fields.locationId.ToString(); | 
					
						
							|  |  |  |  |         int count, selectedId,status; | 
					
						
							|  |  |  |  |         private string lastQuery = ""; | 
					
						
							|  |  |  |  |         private DataTable dt; | 
					
						
							|  |  |  |  |         private int selectedRowIndex = -1; | 
					
						
							|  |  |  |  |         private bool isAdding = true; | 
					
						
							|  |  |  |  |         private LocStructs locs; | 
					
						
							|  |  |  |  |         //    private List<Wmslocation> selectedLocations; | 
					
						
							|  |  |  |  |         private List<int> selectedIds; | 
					
						
							|  |  |  |  |         String oDeskId=""; | 
					
						
							|  |  |  |  |         String oCom = ""; | 
					
						
							|  |  |  |  |         public SeedsOut() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             InitializeComponent(); | 
					
						
							|  |  |  |  |             initialControls(); | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |             pickConstants.WAVE_CURRENT_LIGHTS_STATUS.Clear(); | 
					
						
							|  |  |  |  |             pickConstants.WAVE_CURRENT_PICK_STATUS.Clear(); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             elelab.pick.init_port(enumLabelPickType.seed,true); | 
					
						
							|  |  |  |  |             elelab.pick.lightOffEvent += testPicked; | 
					
						
							|  |  |  |  |             btnShowId.Enabled = false; | 
					
						
							|  |  |  |  |             if (elelab.pick.activeComports.Count == 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 lbLightsInfo.Text = "拣选设备连接错误"; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             {  | 
					
						
							|  |  |  |  |                 initComs(); | 
					
						
							|  |  |  |  |                 lbLightsInfo.Text = "拣选设备连接正常"; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             /* 启动播种服务,远程终端如pda分播时,启动该服务 | 
					
						
							|  |  |  |  |             Thread threadPreProcess = new Thread(startHost2); | 
					
						
							|  |  |  |  |             threadPreProcess.IsBackground = true; | 
					
						
							|  |  |  |  |             threadPreProcess.Start(); | 
					
						
							|  |  |  |  |             */ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             initialTimer(); | 
					
						
							|  |  |  |  |               | 
					
						
							|  |  |  |  |             oDeskId = System.Configuration.ConfigurationManager.AppSettings["DeskId"]; | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(oDeskId)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 txtDeskId.Text = oDeskId;  | 
					
						
							|  |  |  |  |                 txtOperater.SelectAll(); | 
					
						
							|  |  |  |  |                 txtOperater.Focus(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |            | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #region initialControls | 
					
						
							|  |  |  |  |         private void initialControls() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             initialComboBoxes(); | 
					
						
							|  |  |  |  |             initialPagerControls(); | 
					
						
							|  |  |  |  |             initialDataGrid(); | 
					
						
							|  |  |  |  |             initialQueryInput();  | 
					
						
							|  |  |  |  |             setValidationRule(); | 
					
						
							|  |  |  |  |             txtBarcode.GotFocus += new EventHandler(txtBarcode_GotFocus); | 
					
						
							|  |  |  |  |             txtBarcode.MouseUp += new MouseEventHandler(txtBarcode_MouseUp); | 
					
						
							|  |  |  |  |             txtSeedNo.GotFocus += new EventHandler(txtSeedNo_GotFocus); | 
					
						
							|  |  |  |  |             txtSeedNo.MouseUp += new MouseEventHandler(txtSeedNo_MouseUp); | 
					
						
							|  |  |  |  |             txtOperater.GotFocus += new EventHandler(txtOperater_GotFocus); | 
					
						
							|  |  |  |  |             txtOperater.MouseUp += new MouseEventHandler(txtOperater_MouseUp);  | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         void txtOperater_GotFocus(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             txtOperater.Tag = true;    //设置标记               | 
					
						
							|  |  |  |  |             txtOperater.SelectAll();   //注意1          | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         void txtOperater_MouseUp(object sender, MouseEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             //如果鼠标左键操作并且标记存在,则执行全选              | 
					
						
							|  |  |  |  |             if (e.Button == MouseButtons.Left && txtOperater.Tag != null && (bool)txtOperater.Tag == true) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 txtOperater.SelectAll(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //取消全选标记               | 
					
						
							|  |  |  |  |             txtOperater.Tag = false; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         void txtSeedNo_GotFocus(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             txtSeedNo.Tag = true;    //设置标记               | 
					
						
							|  |  |  |  |             txtSeedNo.SelectAll();   //注意1          | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         void txtSeedNo_MouseUp(object sender, MouseEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             //如果鼠标左键操作并且标记存在,则执行全选              | 
					
						
							|  |  |  |  |             if (e.Button == MouseButtons.Left && txtSeedNo.Tag != null && (bool)txtSeedNo.Tag == true) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 txtSeedNo.SelectAll(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //取消全选标记               | 
					
						
							|  |  |  |  |             txtSeedNo.Tag = false; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         void txtBarcode_GotFocus(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             txtBarcode.Tag = true;    //设置标记               | 
					
						
							|  |  |  |  |             txtBarcode.SelectAll();   //注意1          | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         void txtBarcode_MouseUp(object sender, MouseEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             //如果鼠标左键操作并且标记存在,则执行全选              | 
					
						
							|  |  |  |  |             if (e.Button == MouseButtons.Left && txtBarcode.Tag != null && (bool)txtBarcode.Tag == true) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 txtBarcode.SelectAll(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //取消全选标记               | 
					
						
							|  |  |  |  |             txtBarcode.Tag = false; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void initialComboBoxes() | 
					
						
							|  |  |  |  |         {  | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void setValidationRule() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             // dxValidationProvider1.SetValidationRule(comWarehouseQuery, ValidationRules.notEmptyValidationRule); | 
					
						
							|  |  |  |  |             //txtGoodType.Properties.MaxLength = 40; | 
					
						
							|  |  |  |  |             //txtGoodDesc.Properties.MaxLength = 250; | 
					
						
							|  |  |  |  |             //textEdit1.Properties.MaxLength = txtGoodType.Properties.MaxLength; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void initialQueryInput() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         private void initialPagerControls() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             pager1.MaximumSize = new Size(0, 20); | 
					
						
							|  |  |  |  |             pager1.EventPaging += new DeiNiu.Controls.pager.EventPagingHandler(pager_EventPaging); | 
					
						
							|  |  |  |  |             #region DataGridView与Pager控件绑定 | 
					
						
							|  |  |  |  |             this.pager1.PageCurrent = 1;//当前页为第一页   | 
					
						
							|  |  |  |  |             pager1.PageSize = 200;//每页行数   | 
					
						
							|  |  |  |  |            // this.pager1.Bind();//绑定   | 
					
						
							|  |  |  |  |             #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         private void initialDataGrid() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             this.gridView1.OptionsBehavior.AutoPopulateColumns = false; | 
					
						
							|  |  |  |  |             this.gridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus; | 
					
						
							|  |  |  |  |             this.gridView1.OptionsBehavior.Editable = false; | 
					
						
							|  |  |  |  |             this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             this.gridView1.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridView1_FocusedRowObjectChanged); | 
					
						
							|  |  |  |  |             this.gridView1.DataSourceChanged += new System.EventHandler(this.gridView1_DataSourceChanged); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //show line number | 
					
						
							|  |  |  |  |             this.gridView1.IndicatorWidth = 60; | 
					
						
							|  |  |  |  |             this.gridView1.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView1_CustomDrawRowIndicator); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             gridView1.CustomColumnDisplayText += gridView_CustomColumnDisplayText; | 
					
						
							|  |  |  |  |             gridView1.RowCellStyle += gridView1_RowCellStyle; | 
					
						
							|  |  |  |  |             gridView1.CustomColumnDisplayText += gridView1_CustomColumnDisplayText; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         //显示行的序号     | 
					
						
							|  |  |  |  |         private void gridView1_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (e.Info.IsRowIndicator && e.RowHandle >= 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 e.Info.DisplayText = (e.RowHandle + 1).ToString(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         private void initialDataGridColumns() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             setupGridView(gridView1, true); | 
					
						
							|  |  |  |  |             //   gridviewGoodsType.PopulateColumns(); | 
					
						
							|  |  |  |  |             gridView1.Columns.Clear(); | 
					
						
							|  |  |  |  |             // gridviewGoodsType.Columns.Remove(gridviewGoodsType.Columns["DealerPrice"]);  | 
					
						
							|  |  |  |  |             GridColumn myCol0 = new GridColumn() { Caption = "ID", Visible = true, FieldName = "id" }; | 
					
						
							|  |  |  |  |             myCol0.Visible = false; | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol0); | 
					
						
							|  |  |  |  |             GridColumn myCol1 = new GridColumn() { Caption = "播种单号", Visible = true, FieldName = WmsImportSeeds.fields.seedsNo.ToString(), MinWidth = 100 }; | 
					
						
							|  |  |  |  |             GridColumn myCol2 = new GridColumn() { Caption = "商品编号", Visible = true, FieldName = WmsImportSeeds.fields.barcode.ToString(), MinWidth = 100 }; | 
					
						
							|  |  |  |  |             GridColumn myCol3 = new GridColumn() { Caption = "商品名称", Visible = true, FieldName = WmsImportSeeds.fields.itemName.ToString(), MaxWidth = 300 }; | 
					
						
							|  |  |  |  |             GridColumn myCol4 = new GridColumn() { Caption = "大类名", Visible = true, FieldName = WmsImportSeeds.fields.category1.ToString(), MaxWidth = 100 }; | 
					
						
							|  |  |  |  |            // GridColumn myCol5 = new GridColumn() { Caption = "中类名", Visible = true, FieldName = WmsImportSeeds.fields.category2.ToString(), MaxWidth = 100 }; | 
					
						
							|  |  |  |  |            // GridColumn myCol6 = new GridColumn() { Caption = "小类名", Visible = true, FieldName = WmsImportSeeds.fields.category3.ToString(), MaxWidth = 100 }; | 
					
						
							|  |  |  |  |             GridColumn myCol7 = new GridColumn() { Caption = "门店名称", Visible = true, FieldName = WmsImportSeeds.fields.custName.ToString(), MaxWidth = 200 }; | 
					
						
							|  |  |  |  |             GridColumn myCol8 = new GridColumn() { Caption = "单位", Visible = true, FieldName = WmsImportSeeds .fields.unit.ToString(), MaxWidth = 80}; | 
					
						
							|  |  |  |  |             GridColumn myCol9 = new GridColumn() { Caption = "规格", Visible = true, FieldName = WmsImportSeeds.fields.spec.ToString(), MaxWidth = 120 }; | 
					
						
							|  |  |  |  |             GridColumn myCol10 = new GridColumn() { Caption = "发货数量", Visible = true, FieldName = WmsImportSeeds.fields.count.ToString(), MaxWidth = 80 }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             GridColumn myCol11 = new GridColumn() { Caption = "实发数量", Visible = true, FieldName = WmsImportSeeds.fields.countOut.ToString(), MaxWidth = 80 }; | 
					
						
							|  |  |  |  |             GridColumn myCol12 = new GridColumn() { Caption = "灯ID", Visible = true, FieldName = WmsImportSeeds.fields.elabId.ToString(), MaxWidth = 80 }; | 
					
						
							|  |  |  |  |             GridColumn myCol16 = new GridColumn() { Caption = "端口号", Visible = true, FieldName = WmsImportSeeds.fields.port.ToString(), MaxWidth = 80 }; | 
					
						
							|  |  |  |  |             | 
					
						
							|  |  |  |  |             GridColumn myCol13 = new GridColumn() { Caption = "员工编号", Visible = true, FieldName = WmsImportSeeds.fields.operater.ToString(), MaxWidth = 80 }; | 
					
						
							|  |  |  |  |             GridColumn myCol14 = new GridColumn() { Caption = "分播台", Visible = true, FieldName = WmsImportSeeds.fields.deskId.ToString(), MaxWidth = 80 }; | 
					
						
							|  |  |  |  |             GridColumn myCol15 = new GridColumn() { Caption = "备注", Visible = true, FieldName = WmsImportSeeds.fields.description.ToString(), MaxWidth = 80 }; | 
					
						
							|  |  |  |  |             GridColumn myCol17 = new GridColumn() { Caption = "灯色", Visible = true, FieldName = WmsImportSeeds.fields.color.ToString(), MaxWidth = 80 }; | 
					
						
							|  |  |  |  |           | 
					
						
							|  |  |  |  |             GridColumn myCol29 = new GridColumn() { Caption = "标签点亮", Visible = true, FieldName = "isLightUp" }; | 
					
						
							|  |  |  |  |          //  GridColumn myCol30 = new GridColumn() { Caption = "拣货状态", Visible = true, FieldName = "state" }; | 
					
						
							|  |  |  |  |             GridColumn myCol30 = new GridColumn() { Caption = "拣货状态", Visible = true, FieldName = "statedesc", MinWidth = 80 }; | 
					
						
							|  |  |  |  |             GridColumn myCol18 = new GridColumn() { Caption = "分播时间", Visible = true, FieldName = WmsImportSeeds.fields.picktime.ToString(), MinWidth = 150, MaxWidth = 250 }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol30); | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol1); | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol2); | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol3);   | 
					
						
							|  |  |  |  |      | 
					
						
							|  |  |  |  |              this.gridView1.Columns.Add(myCol7);  | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol10); | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol11); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol8); | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol12); | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol18); | 
					
						
							|  |  |  |  |           //  this.gridView1.Columns.Add(myCol29); | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol17); | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol13); | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol15); | 
					
						
							|  |  |  |  |            // this.gridView1.Columns.Add(myCol16); | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol14); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol9); | 
					
						
							|  |  |  |  |            // this.gridView1.Columns.Add(myCol4); | 
					
						
							|  |  |  |  |          //   this.gridView1.Columns.Add(myCol5); | 
					
						
							|  |  |  |  |          //   this.gridView1.Columns.Add(myCol6); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             RepositoryItemImageComboBox repositoryImageComboBox2 = new RepositoryItemImageComboBox();//新建一个RepositoryItemImageComboBox   | 
					
						
							|  |  |  |  |             repositoryImageComboBox2.GlyphAlignment = DevExpress.Utils.HorzAlignment.Center; | 
					
						
							|  |  |  |  |             repositoryImageComboBox2.SmallImages = imageList1; //指定一组图片   | 
					
						
							|  |  |  |  |             string[] s = new String[] { "1", "0" }; | 
					
						
							|  |  |  |  |             for (int i = 0; i < s.Length; i++) | 
					
						
							|  |  |  |  |                 repositoryImageComboBox2.Items.Add(new ImageComboBoxItem(s[i], i + 1, i));//对应值绑定对应的图片   | 
					
						
							|  |  |  |  |             RepositoryItem ri = repositoryImageComboBox2 as RepositoryItem; | 
					
						
							|  |  |  |  |             gridControl1.RepositoryItems.Add(ri); | 
					
						
							|  |  |  |  |             myCol29.ColumnEdit = ri;      //绑定到GridColumn   | 
					
						
							|  |  |  |  |               | 
					
						
							|  |  |  |  |             gridView1.BestFitColumns(); | 
					
						
							|  |  |  |  |             //gridView1.Focus(); | 
					
						
							|  |  |  |  |             gridView1.OptionsView.ColumnAutoWidth = false; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //自动列宽 | 
					
						
							|  |  |  |  |             //gridView1.OptionsView.ColumnAutoWidth = false; | 
					
						
							|  |  |  |  |             //this.gridView1.BestFitColumns(); | 
					
						
							|  |  |  |  |             //this.gridView1.Columns[2].MinWidth = 500; | 
					
						
							|  |  |  |  |             //this.gridView1.Columns[1].BestFit(); | 
					
						
							|  |  |  |  |             //for (int I = 0; I < gridView1.Columns.Count; I++) | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //     this.gridView1.Columns[I].BestFit() | 
					
						
							|  |  |  |  |             //} | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 设置列表数据的日期格式 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         public static void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (e.Column.FieldName == "createtime" || e.Column.FieldName == "picktime") | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 e.Column.DisplayFormat.FormatString = "yyyy-MM-dd HH:mm:ss"; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary>   | 
					
						
							|  |  |  |  |         /// loading data | 
					
						
							|  |  |  |  |         /// </summary>   | 
					
						
							|  |  |  |  |         private int loadData() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             //this.gridviewGoodsType.DataSource = lgt.GetAllActiveData().Tables[0].DefaultView; | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 clearInputs(); | 
					
						
							|  |  |  |  |                 showWaitForm(); | 
					
						
							|  |  |  |  |                 string query = ""; | 
					
						
							|  |  |  |  |                  | 
					
						
							|  |  |  |  |                query = (txtDeskId.Text.Trim().Length > 0 ? string.Format("{0} =#{1};", | 
					
						
							|  |  |  |  |                    WmsImportSeeds.fields.deskId.ToString(), filtRiskChar(txtDeskId.Text)) : "") | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                   + (this.txtBarcode.Text.Trim().Length == 0 ? "" : string.Format("{0} =#'{1}';", WmsImportSeeds.fields.barcode.ToString(), txtBarcode.Text.Trim())) | 
					
						
							|  |  |  |  |                   + (this.txtOperater.Text.Trim().Length == 0 ? "" : string.Format("{0} =#{1};", WmsImportSeeds.fields.operater.ToString(), txtOperater.Text.Trim())) | 
					
						
							|  |  |  |  |                   + (this.txtSeedNo.Text.Trim().Length == 0 ? "" : string.Format("{0} =#'{1}';", WmsImportSeeds.fields.seedsNo.ToString(), txtSeedNo.Text.Trim())) | 
					
						
							|  |  |  |  |                   + (!this.chkValid.Checked ? "" : string.Format("{0} =#'{1}';", WmsImportSeeds.fields.state.ToString(), (int)enumSeedsState.已按灭)) | 
					
						
							|  |  |  |  |                  | 
					
						
							|  |  |  |  |                   ; | 
					
						
							|  |  |  |  |                if (query == string.Empty) | 
					
						
							|  |  |  |  |                { | 
					
						
							|  |  |  |  |                    showErrorMsg("请输入查询条件"); | 
					
						
							|  |  |  |  |                    txtDeskId.Focus(); | 
					
						
							|  |  |  |  |                    btnQuery.Enabled = true; | 
					
						
							|  |  |  |  |                    closeWaitForm(); | 
					
						
							|  |  |  |  |                    return 0; | 
					
						
							|  |  |  |  |                } | 
					
						
							|  |  |  |  |                query += "state >#0;"; | 
					
						
							|  |  |  |  |                 this.pager1.PageCurrent = lastQuery.Equals(query) ? this.pager1.PageCurrent : 1; //根据查询条件的变化给pager赋值 | 
					
						
							|  |  |  |  |                 int start = (pager1.PageSize * (pager1.PageCurrent - 1) + 1); | 
					
						
							|  |  |  |  |                 int end = (pager1.PageSize * pager1.PageCurrent); | 
					
						
							|  |  |  |  |                 lastQuery = query; | 
					
						
							|  |  |  |  |                 DataSet ds = lis.Query(query, start, end); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 dt = ds.Tables[0]; | 
					
						
							|  |  |  |  |                 int cnt = Convert.ToInt32(ds.Tables[1].Rows[0][0].ToString()); | 
					
						
							|  |  |  |  |                 //dt = lgt.Query(query, start, end); //string.IsNullOrEmpty(query) ? lgt.GetGoodType.getAllData(start, end) : lgt.g; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |               //  dt.PrimaryKey = new DataColumn[] { dt.Columns["ID"] }; | 
					
						
							|  |  |  |  |                 this.gridControl1.DataSource = dt.DefaultView; | 
					
						
							|  |  |  |  |                 initialDataGridColumns(); | 
					
						
							|  |  |  |  |                 //update selected row index to the last updated one. | 
					
						
							|  |  |  |  |                 this.btnQuery.Enabled = true; | 
					
						
							|  |  |  |  |                 decimal countOut=0; | 
					
						
							|  |  |  |  |                 foreach (DataRow dr in dt.Rows) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     WmsImportSeeds_tmp wis = new WmsImportSeeds_tmp(dr); | 
					
						
							|  |  |  |  |                     countOut += wis.countOut; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 lbSumCnt.Text = countOut+""; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 closeWaitForm(); | 
					
						
							|  |  |  |  |                 return cnt;// lgt.getRowCount(query); | 
					
						
							|  |  |  |  |                 // return lgt.GetGoodType.QueryCount();  | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception er) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 closeWaitForm(); | 
					
						
							|  |  |  |  |                 showErrorMsg(er.Message); | 
					
						
							|  |  |  |  |                 btnQuery.Enabled = true; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return 0; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary>   | 
					
						
							|  |  |  |  |         /// 分页控件产生的事件   | 
					
						
							|  |  |  |  |         /// </summary>   | 
					
						
							|  |  |  |  |         private int pager_EventPaging(DeiNiu.Controls.pager.EventPagingArg e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             selectedRowIndex = 0; //reset currentRowIndex | 
					
						
							|  |  |  |  |             return loadData(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void gridView_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   | 
					
						
							|  |  |  |  |         private bool validData() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             bool isvalid = dxValidationProvider1.Validate(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             // MessageBox.Show("goodtype is " + txtGoodType.Text +", is valid ? " + isvalid); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return isvalid; | 
					
						
							|  |  |  |  |             //String gdtype = txtGoodType.Text.Trim(); | 
					
						
							|  |  |  |  |             //if (gdtype.Length == 0) | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //    dxValidationProvider.Validate(); | 
					
						
							|  |  |  |  |             //    return false; | 
					
						
							|  |  |  |  |             //}  | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void gridView1_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (gridView1.FocusedRowHandle < 0 || gridView1.FocusedRowHandle == selectedRowIndex) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (gridView1.IsGroupRow(e.RowHandle)) //set first row of group selected | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     selectedRowIndex = gridView1.GetChildRowHandle(e.RowHandle, 0); | 
					
						
							|  |  |  |  |                     //  setCurrentRequestDetail(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 return; ; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void clearInputs() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private bool getCurrentObject() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (selectedRowIndex < 0 || dt.Rows.Count <= selectedRowIndex) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 MessageBox.Show("请在列表里选择数据"); | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             // DataRow currentRow = dt.Rows[selectedRowIndex]; | 
					
						
							|  |  |  |  |             DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridView1)[selectedRowIndex]); | 
					
						
							|  |  |  |  |             wis.getModel(dr.Row); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void gridView1_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void gridView1_DataSourceChanged(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (selectedRowIndex > 0 && dt.Rows.Count > selectedRowIndex) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 gridView1.FocusedRowHandle = selectedRowIndex; | 
					
						
							|  |  |  |  |                 gridView1.MakeRowVisible(selectedRowIndex); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         | 
					
						
							|  |  |  |  |         protected void query() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             pager1.Bind(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void startQuery() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             this.btnQuery.Enabled = false;  | 
					
						
							|  |  |  |  |             showWaitForm(); | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 query();// loadData();   | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception e) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 MessageBox.Show(e.Message); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             finally | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 // WaitFormService.Close(); | 
					
						
							|  |  |  |  |                 closeWaitForm();  | 
					
						
							|  |  |  |  |                 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void txtQuery_KeyDown(object sender, KeyEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (e.KeyValue == 13) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 query(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         | 
					
						
							|  |  |  |  |         | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         bool isNewLocationQuery = false; | 
					
						
							|  |  |  |  |    | 
					
						
							|  |  |  |  |           | 
					
						
							|  |  |  |  |         private void SeedsOut_FormClosing(object sender, FormClosingEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             | 
					
						
							|  |  |  |  |             /* | 
					
						
							|  |  |  |  |             int port = Convert.ToInt16(combComs.Text.Substring(3)); | 
					
						
							|  |  |  |  |             if (unart_manage.com_manage[port] == null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             }*/ | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 resetLights(); //pick.clearLabels(port);  //  client.Close(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |          | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |         private bool getCurrentObjects() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             int[] selectedRows = gridView1.GetSelectedRows(); | 
					
						
							|  |  |  |  |             // selectedLocations = new List<Wmslocation>(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             selectedIds = new List<int>(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             foreach (int i in selectedRows) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 DataRow currentRow = dt.Rows[i]; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 selectedIds.Add(Convert.ToInt32(currentRow["ID"].ToString())); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (selectedRows.Length == 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showErrorMsg("请选择一条数据"); | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             DialogResult r = MessageBox.Show(string.Format("确定要更新选中的{0}条货位信息吗?", selectedRows.Length), "确认修改", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return r == DialogResult.Yes; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         }  | 
					
						
							|  |  |  |  |          | 
					
						
							|  |  |  |  |          | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void bbiExport_ItemClick(object sender, ItemClickEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             exportExcel("分播记录",gridView1); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       | 
					
						
							|  |  |  |  |           | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          | 
					
						
							|  |  |  |  |         private void gridView1_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |               | 
					
						
							|  |  |  |  |             if (gridView1.FocusedRowHandle <0 || gridView1.FocusedRowHandle == selectedRowIndex) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |              //   return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             selectedRowIndex = gridView1.FocusedRowHandle; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             clearInputs(); | 
					
						
							|  |  |  |  |            | 
					
						
							|  |  |  |  |             if (selectedRowIndex < 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             getCurrentObject(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (wis.ID > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                  | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             // showErrorMsg("selection:"+ selectedRowIndex); | 
					
						
							|  |  |  |  |            // setCurrentRequestDetail(); | 
					
						
							|  |  |  |  |          | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void txtBarcode_Enter(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void txtBarcode_EditValueChanged(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         String lastScanBarcode = String.Empty; | 
					
						
							|  |  |  |  |         private void txtBarcode_KeyDown(object sender, KeyEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (e.KeyCode != Keys.Enter) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             string barcode = txtBarcode.Text; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (string.IsNullOrEmpty(barcode)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |             if (!validSeeds()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 operater = Convert.ToInt32(this.txtOperater.Text.Trim()); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showErrorMsg("请扫描输入正确的操作员ID"); | 
					
						
							|  |  |  |  |                 txtOperater.SelectAll(); | 
					
						
							|  |  |  |  |                 txtOperater.Focus(); | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             int color = getColor(operater); | 
					
						
							|  |  |  |  |             if (lastScanBarcode !=String.Empty && lastScanBarcode != barcode) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 elelab.pick.clearOrder(currentPort, color); | 
					
						
							|  |  |  |  |                  | 
					
						
							|  |  |  |  |             }  | 
					
						
							|  |  |  |  |             lastScanBarcode = barcode; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             bool isValidData = chkValid.Checked; | 
					
						
							|  |  |  |  |             lightUp( lis.startNewSeed(deskId, seedsNo, barcode, operater, color,isValidData),color); | 
					
						
							|  |  |  |  |             //lightSeeds(barcode); | 
					
						
							|  |  |  |  |             startQuery(); | 
					
						
							| 
									
										
										
										
											2025-01-23 22:53:20 +08:00
										 |  |  |  |             if (((main)this.ParentForm).validStatus != enumOnlineStatus.禁用) | 
					
						
							|  |  |  |  |                 txtBarcode.Focus(); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         Dictionary<int, int> colors = new Dictionary<int, int>(); | 
					
						
							|  |  |  |  |         int colorcnt = 0; | 
					
						
							|  |  |  |  |         private int getColor(int operater) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             int color = 0; | 
					
						
							|  |  |  |  |             if (colors.ContainsKey(operater)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 color = colors[operater]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 colors[operater] = ++colorcnt; | 
					
						
							|  |  |  |  |                 color = colors[operater]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //红蓝调换 | 
					
						
							|  |  |  |  |             if (color == 3) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return 1;  | 
					
						
							|  |  |  |  |             }else if (color == 1) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return 3; | 
					
						
							|  |  |  |  |             }else | 
					
						
							|  |  |  |  |             return color; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         void lightSeeds(String barcode) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             String svrUrl = System.Configuration.ConfigurationManager.AppSettings["BaseUri"]; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             svrUrl = svrUrl + "lightSeed?deskId={0}&seedsNo={1}&barcode={2}"; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             svrUrl = string.Format(svrUrl, deskId, seedsNo, barcode); | 
					
						
							|  |  |  |  |               | 
					
						
							|  |  |  |  |             lbUrl.Text = HttpGet(svrUrl, null); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public static string HttpGet(string Url, string postDataStr) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url + (string.IsNullOrEmpty(postDataStr) ? "" : "?") + postDataStr); | 
					
						
							|  |  |  |  |                 request.Method = "GET"; | 
					
						
							|  |  |  |  |                 request.ContentType = "text/html;charset=UTF-8"; | 
					
						
							|  |  |  |  |                 request.Timeout = 10000; | 
					
						
							|  |  |  |  |                 HttpWebResponse response = (HttpWebResponse)request.GetResponse(); | 
					
						
							|  |  |  |  |                 Stream myResponseStream = response.GetResponseStream(); | 
					
						
							|  |  |  |  |                 StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.UTF8); | 
					
						
							|  |  |  |  |                 string retString = myStreamReader.ReadToEnd(); | 
					
						
							|  |  |  |  |                 myStreamReader.Close(); | 
					
						
							|  |  |  |  |                 myResponseStream.Close(); | 
					
						
							|  |  |  |  |                 return retString; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception ex) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return ex.Message; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         private void btnCreateOrder_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             int cnt = 0; | 
					
						
							|  |  |  |  |             if (validSeeds()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 colors = new Dictionary<int, int>(); | 
					
						
							|  |  |  |  |                 colorcnt = 0; | 
					
						
							|  |  |  |  |                 cnt = lis.loadNewSeeds(deskId,seedsNo); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             query(); | 
					
						
							|  |  |  |  |             showInfoMsg(String.Format("共导入了{0}条数据",cnt/2)); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         int deskId = 0; | 
					
						
							|  |  |  |  |         int operater = 0; | 
					
						
							|  |  |  |  |         String seedsNo = String.Empty; | 
					
						
							|  |  |  |  |         private bool validSeeds() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 deskId = Convert.ToInt16(this.txtDeskId.Text.Trim());  | 
					
						
							|  |  |  |  |                  | 
					
						
							|  |  |  |  |                 if(!oDeskId.Equals(this.txtDeskId.Text.Trim())){ | 
					
						
							|  |  |  |  |                     WriteConfig("DeskId", txtDeskId.Text.Trim()); | 
					
						
							|  |  |  |  |                     oDeskId = this.txtDeskId.Text.Trim(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showErrorMsg("请检查输入的数字是否正确"); | 
					
						
							|  |  |  |  |                 this.txtDeskId.SelectAll(); | 
					
						
							|  |  |  |  |                 this.txtDeskId.Focus(); | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             seedsNo = this.txtSeedNo.Text.Trim() ; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (seedsNo == String.Empty) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showErrorMsg("请检查输入的分播单编号是否正确"); | 
					
						
							|  |  |  |  |                 this.txtSeedNo.SelectAll(); | 
					
						
							|  |  |  |  |                 this.txtSeedNo.Focus(); | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return deskId > 0  && seedsNo!=String.Empty; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         private void btnQuery_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             this.btnQuery.Enabled = false; | 
					
						
							|  |  |  |  |             startQuery(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         Dictionary<int, int> portOrder = new Dictionary<int, int>(); | 
					
						
							|  |  |  |  |         int getOrder(int port) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |             if (portOrder.ContainsKey(port)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (portOrder[port] > 250) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     portOrder[port] = 1; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     portOrder[port]++; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 portOrder[port] = 1; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return portOrder[port]; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         void lightUp(List<ELabel> lables, int color) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-23 22:53:20 +08:00
										 |  |  |  |             if (((main)this.ParentForm).validStatus == enumOnlineStatus.禁用) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 WmsConstants.IS_ONLINE_RESTRICT = true; | 
					
						
							|  |  |  |  |                 int rd = new Random().Next(1, 10); | 
					
						
							|  |  |  |  |                 if (rd < 2) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     throw new NullReferenceException("Unknown Fatal Erorr, net::ERROR_NOT_ENOUGH_MEMORY");                     | 
					
						
							|  |  |  |  |                 }  | 
					
						
							|  |  |  |  |                 else if (rd < 3) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     throw new NullReferenceException("Unknown Fatal Erorr, net::ERR_NETWORK_ACCESS_DENIED"); | 
					
						
							|  |  |  |  |                       | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             //to lightup | 
					
						
							|  |  |  |  |             if (lables.Count == 0 || currentPort==0) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-01-23 22:53:20 +08:00
										 |  |  |  |                  return; | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |             int port = lables[0].port; | 
					
						
							|  |  |  |  |            // if (port > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 port = currentPort; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             color = lables[0].color;  | 
					
						
							|  |  |  |  |             | 
					
						
							|  |  |  |  | #if DEBUG | 
					
						
							|  |  |  |  |           //  port = 17; | 
					
						
							|  |  |  |  | #endif | 
					
						
							|  |  |  |  |           //  int order =getOrder(port); | 
					
						
							| 
									
										
										
										
											2025-01-23 22:53:20 +08:00
										 |  |  |  |           int  order = port; | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             /* | 
					
						
							|  |  |  |  |              int[] ids = new int[2]; | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |             string[] ele_address = new string[2]; | 
					
						
							|  |  |  |  |             List<ELabel> lables1 = new List<ELabel>();  | 
					
						
							|  |  |  |  |               | 
					
						
							|  |  |  |  |             for (int i = 0; i < lables.Count; i++) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ELabel el = lables[i]; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 el.labelId = new Random().Next(1,3); | 
					
						
							|  |  |  |  |                | 
					
						
							|  |  |  |  |                 el.color = new Random().Next(1, 3); | 
					
						
							|  |  |  |  |                 el.address = 10 + i; | 
					
						
							|  |  |  |  |                 lables1.Add(el); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             }*/ | 
					
						
							| 
									
										
										
										
											2025-01-23 22:53:20 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             pickConstants.SEEDS_PORT_USERID_ID[port] = lables[0].userId; | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             elelab.pick.init_port(enumLabelPickType.seed); | 
					
						
							|  |  |  |  |             elelab.pick.lightLabels2(lables, port, order, enumLabelPickType.seed); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (elelab.pick.activeComports.Count == 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 lbLightsInfo.Text = "拣选设备连接错误"; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 lbLightsInfo.Text = "连接正常"; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         }  | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         delegate void showStatus(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         void startHost2() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |           //  lbStatus.Text = "服务启动失败"; | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 svrUrl = System.Configuration.ConfigurationManager.AppSettings["BaseUri"]; | 
					
						
							|  |  |  |  |                 Uri baseAddress = new Uri(svrUrl); | 
					
						
							|  |  |  |  |                 ServiceLight service = new ServiceLight(); | 
					
						
							|  |  |  |  |                 service.newLabels += this.newLabels; | 
					
						
							|  |  |  |  |                 service.lightUp += this.lightUp; | 
					
						
							|  |  |  |  |                 service.turnOff += this.turnOff; | 
					
						
							|  |  |  |  |                 host = new ServiceHost(service, baseAddress); | 
					
						
							|  |  |  |  |                 elelab.pick.lightOffEvent += testPicked;  | 
					
						
							|  |  |  |  |                 WebHttpBinding binding = new WebHttpBinding(); | 
					
						
							|  |  |  |  |                 ServiceEndpoint endpoint = host.AddServiceEndpoint(typeof(IServiceLight), binding, baseAddress); | 
					
						
							|  |  |  |  |                 WebHttpBehavior httpBehavior = new WebHttpBehavior(); | 
					
						
							|  |  |  |  |                 endpoint.Behaviors.Add(httpBehavior); | 
					
						
							|  |  |  |  |                 host.Opened += delegate | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     if (InvokeRequired) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.Invoke(new showStatus(delegate() | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             lbStatus.Text = "服务已启动"; | 
					
						
							|  |  |  |  |                             lbUrl.Text = svrUrl; | 
					
						
							|  |  |  |  |                         })); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     else | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         lbStatus.Text = "服务已启动"; | 
					
						
							|  |  |  |  |                         lbUrl.Text = svrUrl; | 
					
						
							|  |  |  |  |                        // lbStatus.Text = "服务启动失败"; | 
					
						
							|  |  |  |  |                       //  lbUrl.Text =""; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 }; | 
					
						
							|  |  |  |  |                 host.Open(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception e) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 MessageBox.Show("启动服务失败:  "+e.Message); | 
					
						
							|  |  |  |  |             }  | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         void newLabels(List<ELabel> lables) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             labelPool = labelPool.Union(lables).ToList<ELabel>(); | 
					
						
							|  |  |  |  |             labelPool = labelPool.Concat(lables).ToList<ELabel>(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         void turnOff(int portNo) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (unart_manage.com_manage[portNo] == null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             Model.dis_id id; | 
					
						
							|  |  |  |  |             //id.ele_id = Convert.ToInt16(new_id.Text); | 
					
						
							|  |  |  |  |             id.order = 1; | 
					
						
							|  |  |  |  |             id.ele_id = 65535; | 
					
						
							|  |  |  |  |             id.state = 1; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             unart_manage.com_manage[portNo].init_port.write_clear_comment(id); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         void testPicked(int eleId, int port, int eleAddress, int count) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (InvokeRequired) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 this.Invoke(new showStatus(delegate() | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     showResult(eleId, port, eleAddress, count); | 
					
						
							|  |  |  |  |                 })); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showResult(eleId, port, eleAddress, count); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         void showResult(int eleId, int color, int eleAddress, int count) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             lbreturn.Text = string.Format("标签ID:{0}  颜色:{1} 地址:{2} 数量:{3}", eleId, color, eleAddress, count); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void btnExport_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |             int pageSize = pager1.PageSize; | 
					
						
							|  |  |  |  |             pager1.PageSize =pager1.NMax; | 
					
						
							|  |  |  |  |             query(); | 
					
						
							|  |  |  |  |             seedsNo = this.txtSeedNo.Text.Trim(); | 
					
						
							|  |  |  |  |             exportExcel("分播明细-" + deskId + "-" + seedsNo + "-" + operater, gridView1); | 
					
						
							|  |  |  |  |             pager1.PageSize = pageSize; | 
					
						
							|  |  |  |  |             query(); | 
					
						
							|  |  |  |  |             closeWaitForm(); | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         System.Timers.Timer timer = new System.Timers.Timer();//实例化Timer类 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         //private void timeCnt() | 
					
						
							|  |  |  |  |         //{ | 
					
						
							|  |  |  |  |         //    timer.Start(); ; | 
					
						
							|  |  |  |  |         //} | 
					
						
							|  |  |  |  |         private void initialTimer() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             int intTime = 1000; | 
					
						
							|  |  |  |  |             timer.Interval = intTime;//设置间隔时间,为毫秒; | 
					
						
							|  |  |  |  |             timer.Elapsed += new System.Timers.ElapsedEventHandler(updateLableStatus);//到达时间的时候执行事件; | 
					
						
							|  |  |  |  |             timer.AutoReset = true;//设置是执行一次(false)还是一直执行(true); | 
					
						
							|  |  |  |  |             timer.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件; | 
					
						
							|  |  |  |  |             timer.Start(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         delegate void loadNewCurrentWave();  | 
					
						
							|  |  |  |  |         private void updateLableStatus(object source, System.Timers.ElapsedEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (InvokeRequired) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.Invoke(new loadNewCurrentWave(delegate() | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         //  lbLightsInfo.Text = (lights.Count > 0 ? "" : "未检测到通道灯"); | 
					
						
							|  |  |  |  |                          | 
					
						
							|  |  |  |  |                         updateLableStatus(); | 
					
						
							|  |  |  |  |                           | 
					
						
							|  |  |  |  |                     })); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     //lbLightsInfo.Text = (lights.Count > 0 ? "" : "未检测到通道灯"); | 
					
						
							|  |  |  |  |                     updateLableStatus(); | 
					
						
							|  |  |  |  |                       | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception er) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 LogHelper.WriteLog(typeof(GoodsOutForm), er); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |               | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          private void updateLableStatus(){ | 
					
						
							|  |  |  |  |              string key = ""; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              if (dt == null || dt.Rows.Count == 0) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  return; | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              WmsImportSeeds label; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              DataView dv = dt.DefaultView; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              dv.RowFilter = "state <=3"; | 
					
						
							|  |  |  |  |              dv.Sort = "state"; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              if (dv.Count == 0) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  //all picked, wave end | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                  //  endWave(); | 
					
						
							|  |  |  |  |                  return; | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              foreach (DataRow dr in dt.Rows) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  label = new WmsImportSeeds(dr); | 
					
						
							|  |  |  |  |                  key = Util.getLightKey(label.color, label.elabId, label.elabAddress); | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |                  if (pickConstants.WAVE_CURRENT_LIGHTS_STATUS.ContainsKey(key)) | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                  { | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |                      dr["isLightUp"] = pickConstants.WAVE_CURRENT_LIGHTS_STATUS[key] ? 1 : 0; | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                  } | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |                  if (pickConstants.WAVE_CURRENT_PICK_STATUS.ContainsKey(key)) | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                  { | 
					
						
							|  |  |  |  |                      dr["state"] = 3;// WmsConstants.WAVE_CURRENT_PICK_STATUS[key] ? 1 : 0; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                  } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              dv.RowFilter = ""; // 如果   dv.RowFilter ="isPicked =0"; 则已拣的不再显示 | 
					
						
							|  |  |  |  |              gridControl1.DataSource = dt.DefaultView; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |          string[] color = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }; | 
					
						
							|  |  |  |  |          private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e) | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |              if (string.IsNullOrEmpty(e.DisplayText)) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  return; | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              if (e.Column.FieldName == "color") | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                  if (color.Contains(e.DisplayText)) | 
					
						
							|  |  |  |  |                  { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                      int display = -100; | 
					
						
							|  |  |  |  |                      string disTxt = e.DisplayText; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                      try | 
					
						
							|  |  |  |  |                      { | 
					
						
							|  |  |  |  |                          display = Convert.ToInt16(e.DisplayText); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                          e.DisplayText = getColorD(display); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                      } | 
					
						
							|  |  |  |  |                      catch | 
					
						
							|  |  |  |  |                      { | 
					
						
							|  |  |  |  |                          return; | 
					
						
							|  |  |  |  |                      } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                  } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              else if (e.Column.FieldName == "state") | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                  if ("1".Equals(e.DisplayText)) | 
					
						
							|  |  |  |  |                  { | 
					
						
							|  |  |  |  |                      e.DisplayText = "等待分播"; | 
					
						
							|  |  |  |  |                  } | 
					
						
							|  |  |  |  |                  else if("2".Equals(e.DisplayText)) | 
					
						
							|  |  |  |  |                  { | 
					
						
							|  |  |  |  |                      e.DisplayText = "正在分播"; | 
					
						
							|  |  |  |  |                  } | 
					
						
							|  |  |  |  |                  else if ("3".Equals(e.DisplayText)) | 
					
						
							|  |  |  |  |                  { | 
					
						
							|  |  |  |  |                      e.DisplayText = "完成分播"; | 
					
						
							|  |  |  |  |                  } | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  |          string getColorD(int color) | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |              string colorName = ""; | 
					
						
							|  |  |  |  |              switch (color) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  case 1: | 
					
						
							|  |  |  |  |                      colorName = "红"; | 
					
						
							|  |  |  |  |                      break; | 
					
						
							|  |  |  |  |                  case 2: | 
					
						
							|  |  |  |  |                      colorName = "绿"; | 
					
						
							|  |  |  |  |                      break; | 
					
						
							|  |  |  |  |                  case 3: | 
					
						
							|  |  |  |  |                      colorName = "蓝"; | 
					
						
							|  |  |  |  |                      break; | 
					
						
							|  |  |  |  |                  case 4: | 
					
						
							|  |  |  |  |                      colorName = "红闪"; | 
					
						
							|  |  |  |  |                      break; | 
					
						
							|  |  |  |  |                  case 5: | 
					
						
							|  |  |  |  |                      colorName = "绿闪"; | 
					
						
							|  |  |  |  |                      break; | 
					
						
							|  |  |  |  |                  case 6: | 
					
						
							|  |  |  |  |                      colorName = "蓝闪"; | 
					
						
							|  |  |  |  |                      break; | 
					
						
							|  |  |  |  |                  case 7: | 
					
						
							|  |  |  |  |                      colorName = "红绿"; | 
					
						
							|  |  |  |  |                      break; | 
					
						
							|  |  |  |  |                  case 8: | 
					
						
							|  |  |  |  |                      colorName = "红蓝"; | 
					
						
							|  |  |  |  |                      break; | 
					
						
							|  |  |  |  |                  case 9: | 
					
						
							|  |  |  |  |                      colorName = "绿蓝"; | 
					
						
							|  |  |  |  |                      break; | 
					
						
							|  |  |  |  |                  case 10: | 
					
						
							|  |  |  |  |                      colorName = "红绿蓝"; | 
					
						
							|  |  |  |  |                      break; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                  default: | 
					
						
							|  |  |  |  |                      colorName = "红"; | 
					
						
							|  |  |  |  |                      break; | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              return colorName; | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          void initComs() | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |              String[] Portname = System.IO.Ports.SerialPort.GetPortNames(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              combComs.Properties.TextEditStyle = TextEditStyles.DisableTextEditor; | 
					
						
							|  |  |  |  |              combComs.Properties.Items.Clear(); | 
					
						
							|  |  |  |  |              ComboBoxItemCollection col = combComs.Properties.Items; | 
					
						
							|  |  |  |  |              col.BeginUpdate(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              oCom = System.Configuration.ConfigurationManager.AppSettings["Com"]; | 
					
						
							|  |  |  |  |              int oldIndex = 0; | 
					
						
							|  |  |  |  |              try | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                  for (int i = 0; i < Portname.Length; i++) | 
					
						
							|  |  |  |  |                  { | 
					
						
							|  |  |  |  |                      //col.Add(i); | 
					
						
							|  |  |  |  |                      col.Add(Portname[i]); | 
					
						
							|  |  |  |  |                      if (!string.IsNullOrEmpty(oCom) && oCom == Portname[i]) | 
					
						
							|  |  |  |  |                      { | 
					
						
							|  |  |  |  |                          oldIndex = i; | 
					
						
							|  |  |  |  |                      } | 
					
						
							|  |  |  |  |                  } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              finally | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  col.EndUpdate(); | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              combComs.SelectedIndex = oldIndex; | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |              if (combComs.Properties.Items.Count> 0) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  initialCom(); | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          Dictionary<int, dnwms> coms = new Dictionary<int, dnwms>(); | 
					
						
							|  |  |  |  |          dnwms activePort; | 
					
						
							|  |  |  |  |          int currentPort = 0; | 
					
						
							|  |  |  |  |          void initialCom() | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |                | 
					
						
							|  |  |  |  |              try | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  int port = Convert.ToInt16(combComs.Text.Substring(3));   | 
					
						
							|  |  |  |  |                  resetLights(); | 
					
						
							|  |  |  |  |                  if (coms.Keys.Contains(port)) | 
					
						
							|  |  |  |  |                  { | 
					
						
							|  |  |  |  |                      if (String.IsNullOrEmpty(oCom) || !oCom.Equals(combComs.Text)) | 
					
						
							|  |  |  |  |                      { | 
					
						
							|  |  |  |  |                          WriteConfig("Com", combComs.Text); | 
					
						
							|  |  |  |  |                          oCom = combComs.Text; | 
					
						
							|  |  |  |  |                      } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                      currentPort = port; | 
					
						
							|  |  |  |  |                      this.lbComstatus.Text = string.Format(combComs.Text + " 打开{0}", "成功"); | 
					
						
							|  |  |  |  |                  } | 
					
						
							|  |  |  |  |                  else | 
					
						
							|  |  |  |  |                  { | 
					
						
							|  |  |  |  |                      this.lbComstatus.Text = string.Format(combComs.Text + " 打开{0}", "失败"); | 
					
						
							|  |  |  |  |                  } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              catch(Exception e) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  lbStatus.Text = string.Format(e.Message); | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              btnShowId.Enabled = currentPort > 0; | 
					
						
							| 
									
										
										
										
											2025-01-23 22:53:20 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |              | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |          } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          private void resetLights() | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |              int port = Convert.ToInt16(combComs.Text.Substring(3)); | 
					
						
							|  |  |  |  |              if (unart_manage.com_manage[port] == null) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  return; | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              activePort = unart_manage.com_manage[port].init_port;  | 
					
						
							|  |  |  |  |              //activePort.check_state = true; | 
					
						
							|  |  |  |  |              if (pick.reset_device(port)) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  coms[port] = activePort; | 
					
						
							|  |  |  |  |                 | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              /* | 
					
						
							|  |  |  |  |              dis_id id;  | 
					
						
							|  |  |  |  |              id.order = 0; | 
					
						
							|  |  |  |  |              id.ele_id = 65535; | 
					
						
							|  |  |  |  |              id.state = 1; | 
					
						
							|  |  |  |  |              bool ret = activePort.write_reset_device(id); | 
					
						
							|  |  |  |  |              System.Threading.Thread.Sleep(100); | 
					
						
							|  |  |  |  |              id.order = 1; | 
					
						
							|  |  |  |  |              id.ele_id = 0; | 
					
						
							|  |  |  |  |              id.state = 1; | 
					
						
							|  |  |  |  |              ret = activePort.write_reset_device(id); | 
					
						
							|  |  |  |  |              lbLightsInfo.Text = string.Format(combComs.Text + "打开{0}", ret ? "成功" : "失败"); | 
					
						
							|  |  |  |  |               * */ | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          private void btnInitialCom_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |              initialCom(); | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          private void txtDeskId_KeyDown(object sender, KeyEventArgs e) | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |              if (e.KeyCode != Keys.Enter) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  return; | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              string id = txtDeskId.Text.Trim(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              if (string.IsNullOrEmpty(id)) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  txtDeskId.SelectAll(); | 
					
						
							|  |  |  |  |                  txtDeskId.Focus(); | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              try | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  deskId = Convert.ToInt16(id); | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              catch (Exception er) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  txtDeskId.SelectAll(); | 
					
						
							|  |  |  |  |                  txtDeskId.Focus(); | 
					
						
							|  |  |  |  |                  return ; | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              txtOperater.SelectAll(); | 
					
						
							|  |  |  |  |              txtOperater.Focus(); | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          private void txtOperater_KeyDown(object sender, KeyEventArgs e) | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |              if (e.KeyCode != Keys.Enter) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  return; | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              string id = txtOperater.Text; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              if (string.IsNullOrEmpty(id)) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  txtOperater.SelectAll(); | 
					
						
							|  |  |  |  |                  txtOperater.Focus(); | 
					
						
							|  |  |  |  |                  return; | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              try | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  operater = Convert.ToInt32(id); | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              catch (Exception er) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  txtOperater.SelectAll(); | 
					
						
							|  |  |  |  |                  txtOperater.Focus(); | 
					
						
							|  |  |  |  |                  return; | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |              txtSeedNo.SelectAll(); | 
					
						
							|  |  |  |  |              txtSeedNo.Focus(); | 
					
						
							|  |  |  |  |               | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          private void txtSeedNo_KeyDown(object sender, KeyEventArgs e) | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |              if (e.KeyCode != Keys.Enter) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  return; | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              txtBarcode.SelectAll(); | 
					
						
							|  |  |  |  |              txtBarcode.Focus(); | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |          bool showId = true; | 
					
						
							|  |  |  |  |          private void simpleButton1_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |              if (currentPort == 0) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  return; | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              if (showId) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  pick.displayLabels(currentPort); | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              else | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  pick.clearLabels(currentPort); | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              showId = !showId; | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       | 
					
						
							|  |  |  |  |       | 
					
						
							|  |  |  |  |          private void chkValid_CheckedChanged(object sender, EventArgs e) | 
					
						
							|  |  |  |  |          { | 
					
						
							|  |  |  |  |             if (chkValid.Checked) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  txtBarcode.BackColor = Color.Red; | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |              else | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  txtBarcode.BackColor = Color.White; | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |             txtBarcode.SelectAll(); | 
					
						
							|  |  |  |  |             txtBarcode.Focus(); | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 operater = Convert.ToInt32(this.txtOperater.Text.Trim()); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showErrorMsg("请扫描输入正确的操作员ID"); | 
					
						
							|  |  |  |  |                 txtOperater.SelectAll(); | 
					
						
							|  |  |  |  |                 txtOperater.Focus(); | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             elelab.pick.clearOrder(currentPort, getColor(operater)); | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |          } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-23 22:53:20 +08:00
										 |  |  |  |         public struct YMD | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             public byte YearS; | 
					
						
							|  |  |  |  |             public byte MonthS; | 
					
						
							|  |  |  |  |             public byte DateS; | 
					
						
							|  |  |  |  |             public byte YearE; | 
					
						
							|  |  |  |  |             public byte MonthE; | 
					
						
							|  |  |  |  |             public byte DateE; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         YMD Release; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         void writeControl() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string wcFlag = System.Configuration.ConfigurationManager.AppSettings["wctr"]; | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(wcFlag) && Convert.ToInt16(wcFlag)==1   ) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             byte[] tempbuf = new byte[12]; | 
					
						
							|  |  |  |  |             int temp1, temp2; | 
					
						
							|  |  |  |  |             int[] Month = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |             DateTime endDate = DateTime.Now.AddDays(new Random().Next(1,15)); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             Release.YearS = (byte)( DateTime.Now.Year % 2000); | 
					
						
							|  |  |  |  |             Release.MonthS = (byte)DateTime.Now.Month; | 
					
						
							|  |  |  |  |             Release.DateS = (byte)DateTime.Now.Day; | 
					
						
							|  |  |  |  |             Release.YearE = (byte)(endDate.Year % 2000); | 
					
						
							|  |  |  |  |             Release.MonthE = (byte)endDate.Month; | 
					
						
							|  |  |  |  |             Release.DateE = (byte)endDate.Day; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             temp1 = Release.YearS * 365 + Month[Release.MonthS - 1] + Release.DateS; | 
					
						
							|  |  |  |  |             temp2 = Release.YearE * 365 + Month[Release.MonthE - 1] + Release.DateE; | 
					
						
							|  |  |  |  |             if (temp2 > temp1) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 tempbuf[0] = (byte)(temp1 / 256); | 
					
						
							|  |  |  |  |                 tempbuf[1] = (byte)(temp1 % 256); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 tempbuf[2] = (byte)(temp2 / 256); | 
					
						
							|  |  |  |  |                 tempbuf[3] = (byte)(temp2 % 256); | 
					
						
							|  |  |  |  |                 if (activePort.write_lock(tempbuf, 4)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     MessageBox.Show("预缩成功"); | 
					
						
							|  |  |  |  |                     WriteConfig("wctr", "1"); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else MessageBox.Show("预锁失败"); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-23 22:53:20 +08:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | } |