private void toolStripButton5_Click(object sender, EventArgs e) { List <string> ListPorts = System.IO.Ports.SerialPort.GetPortNames().OrderBy(r => r).ToList(); if (ListPorts.Count <= 0) { MessageBox.Show("请检查串口USB连接,或者其驱动是否正常!"); return; } using (FormWareHouseZonePosition_EleLabSetup frm = new FormWareHouseZonePosition_EleLabSetup(this.EleModel)) { var re = frm.ShowDialog(); if (re == System.Windows.Forms.DialogResult.OK) { this.EleModel = frm.EleModel; } } }
public FormWareHouseZonePosition() { InitializeComponent(); #region 右键打印单条货位条码 RightMenu = new Pharmacy.UI.Common.BaseRightMenu(this.dataGridView1); RightMenu.InsertMenuItem("打印该货位的条码", delegate() { var re = MessageBox.Show("需要打印该行货位条码码?", "提示", MessageBoxButtons.OKCancel); if (re == System.Windows.Forms.DialogResult.Cancel) { return; } if (!System.IO.File.Exists("resources\\名称.lbx")) { MessageBox.Show("条码打印模板文件不存在,请增加一个!"); return; } bpac.DocumentClass doc = new DocumentClass(); doc.Open("resources\\名称.lbx"); Business.Models.WareHouseZonePositionModel m = this.dataGridView1.CurrentRow.DataBoundItem as Business.Models.WareHouseZonePositionModel; doc.GetObject("Title").Text = m.WareHouseZoneName + " " + m.Name; doc.SetBarcodeData(0, m.BarCode); doc.StartPrint("", PrintOptionConstants.bpoDefault); doc.PrintOut(1, PrintOptionConstants.bpoDefault); doc.EndPrint(); doc.Close(); }); #endregion this.EleModel = SearialiserHelper <Ele_Lab> .DeSerializeFileToObj("EleSetup.bin"); if (this.EleModel.IsEnabled) { if (elelab.unart_manage.com_manage.FirstOrDefault() == null) { int[] ss = new int[] { int.Parse(this.EleModel.PortName.Substring(3)) }; elelab.unart_manage.init_com_sys(ss); } } this.button2.Visible = this.EleModel.IsEnabled; this.dataGridView1.RowPostPaint += delegate(object o, DataGridViewRowPostPaintEventArgs ex) { DataGridViewOperator.SetRowNumber((DataGridView)o, ex); }; this.dataGridView1.ReadOnly = true; this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; #region 插入仓库数据到combo和事件 this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList; this.comboBox2.DropDownStyle = ComboBoxStyle.DropDownList; var w = this.PharmacyDatabaseService.AllWarehouses(out msg).Where(r => r.Deleted == false).OrderBy(r => r.Name).ToList(); w.Insert(0, new Models.Warehouse { Name = "全部", Id = Guid.Empty, }); this.comboBox1.ValueMember = "Id"; this.comboBox1.DisplayMember = "Name"; this.comboBox1.DataSource = w; this.comboBox1.SelectedIndex = 0; var wz = this.PharmacyDatabaseService.AllWarehouseZones(out msg).Where(r => r.Deleted == false).OrderBy(r => r.Name).ToList(); var wzt = new List <Models.WarehouseZone>(); wzt.Add( new Models.WarehouseZone { Name = "全部", Id = Guid.Empty, }); this.comboBox2.ValueMember = "Id"; this.comboBox2.DisplayMember = "Name"; this.comboBox2.DataSource = wzt; this.comboBox2.SelectedIndex = 0; this.comboBox1.SelectedIndexChanged += (sender, e) => { var wzs = wz.Where(r => r.WarehouseId == (Guid)this.comboBox1.SelectedValue).OrderBy(r => r.Name).ToList(); wzs.Insert(0, new Models.WarehouseZone { Name = "全部", Id = Guid.Empty, }); this.comboBox2.ValueMember = "Id"; this.comboBox2.DisplayMember = "Name"; this.comboBox2.DataSource = wzs; this.comboBox2.SelectedIndex = 0; }; #endregion //批量创建 this.toolStripButton2.Click += (sender, e) => { FormWareHouseZonePosition_Editor frm = new FormWareHouseZonePosition_Editor(w, wz); frm.Show(this); }; #region 修改ACTION Action <object, EventArgs> EditPostionAction = (sender, e) => { if (this.dataGridView1.CurrentRow == null) { return; } var c = this.dataGridView1.CurrentRow.DataBoundItem as Business.Models.WareHouseZonePositionModel; using (FormWareHouseZonePositionEdit frm = new FormWareHouseZonePositionEdit(w, wz, c)) { var re = frm.ShowDialog(); if (re == System.Windows.Forms.DialogResult.OK) { this.toolStripButton1_Click(null, null); } } }; #endregion //修改 this.toolStripButton3.Click += (sender, e) => EditPostionAction(sender, e); //Datagridview双击修该货位 this.dataGridView1.CellDoubleClick += (sender, e) => { if (e.RowIndex < 0 || e.ColumnIndex < 0) { return; } EditPostionAction(null, null); }; }