//委外加工單 private void btn_SelectOtherCompact_Click(object sender, EventArgs e) { ProduceOtherCompact.ChooseOutContract f = new Book.UI.produceManager.ProduceOtherCompact.ChooseOutContract(); if (f.ShowDialog(this) == DialogResult.OK) { if (f.key != null) { foreach (var item in f.key) { Model.PCEarplugsStayWireCheckDetail detail = new Book.Model.PCEarplugsStayWireCheckDetail(); detail.PCEarplugsStayWireCheckDetailId = Guid.NewGuid().ToString(); detail.Number = (this._pCEarplugsStayWireCheck.Details.Count + 1).ToString(); detail.FromId = item.ProduceOtherCompactId; detail.Product = item.Product; detail.ProductId = item.ProductId; detail.ProductUnit = item.ProductUnit; if (!string.IsNullOrEmpty(item.ProduceOtherCompactId)) { Model.ProduceOtherCompact model = new BL.ProduceOtherCompactManager().Get(item.ProduceOtherCompactId); if (model != null) { detail.InvoiceXOId = model.InvoiceXOId; } } detail.InvoiceXOQuantity = item.OtherCompactCount.HasValue ? item.OtherCompactCount.Value : 0; Model.InvoiceXO xo = invoiceXOManager.Get(detail.InvoiceXOId); if (xo != null) { detail.InvoiceXO = xo; } this._pCEarplugsStayWireCheck.Details.Add(detail); } this.gridControl1.RefreshDataSource(); } f.Dispose(); GC.Collect(); } }
private void simpleButton1_Click(object sender, EventArgs e) { Type objClassType = null; objClassType = Type.GetTypeFromProgID("Excel.Application"); if (objClassType == null) { MessageBox.Show("本機沒有安裝Excel", "提示!", MessageBoxButtons.OK); return; } DateTime startTime = global::Helper.DateTimeParse.NullDate; DateTime endTime = global::Helper.DateTimeParse.EndDate; if (this.dateEditStartDate.EditValue != null) { startTime = this.dateEditStartDate.DateTime; } if (this.dateEditEndDate.EditValue != null) { endTime = this.dateEditEndDate.DateTime; } System.Data.DataTable dt = new BL.ProduceOtherCompactManager().GetExcelData(startTime, endTime); if (dt == null || dt.Rows.Count == 0) { MessageBox.Show("無數據!", "提示!", MessageBoxButtons.OK); return; } try { Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application(); excel.Application.Workbooks.Add(true); excel.Cells.ColumnWidth = 12; excel.Rows.RowHeight = 20; #region 表頭 excel.get_Range(excel.Cells[1, 1], excel.Cells[1 + dt.Rows.Count, 9]).Borders.LineStyle = XlLineStyle.xlContinuous; excel.get_Range(excel.Cells[1, 1], excel.Cells[1 + dt.Rows.Count, 9]).HorizontalAlignment = XlHAlign.xlHAlignLeft; excel.get_Range(excel.Cells[1, 1], excel.Cells[1, 1]).RowHeight = 25; excel.get_Range(excel.Cells[1, 1], excel.Cells[1, 1]).ColumnWidth = 18; excel.get_Range(excel.Cells[1, 4], excel.Cells[1, 4]).ColumnWidth = 18; excel.get_Range(excel.Cells[1, 1], excel.Cells[1, 10]).Font.Size = 12; excel.get_Range(excel.Cells[1, 5], excel.Cells[1, 6]).ColumnWidth = 40; excel.Cells[1, 1] = "編號"; excel.Cells[1, 2] = "交期"; excel.Cells[1, 3] = "訂單預交日期"; excel.Cells[1, 4] = "客戶訂單號"; excel.Cells[1, 5] = "廠商"; excel.Cells[1, 6] = "貨品名稱"; excel.Cells[1, 7] = "數量"; excel.Cells[1, 8] = "進貨數量"; excel.Cells[1, 9] = "單位"; #endregion for (int i = 0; i < dt.Rows.Count; i++) { excel.Cells[i + 2, 1] = dt.Rows[i]["ProduceOtherCompactId"] == null ? "" : dt.Rows[i]["ProduceOtherCompactId"].ToString(); excel.Cells[i + 2, 2] = dt.Rows[i]["LastDate"] == null ? "" : dt.Rows[i]["LastDate"].ToString(); excel.Cells[i + 2, 3] = dt.Rows[i]["InvoiceYjrq"] == null ? "" : dt.Rows[i]["InvoiceYjrq"].ToString(); excel.Cells[i + 2, 4] = dt.Rows[i]["CustomerInvoiceXOId"] == null ? "" : dt.Rows[i]["CustomerInvoiceXOId"].ToString(); excel.Cells[i + 2, 5] = dt.Rows[i]["SupplierFullName"] == null ? "" : dt.Rows[i]["SupplierFullName"].ToString(); excel.Cells[i + 2, 6] = dt.Rows[i]["ProductName"] == null ? "" : dt.Rows[i]["ProductName"].ToString(); excel.Cells[i + 2, 7] = dt.Rows[i]["OtherCompactCount"] == null ? "" : dt.Rows[i]["OtherCompactCount"].ToString(); excel.Cells[i + 2, 8] = dt.Rows[i]["ArrivalInQuantity"] == null ? "" : dt.Rows[i]["ArrivalInQuantity"].ToString(); excel.Cells[i + 2, 9] = dt.Rows[i]["ProductUnit"] == null ? "" : dt.Rows[i]["ProductUnit"].ToString(); } excel.Visible = true; } catch { MessageBox.Show("Excel未生成完畢,請勿操作,并重新點擊按鈕生成數據!", "提示!", MessageBoxButtons.OK); return; } }
public RO(string produceOtherMaterialId) { InitializeComponent(); this.produceOtherMaterial = this.produceOtherMaterialManager.GetDetails(produceOtherMaterialId); if (this.produceOtherMaterial == null) { return; } // this.produceOtherMaterial.Details = this.ProduceOtherMaterialDetailManager.GetOrderById(this.produceOtherMaterial); this.DataSource = this.produceOtherMaterial.Details; //CompanyInfo this.xrLabelCompanyInfoName.Text = BL.Settings.CompanyChineseName; this.xrLabelDataName.Text = Properties.Resources.ProduceOtherMaterialDetail; this.xrLabelDepot.Text = this.produceOtherMaterial.Depot == null ? "" : this.produceOtherMaterial.Depot.ToString(); this.xrLabelDate.Text += DateTime.Now.ToShortDateString(); xrLabelSup.Text = this.produceOtherMaterial.Supplier == null ? null : this.produceOtherMaterial.Supplier.SupplierShortName; //外包領料 this.xrLabelProduceOtherMaterialId.Text = this.produceOtherMaterial.ProduceOtherMaterialId; this.xrLabelProduceOtherMaterialDate.Text = this.produceOtherMaterial.ProduceOtherMaterialDate.Value.ToString("yyyy-MM-dd"); if (this.produceOtherMaterial.Employee0 != null) { this.xrLabelEmployee0.Text = this.produceOtherMaterial.Employee0.EmployeeName; } if (this.produceOtherMaterial.Employee1 != null) { this.xrLabelEmployee1.Text = this.produceOtherMaterial.Employee1.EmployeeName; } if (this.produceOtherMaterial.WorkHouse != null) { this.xrLabelDepartment.Text = this.produceOtherMaterial.WorkHouse.Workhousename; } this.xrLabelOtherCam.Text = this.produceOtherMaterial.ProduceOtherCompactId; this.xrLabelProduceOtherMaterialDesc.Text = this.produceOtherMaterial.ProduceOtherMaterialDesc; if (!string.IsNullOrEmpty(produceOtherMaterial.ProduceOtherCompactId)) { Model.ProduceOtherCompact OtherCompact = new BL.ProduceOtherCompactManager().Get(produceOtherMaterial.ProduceOtherCompactId); if (OtherCompact != null) { //Model.MRSHeader mrsHeader = this.mRSHeaderManager.Get(OtherCompact.MRSHeaderId); //if (mrsHeader != null) //{ // Model.MPSheader mPSheader = this.mPSheaderManager.Get(mrsHeader.MPSheaderId); // if (mPSheader != null) // { // Model.InvoiceXO invoiceXO = this.invoiceXOManager.Get(mPSheader.InvoiceXOId); // this.xrLabelCustomerXOId.Text = invoiceXO == null ? string.Empty : invoiceXO.CustomerInvoiceXOId; // } //} Model.InvoiceXO invoiceXO = OtherCompact.InvoiceXO; if (invoiceXO != null) { this.xrLabelCustomerXOId.Text = invoiceXO.CustomerInvoiceXOId; if (invoiceXO.xocustomer != null && !string.IsNullOrEmpty(invoiceXO.xocustomer.CheckedStandard)) { if (invoiceXO.xocustomer.CheckedStandard.ToLower().Contains("jis") && invoiceXO.xocustomer.CustomerFullName.ToUpper().Contains("MIDORI")) { //CreateTagLable("JIS"); this.lbl_JIS.Text = "JIS"; } else if (invoiceXO.xocustomer.CheckedStandard.ToLower().Contains("as")) { //CreateTagLable("AS"); this.lbl_JIS.Text = "AS"; } } } } } //this.xrLabelCustomerXOId.Text = this.produceOtherMaterial.InvoiceCusId; //明细 //this.xrTableCell1ProductId.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_Id); this.xrTableCellProductName.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_ProductName); //if (produceOtherMaterial.WorkHouse!=null) //{ // if(produceOtherMaterial.WorkHouse.Workhousename != null) // this.xrTableCellDepartment.DataBindings.Add("Text", this.DataSource, "ProduceOtherMaterialWorkHouse.Workhousename"); //} // this.xrTableCellProduceOtherMaterialDate.DataBindings.Add("Text", this.DataSource, "ProduceOtherMaterial." + Model.ProduceOtherMaterial.PRO_ProduceOtherMaterialDate, "{0:yyyy-MM-dd}"); this.xrTableCellOtherMaterialQuantity.DataBindings.Add("Text", this.DataSource, Model.ProduceOtherMaterialDetail.PRO_OtherMaterialQuantity); this.xrTableCellDesc.DataBindings.Add("Text", this.DataSource, Model.ProduceOtherMaterialDetail.PRO_Description); this.xrTableCell4.DataBindings.Add("Text", this.DataSource, Model.ProduceOtherMaterialDetail.PRO_ProductUnit); //this.xrRichText1.DataBindings.Add("Rtf", this.DataSource, "Product." + Model.Product.PRO_ProductDescription); this.xrTableCellParent.DataBindings.Add("Text", this.DataSource, "ParentProduct." + Model.Product.PRO_ProductName); this.xrTableInumber.DataBindings.Add("Text", this.DataSource, Model.ProduceOtherMaterialDetail.PRO_Inumber); this.xrTableStock.DataBindings.Add("Text", this.DataSource, Model.ProduceOtherMaterialDetail.PRO_ProductStock); this.xrTableCellNum.DataBindings.Add("Text", this.DataSource, Model.ProduceOtherMaterialDetail.PRO_PiHao); this.TCKouliaoDate.DataBindings.Add("Text", this.DataSource, Model.ProduceOtherMaterialDetail.PRO_KouliaoDate, "{0:yyyy-MM-dd}"); this.TCInvoiceUseQuantity.DataBindings.Add("Text", this.DataSource, Model.ProduceOtherMaterialDetail.PRO_InvoiceUseQuantity); }