private void btnPrint_Click(object sender, EventArgs e) { string templatePath = TEMPLATE_DIRECTORY; // None decoration frame if (cmbTemplate.SelectedIndex == 0) { templatePath += TEMPLATE_SIMPLE; } // Decoration frame else { templatePath += TEMPLATE_FRAME; } bpac.DocumentClass doc = new DocumentClass(); if (doc.Open(templatePath) != false) { doc.GetObject("objCompany").Text = txtCompany.Text; doc.GetObject("objName").Text = txtName.Text; // doc.SetMediaById(doc.Printer.GetMediaId(), true); doc.StartPrint("", PrintOptionConstants.bpoDefault); doc.PrintOut(1, PrintOptionConstants.bpoDefault); doc.EndPrint(); doc.Close(); } else { MessageBox.Show("Open() Error: " + doc.ErrorCode); } }
public void Print(BarcodeVolksschiessen barcodeInfo) { DocumentClass doc = new DocumentClass(); const string path = @".\Templates\Volksschiessen_2015.lbx"; string fullPath = Path.GetFullPath(path); if (doc.Open(fullPath)) { IObject barcode = doc.GetObject("barcode"); barcode.Text = Convert.ToString(barcodeInfo.Barcode); IObject shooterName = doc.GetObject("shooterName"); shooterName.Text = Convert.ToString(barcodeInfo.FirstName + " " + barcodeInfo.LastName); IObject dateOfBirth = doc.GetObject("dateOfBirth"); dateOfBirth.Text = Convert.ToString(barcodeInfo.DateOfBirth != null ? ((DateTime)barcodeInfo.DateOfBirth).ToString("dd.MM.yyyy") : string.Empty); IObject groupName = doc.GetObject("GroupName"); groupName.Text = Convert.ToString(barcodeInfo.Gruppenstich ?? string.Empty); IObject isGroup = doc.GetObject("isGruppen"); isGroup.Text = Convert.ToString(barcodeInfo.Gruppenstich == null ? string.Empty : "x"); doc.StartPrint("", PrintOptionConstants.bpoDefault); doc.PrintOut(1, PrintOptionConstants.bpoDefault); doc.EndPrint(); doc.Close(); } else { throw new InvalidOperationException(string.Format("Can not open template file '{0}'", fullPath)); } }
public static void print(PrintModel print) { try { string directory = Directory.GetCurrentDirectory(); string pfad = directory + @"\ivy_label.LBX"; bpac.DocumentClass doc = new DocumentClass(); doc.Open(pfad); doc.GetObject("ArticleID").Text = print.ArticleID.ToString(); doc.GetObject("ArticleBCode").Text = print.ArticleID.ToString(); doc.GetObject("Manufacturer").Text = print.Manufacturer.ToString(); doc.GetObject("ManufacturerPartNumber").Text = print.ManufacturerPartNumber.ToString(); doc.GetObject("ArticleQR").Text = print.ArticleID.ToString(); doc.GetObject("Description").Text = print.Description.ToString(); doc.SetPrinter("Brother QL-500", true); doc.StartPrint("", PrintOptionConstants.bpoDefault); doc.PrintOut(1, PrintOptionConstants.bpoDefault); doc.EndPrint(); doc.Close(); }catch (Exception e) { MessageBox.Show(e.ToString()); } }
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 void EndPrint() { if (!_doc.EndPrint()) { throw new BpacException("Unable to end printing"); } }
public void Print(Bitmap QRCode) { var _toprint = PrinterErrorCheck(QRLocation); if (_toprint == ToPrint.Yes) { DocumentClass document = new DocumentClass(); document.Printed += new IPrintEvents_PrintedEventHandler(HandlePrinted); document.Open(QRLocation); #region Document Object Text using (MemoryStream ms = new MemoryStream()) { QRCode.Save(ms, ImageFormat.Bmp); document.GetObject("QRImage").SetData(0, ms, 4); } #endregion document.StartPrint((QRCode.GetHashCode().ToString() + " Print Job"), PrintOptionConstants.bpoDefault); document.PrintOut(1, PrintOptionConstants.bpoDefault); int ErrorCode = document.ErrorCode; Console.WriteLine("Error Code > " + ErrorCode); document.EndPrint(); document.Close(); } else if (_toprint == ToPrint.Retry) { restartPrint(QRCode); } }
public void Print(BitmapImage QRCode) { try { var _toprint = PrinterErrorCheck(QRLocation); if (_toprint == ToPrint.Yes) { DocumentClass document = new DocumentClass(); document.Printed += new IPrintEvents_PrintedEventHandler(HandlePrinted); document.Open(QRLocation); #region Document Setting using (MemoryStream ms = new MemoryStream()) { BitmapEncoder enc = new BmpBitmapEncoder(); enc.Frames.Add(BitmapFrame.Create(QRCode)); enc.Save(ms); Bitmap bitmap = new Bitmap(ms); App.LocalFilesManagement.Save(bitmap, null, SaveConfig.QRCode, true); IObjects data = document.Objects; foreach (IObject obj in data) { Console.WriteLine(obj.Name); } Console.WriteLine(data); document.GetObject("QRImage").SetData(0, App.LocalFilesManagement.TempBmpFile, 4); App.LocalFilesManagement.ClearTmp(true); } #endregion document.StartPrint((QRCode.GetHashCode().ToString() + " Print Job"), PrintOptionConstants.bpoDefault); document.PrintOut(1, PrintOptionConstants.bpoDefault); int ErrorCode = document.ErrorCode; Console.WriteLine("Error Code > " + ErrorCode); document.EndPrint(); document.Close(); } else if (_toprint == ToPrint.Retry) { restartPrint(QRCode); } } catch (Exception e) { Console.WriteLine(e); } }
private void SendToPrint() { try { var docClass = new DocumentClass(); //if (!docClass.Printer.IsPrinterOnline("Engenharia_Etiquetas")) //{ // MessageBox.Show("A impressora não está Online, verifique se ela está ligada!", "Impressora OFF-LINE"); // return; //} if (docClass.Open(TagInstance.GetFileService().TemplatePath())) { foreach (var productTag in TagInstance.GetProductServiceTag().GetTags()) { if (productTag.Print != true) { continue; } docClass.GetObject(TagTemplateFieldNames.TagPosicao).Text = productTag.Position ?? string.Empty; docClass.GetObject(TagTemplateFieldNames.TagItem).Text = productTag.Item ?? string.Empty; docClass.GetObject(TagTemplateFieldNames.TagDescription).Text = productTag.Description ?? string.Empty; docClass.GetObject(TagTemplateFieldNames.TagOf).Text = productTag.Of ?? string.Empty; docClass.GetObject(TagTemplateFieldNames.TagOrcamento).Text = productTag.OrderNumber ?? string.Empty; docClass.GetObject(TagTemplateFieldNames.TagNumDesenho).Text = productTag.DrawingCodeName ?? string.Empty; docClass.GetObject(TagTemplateFieldNames.TagData).Text = DateTime.Now.ToString("MM/dd/yyyy") ?? string.Empty; docClass.StartPrint(string.Empty, PrintOptionConstants.bpoDefault); docClass.PrintOut(productTag.Quantity, PrintOptionConstants.bpoHalfCut); productTag.Printed = docClass.EndPrint(); } docClass.Close(); } else { MessageBox.Show($"Erro ao Abrir.\n{docClass.ErrorCode}"); } } catch (Exception e) { throw new Exception("Erro ao imprimir.", e); } }
public void Print(BarcodeHerbstschiessen barcodeInfo) { DocumentClass doc = new DocumentClass(); const string path = @".\Templates\Herbstschiessen.lbx"; string fullPath = Path.GetFullPath(path); if (doc.Open(fullPath)) { IObject barcode = doc.GetObject("barcode"); barcode.Text = Convert.ToString(barcodeInfo.Barcode); IObject shooterName = doc.GetObject("shooterName"); shooterName.Text = Convert.ToString(barcodeInfo.FirstName + " " + barcodeInfo.LastName); IObject dateOfBirth = doc.GetObject("dateOfBirth"); dateOfBirth.Text = Convert.ToString(barcodeInfo.DateOfBirth != null ? ((DateTime)barcodeInfo.DateOfBirth).ToString("dd.MM.yyyy") : string.Empty); IObject groupName = doc.GetObject("GroupName"); groupName.Text = Convert.ToString(barcodeInfo.Gruppenstich); IObject sieUndErName = doc.GetObject("SieUndErName"); sieUndErName.Text = Convert.ToString(barcodeInfo.SieUndEr); IObject isGruppenstich = doc.GetObject("pass_103"); isGruppenstich.Text = Convert.ToString(barcodeInfo.IsGruppenstich ? "x" : string.Empty); IObject isNachwuchsstich = doc.GetObject("pass_104"); isNachwuchsstich.Text = Convert.ToString(barcodeInfo.IsNachwuchsstich ? "x" : string.Empty); IObject isWorschtUndBrot = doc.GetObject("pass_101"); isWorschtUndBrot.Text = Convert.ToString(barcodeInfo.IsWorschtUndBrot ? "x" : string.Empty); IObject isSieUndEr = doc.GetObject("pass_102"); isSieUndEr.Text = Convert.ToString(barcodeInfo.IsSieUndEr ? "x" : string.Empty); doc.StartPrint("", PrintOptionConstants.bpoDefault); doc.PrintOut(1, PrintOptionConstants.bpoDefault); doc.EndPrint(); doc.Close(); } else { throw new InvalidOperationException(string.Format("Can not open template file '{0}'", fullPath)); } }
private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { try { LobbyManagerWS.ImageCollectorClient imgCollectorClient = new ImageCollectorClient(); String desk = File.ReadAllText(Path.Combine(Application.StartupPath, "desk.txt")); String labelService = imgCollectorClient.label(desk); if (labelService != null) { File.AppendAllText(Path.Combine(path, @"log\errors.txt"), Environment.NewLine + labelService); String[] labelRaw = labelService.Split('|'); string templatePath = TEMPLATE_DIRECTORY; templatePath += TEMPLATE_SIMPLE; bpac.DocumentClass doc = new DocumentClass(); if (doc.Open(templatePath) != false) { String name = labelRaw[0]; doc.GetObject("objName").Text = name; doc.GetObject("objSerial").Text = labelRaw[1]; doc.GetObject("objBarcode").Text = labelRaw[2]; doc.GetObject("objDesc").Text = labelRaw[3]; doc.GetObject("objOwner").Text = labelRaw[4]; // doc.SetMediaById(doc.Printer.GetMediaId(), true); doc.StartPrint("", PrintOptionConstants.bpoDefault); doc.PrintOut(1, PrintOptionConstants.bpoDefault); doc.EndPrint(); } else { File.AppendAllText(Path.Combine(path, @"log\errors.txt"), Environment.NewLine + "ERROR: DocOpen"); } } else { //File.AppendAllText(Path.Combine(path, @"log\errors.txt"), Environment.NewLine + "ERROR: NULL"); } } catch (Exception ex) { //Do exception File.AppendAllText(Path.Combine(path, @"log\errors.txt"), Environment.NewLine + "ERROR: " + ex.ToString()); } }
/// <summary> /// Controla el evento del botón para la impresión de viñetas en el impresor Brother QL 700 /// </summary> /// <param name="sender">Objeto que llama a la acción</param> /// <param name="e">Evento Ejecutado</param> protected void btnExecutePrint_Click(object sender, EventArgs e) { string templatePath = TEMPLATE_DIRECTORY; templatePath += TEMPLATE_SIMPLE; bpac.DocumentClass doc = new DocumentClass(); if (doc.Open(templatePath) != false) { string connStr = ConfigurationManager.ConnectionStrings[mainConnectionString].ConnectionString; using (var conn = new SqlConnection(connStr)) using (var cmd = conn.CreateCommand()) { conn.Open(); cmd.CommandText = "SELECT reg_id, reg_type, type_name, reg_quantity, reg_serial, reg_desc FROM tbl_reg_equipment, tbl_type_equipment where type_id = reg_type and reg_visitor = @reg_visitor"; cmd.Parameters.AddWithValue("reg_visitor", visitorID); SqlDataReader dreader = cmd.ExecuteReader(); while (dreader.Read()) { String name = dreader["type_name"].ToString().Trim(); doc.GetObject("objName").Text = name; doc.GetObject("objSerial").Text = dreader["reg_serial"].ToString().Trim(); doc.GetObject("objBarcode").Text = dreader["reg_id"].ToString().Trim(); doc.GetObject("objDesc").Text = dreader["reg_desc"].ToString().Trim(); doc.GetObject("objOwner").Text = lblTitle.Text.Trim(); // doc.SetMediaById(doc.Printer.GetMediaId(), true); doc.StartPrint("", PrintOptionConstants.bpoDefault); doc.PrintOut(1, PrintOptionConstants.bpoDefault); doc.EndPrint(); } doc.Close(); dreader.Close(); conn.Close(); } } else { //MessageBox.Show("Open() Error: " + doc.ErrorCode); } }
public void Print(TLabel tLabel) { var _toprint = PrinterErrorCheck(LabelLocation); if (_toprint == ToPrint.Yes) { DocumentClass document = new DocumentClass(); document.Printed += new IPrintEvents_PrintedEventHandler(HandlePrinted); document.Open(LabelLocation); var barcodeIndex = document.GetBarcodeIndex("Barcode"); #region Document Object Text document.GetObject("Name").Text = tLabel.Name; document.GetObject("Address").Text = tLabel.Address; document.SetBarcodeData(barcodeIndex, tLabel.Barcode); document.GetObject("DeliveryDate").Text = tLabel.DeliveryDate; document.GetObject("ConsignmentNumber").Text = tLabel.ConsignmentNumber; document.GetObject("PostCode").Text = tLabel.PostCode; document.GetObject("Telephone").Text = tLabel.Telephone; document.GetObject("Location").Text = tLabel.Location; document.GetObject("Weight").Text = tLabel.Weight; document.GetObject("LocationNumber").Text = tLabel.LocationNumber; document.GetObject("ParcelNumber").Text = tLabel.ParcelNumber; #endregion document.StartPrint((tLabel.Name + " Print Job"), PrintOptionConstants.bpoDefault); document.PrintOut(1, PrintOptionConstants.bpoDefault); int ErrorCode = document.ErrorCode; Console.WriteLine("Error Code > " + ErrorCode); document.EndPrint(); document.Close(); } else if (_toprint == ToPrint.Retry) { restartPrint(tLabel); } }
public void Print(string labelName, Dictionary <String, String> substitutions) { var doc = new DocumentClass(); if (doc.Open("labels/" + labelName + ".lbx")) { foreach (var s in substitutions) { doc.GetObject(s.Key).Text = s.Value; } doc.SetPrinter(printerName, false); doc.SetMediaById(doc.Printer.GetMediaId(), true); doc.StartPrint("", PrintOptionConstants.bpoDefault); doc.PrintOut(1, PrintOptionConstants.bpoDefault); doc.EndPrint(); doc.Close(); Console.WriteLine("Label printed"); } else { Console.WriteLine("Can't open label file!"); } }
public void Print(IRegisterDetail item) { string template = string.Concat(AppDomain.CurrentDomain.BaseDirectory, @"drivers\Simple.lbx"); string barcode = Coder.Calculate(Convert.ToUInt32(item.Id)); string name = item.DetailType.Id > 0 ? item.DetailType.Name : item.Name; bpac.DocumentClass doc = new DocumentClass(); if (doc.Open(template)) { doc.GetObject("Code").Text = barcode; doc.GetObject("InvNum").Text = item.Register.InvNumber; doc.GetObject("Name").Text = string.Format("{0}. {1}", item.Npp, name); doc.StartPrint("", PrintOptionConstants.bpoChainPrint | PrintOptionConstants.bpoAutoCut); doc.PrintOut(1, PrintOptionConstants.bpoChainPrint | PrintOptionConstants.bpoAutoCut); doc.EndPrint(); doc.Close(); } else { throw new Exception("Невозможно открыть шаблон"); } }
public void Print(GenericBarcode_20150909 barcodeInfo) { DocumentClass doc = new DocumentClass(); const string path = @".\Templates\Generic_20150909.lbx"; string fullPath = Path.GetFullPath(path); if (doc.Open(fullPath)) { IObject barcode = doc.GetObject("barcode"); barcode.Text = Convert.ToString(barcodeInfo.Barcode); IObject shooterName = doc.GetObject("shooterName"); shooterName.Text = Convert.ToString(barcodeInfo.FirstName + " " + barcodeInfo.LastName); IObject dateOfBirth = doc.GetObject("dateOfBirth"); dateOfBirth.Text = Convert.ToString(barcodeInfo.DateOfBirth != null ? ((DateTime)barcodeInfo.DateOfBirth).ToString("dd.MM.yyyy") : string.Empty); AddCollectionLabel(barcodeInfo, doc, 0); AddCollectionLabel(barcodeInfo, doc, 1); AddStichLabel(barcodeInfo, doc, 1); AddStichLabel(barcodeInfo, doc, 2); AddStichLabel(barcodeInfo, doc, 3); AddStichLabel(barcodeInfo, doc, 4); AddStichLabel(barcodeInfo, doc, 5); doc.StartPrint("", PrintOptionConstants.bpoDefault); doc.PrintOut(1, PrintOptionConstants.bpoDefault); doc.EndPrint(); doc.Close(); } else { throw new InvalidOperationException(string.Format("Can not open template file '{0}'", fullPath)); } }
static void Main(string[] args) { Console.WriteLine(" "); Console.WriteLine(" GBPrintServer 1.1.0"); Console.WriteLine(" (C) RobbytuProjects 2013"); Console.WriteLine(" "); TcpListener listener = new TcpListener(IPAddress.Any, 8000); listener.Start(); Console.WriteLine(" * Listening for incoming connections on port 8000."); while (true) { try { Console.WriteLine(" "); Socket soc = listener.AcceptSocket(); Console.WriteLine(" * Accepted incoming connection: {0}", soc.RemoteEndPoint); Stream s = new NetworkStream(soc); StreamReader sr = new StreamReader(s); StreamWriter sw = new StreamWriter(s); Console.WriteLine(" * Reading job information..."); bool waitForJob = true; while (waitForJob) { String input = sr.ReadLine(); if (input.StartsWith("GET ")) { Console.WriteLine(" * Processing job information..."); String[] jobParts = input.Split("?".ToCharArray())[1].Split(" ".ToCharArray())[0].Split("&".ToCharArray()); IDictionary<string, string> processedParts = new Dictionary<string, string>(); foreach (String part in jobParts) { String decodedPart = HttpUtility.UrlDecode(part); processedParts[decodedPart.Split("=".ToCharArray())[0]] = decodedPart.Split("=".ToCharArray())[1]; } DocumentClass doc = new DocumentClass(); if (doc.Open("\\\\win2k12.ad.local\\Programs\\GBPrintServer\\" + processedParts["label"]) != false) { Console.WriteLine(" * Preparing print job..."); foreach (KeyValuePair<string, string> part in processedParts) { if (part.Key != "label") { Console.WriteLine(" -> Setting object value: {0}={1}", part.Key, part.Value); doc.GetObject(part.Key).Text = part.Value; } } Console.WriteLine(" * Sending job to printer..."); doc.StartPrint("", PrintOptionConstants.bpoNoCut); doc.PrintOut(1, PrintOptionConstants.bpoNoCut); doc.EndPrint(); Console.WriteLine(" * Writing response code NOERR..."); sw.WriteLine("HTTP/1.1 200 OK"); sw.WriteLine("Content-Type: text/html"); sw.WriteLine("Content-Length: 3"); sw.WriteLine(""); sw.Write("noe"); // NO ERROR sw.Flush(); Console.WriteLine(" * Closing connection..."); soc.Close(); } else { Console.WriteLine(" -> E: Could not open label file: are you connected to the Network?"); Console.WriteLine(" -> Writing response code ERR..."); sw.WriteLine("HTTP/1.1 200 OK"); sw.WriteLine("Content-Type: text/html"); sw.WriteLine("Content-Length: 3"); sw.WriteLine(""); sw.Write("err"); sw.Flush(); Console.WriteLine(" * Closing connection..."); soc.Close(); } waitForJob = false; } Console.WriteLine(" "); } } catch (Exception e) { Console.WriteLine(" -> Unexpected exception during Connloop."); Console.WriteLine(" -> E: " + e.Message); } } }
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); }; }