private void buttonCover_Click(object sender, EventArgs e) { StandardFormPreviewExcel formPreview = new StandardFormPreviewExcel("发货单预览"); WMSEntities wmsEntities = new WMSEntities(); foreach (int id in this.putOutStorageTicketIDs) { PutOutStorageTicketView putOutStorageTicketView = null; ShipmentTicketView shipmentTicketView = null; PutOutStorageTicketItemView[] putOutStorageTicketItemViews = null; try { putOutStorageTicketView = (from p in wmsEntities.PutOutStorageTicketView where p.ID == id select p).FirstOrDefault(); putOutStorageTicketItemViews = (from p in wmsEntities.PutOutStorageTicketItemView where p.PutOutStorageTicketID == putOutStorageTicketView.ID select p).ToArray(); if (putOutStorageTicketView == null) { MessageBox.Show("出库单" + putOutStorageTicketView.No + "不存在,可能已被删除,请重新查询!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } shipmentTicketView = wmsEntities.Database.SqlQuery <ShipmentTicketView>(string.Format(@"SELECT * FROM ShipmentTicketView WHERE ID = (SELECT ShipmentTicketID FROM JobTicket WHERE JobTicket.ID = {0})", putOutStorageTicketView.JobTicketID)).FirstOrDefault(); } catch { MessageBox.Show("加载失败,请检查网络连接!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string worksheetName = id.ToString(); if (formPreview.AddPatternTable(@"Excel\patternPutOutStorageTicketNormal.xlsx", worksheetName) == false) { this.Close(); return; } formPreview.AddData("putOutStorageTicket", putOutStorageTicketView, worksheetName); formPreview.AddData("putOutStorageTicketItems", putOutStorageTicketItemViews, worksheetName); formPreview.AddData("shipmentTicket", shipmentTicketView, worksheetName); formPreview.SetPrintScale(0.9F, worksheetName); } formPreview.Show(); this.Close(); }
private void buttonMoBiSi_Click(object sender, EventArgs e) { StandardFormPreviewExcel formPreview = new StandardFormPreviewExcel("出库单预览"); WMSEntities wmsEntities = new WMSEntities(); if (putOutStorageTicketIDs.Length > 1) { MessageBox.Show("摩比斯格式暂不支持批量打印", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); return; } int id = putOutStorageTicketIDs[0]; PutOutStorageTicketView putOutStorageTicketView = (from p in wmsEntities.PutOutStorageTicketView where p.ID == id select p).FirstOrDefault(); PutOutStorageTicketItemView[] putOutStorageTicketItemViews = (from p in wmsEntities.PutOutStorageTicketItemView where p.PutOutStorageTicketID == putOutStorageTicketView.ID select p).ToArray(); if (putOutStorageTicketView == null) { MessageBox.Show("出库单不存在,请重新查询!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ShipmentTicketView shipmentTicketView = wmsEntities.Database.SqlQuery <ShipmentTicketView>(string.Format(@"SELECT * FROM ShipmentTicketView WHERE ID = (SELECT ShipmentTicketID FROM JobTicket WHERE JobTicket.ID = {0})", putOutStorageTicketView.JobTicketID)).FirstOrDefault(); int[] supplierIDs = (from item in putOutStorageTicketItemViews where item.SupplierID != null select item.SupplierID.Value).ToArray(); Supplier[] suppliers = (from s in wmsEntities.Supplier where supplierIDs.Contains(s.ID) select s).ToArray(); foreach (Supplier supplier in suppliers) { formPreview.AddPatternTable(@"Excel\patternPutOutStorageTicketMoBiSi.xlsx", supplier.Name); formPreview.AddData("ticket", putOutStorageTicketView, supplier.Name); formPreview.AddData("items", (from item in putOutStorageTicketItemViews where item.SupplierID == supplier.ID select item).ToArray(), supplier.Name); formPreview.AddData("shipmentTicket", shipmentTicketView, supplier.Name); formPreview.AddData("supplier", supplier, supplier.Name); } //没有供应商信息的单独显示一个tab(非正常情况) PutOutStorageTicketItemView[] noSupplierItems = (from item in putOutStorageTicketItemViews where item.SupplierID == null select item).ToArray(); if (noSupplierItems.Length > 0) { formPreview.AddPatternTable(@"Excel\patternPutOutStorageTicketMoBiSi.xlsx", "无供应商"); formPreview.AddData("ticket", putOutStorageTicketView, "无供应商"); formPreview.AddData("items", noSupplierItems, "无供应商"); formPreview.AddData("shipmentTicket", shipmentTicketView, "无供应商"); formPreview.AddData("supplier", default(Supplier), "无供应商"); } formPreview.Show(); this.Close(); }
private void FormShipmentTicketModify_Load(object sender, EventArgs e) { if (this.mode == FormMode.ALTER && this.shipmentTicketID == -1) { throw new Exception("未设置源发货单信息"); } Utilities.CreateEditPanel(this.tableLayoutPanelTextBoxes, ShipmentTicketViewMetaData.KeyNames); //this.textBoxSupplierName = (TextBox)this.Controls.Find("textBoxSupplierName", true)[0]; //textBoxSupplierName.BackColor = Color.White; //textBoxSupplierName.Click += textBoxSupplierName_Click; this.textBoxCreateUserUsername = (TextBox)this.Controls.Find("textBoxCreateUserUsername", true)[0]; this.textBoxCreateTime = (TextBox)this.Controls.Find("textBoxCreateTime", true)[0]; this.textBoxPersonName = (TextBox)this.Controls.Find("textBoxPersonName", true)[0]; textBoxPersonName.ReadOnly = true; textBoxPersonName.BackColor = Color.White; textBoxPersonName.Click += textBoxPersonName_Click; WMSEntities wmsEntities = new WMSEntities(); if (this.mode == FormMode.ALTER) { this.Text = "修改发货单信息"; ShipmentTicketView shipmentTicketView = null; try { shipmentTicketView = (from s in wmsEntities.ShipmentTicketView where s.ID == this.shipmentTicketID select s).FirstOrDefault(); } catch { MessageBox.Show("加载数据失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); if (this.IsDisposed == false) { this.Invoke(new Action(this.Close)); } return; } if (shipmentTicketView == null) { MessageBox.Show("修改失败,发货单不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } Utilities.CopyPropertiesToTextBoxes(shipmentTicketView, this); Utilities.CopyPropertiesToComboBoxes(shipmentTicketView, this); //if (shipmentTicketView.SupplierID.HasValue) //{ // this.curSupplierID = shipmentTicketView.SupplierID.Value; //} } else if (this.mode == FormMode.ADD) { this.Text = "添加发货单"; try { User user = (from u in wmsEntities.User where u.ID == this.userID select u).FirstOrDefault(); if (user == null) { MessageBox.Show("登录用户不存在,请重新登录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.textBoxCreateUserUsername.Text = user.Username; this.textBoxCreateTime.Text = DateTime.Now.ToString(); } catch { MessageBox.Show("加载失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }