private void FormPutOutStorageTicketModify_Load(object sender, EventArgs e) { if (this.putOutStorageTicketID == -1) { throw new Exception("未设置源库存信息"); } Utilities.CreateEditPanel(this.tableLayoutPanelTextBoxes, PutOutStorageTicketViewMetaData.KeyNames); this.personIDGetter = Utilities.BindTextBoxSelect <FormSelectPerson, Person>(this, "textBoxPersonName", "Name"); PutOutStorageTicketView putOutStorageTicketView = null; try { putOutStorageTicketView = (from s in this.wmsEntities.PutOutStorageTicketView where s.ID == this.putOutStorageTicketID select s).FirstOrDefault(); } catch { MessageBox.Show("加载数据失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } if (putOutStorageTicketView == null) { MessageBox.Show("出库单不存在,请重新查询", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } Utilities.CopyPropertiesToTextBoxes(putOutStorageTicketView, this); Utilities.CopyPropertiesToComboBoxes(putOutStorageTicketView, this); }
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(); }