private void toolStripButton7_Click(object sender, EventArgs e) { 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"); foreach (DataGridViewRow i in this.dataGridView1.Rows) { Business.Models.WareHouseZonePositionModel m = i.DataBoundItem as Business.Models.WareHouseZonePositionModel; doc.GetObject("Title").Text = m.WareHouseZoneName + " " + m.Name; doc.SetBarcodeData(0, m.BarCode); doc.StartPrint("", PrintOptionConstants.bpoHalfCut); doc.PrintOut(1, PrintOptionConstants.bpoHalfCut | PrintOptionConstants.bpoChainPrint); } doc.EndPrint(); doc.Close(); }
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); }; }
public FormWareHouseZonePositionEdit(List <Models.Warehouse> w, List <Models.WarehouseZone> wz, Business.Models.WareHouseZonePositionModel wzp) : this() { #region 绑定货位 var rc = wzp.RowCol.Split(','); int row = int.Parse(rc[0].Substring(1, rc[0].Length - 2)); int col = int.Parse(rc[1].Substring(1, rc[1].Length - 2)); PositionRowCol prc = new PositionRowCol { Capacity = wzp.Capacity, Row = row, Col = col, NamePrefix = wzp.Name }; this.textBox1.DataBindings.Add("Text", prc, "Row"); this.textBox2.DataBindings.Add("Text", prc, "Col"); this.textBox3.DataBindings.Add("Text", prc, "NamePrefix"); this.textBox4.DataBindings.Add("Text", prc, "Capacity"); #endregion #region 绑定仓库,货架 this.comboBox1.ValueMember = "Id"; this.comboBox1.DisplayMember = "Name"; this.comboBox1.DataSource = w; this.comboBox1.SelectedValue = wzp.WareHouseId; Action <object, EventArgs> Combo1SelectedIndexChanged = (sender, ex) => { this.comboBox2.ValueMember = "Id"; this.comboBox2.DisplayMember = "Name"; var u = wz.Where(r => r.WarehouseId == (Guid)this.comboBox1.SelectedValue).ToList(); this.comboBox2.DataSource = u; if (u.FirstOrDefault(r => r.Id == wzp.Id) == null) { this.comboBox2.SelectedIndex = 0; } else { this.comboBox2.SelectedValue = wzp.WareHouseZoneId; } }; Combo1SelectedIndexChanged(null, null); this.comboBox1.SelectedIndexChanged += (sender, e) => Combo1SelectedIndexChanged(sender, e); #endregion #region 提交修改 this.button1.Click += (sender, e) => { if (string.IsNullOrEmpty(prc.NamePrefix)) { MessageBox.Show("货位名称不能为空"); return; } if (prc.Row <= 0 || prc.Col <= 0) { MessageBox.Show("货位行或列不得小于或等于0"); return; } var re = MessageBox.Show("确定需要更改该货位信息吗?", "提示", MessageBoxButtons.OKCancel); if (re == System.Windows.Forms.DialogResult.Cancel) { return; } var c = this.PharmacyDatabaseService.GetWarehouseZonePositionById(wzp.Id, out msg); if (c == null) { MessageBox.Show("数据库发生错误,请联系管理员!"); return; } c.RowCol = "第" + prc.Row + "层,第" + prc.Col.ToString() + "列"; c.Name = prc.NamePrefix; c.WareHouseZoneId = (Guid)this.comboBox2.SelectedValue; c.Capacity = prc.Capacity; var sub = new List <Models.WarehouseZonePosition>(); sub.Add(c); var b = this.PharmacyDatabaseService.SaveWareHouseZonePosition(sub, out msg); if (b) { MessageBox.Show("提交成功!"); this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBox.Show("提交失败,请联系管理员!"); } }; #endregion #region 关闭窗口 this.button2.Click += (sender, e) => { this.Close(); }; #endregion }