private void btnPrint_Click(object sender, EventArgs e) { int recordCount = bPurchase.GetPurchaseRecordCount(GetCondition()); _currentDt = bPurchase.GetPurchaseList(GetCondition(), "", 1, recordCount).Tables[0]; if (isSearch && _currentDt != null) { SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_PURCHASE_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx"; sf.Filter = "(文件)|*.xls;*.xlsx"; string header = "画面明细编号\t采购内部编号\t供应商编号\t供应商名称\t供应商类型\t供应商类型名称\t供应商类型名称\t国外发票No\t国外发票金额\t国内发票No\t" + "国内发票金额\t付款状态\t付款状态名称\t开票日期\t付款预定日\t通货编号\t通货名称\t状态\t\n"; if (sf.ShowDialog(this) == DialogResult.OK) { _currentDt.Columns.Remove("INVOICE_No"); _currentDt.Columns.Remove("INVOICE_NO_AMOUNT"); if (_currentDt != null) { int result = CommonExport.DataTableToCsv(_currentDt, header, sf.FileName); if (result == 0) { MessageBox.Show("导出成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } }
private void btnPrint_Click(object sender, EventArgs e) { _currentDt = bStock.GetStockPrintList(oldGetCondition).Tables[0]; _currentDt.Columns.Add("ALLOATION_QUANTITY", Type.GetType("System.String")); _currentDt.Columns.Add("NO_ALLOATION", Type.GetType("System.String")); _currentDt.Columns.Add("RECEIPT_PLAN_QUANTITY", Type.GetType("System.String")); foreach (DataRow rows in _currentDt.Rows) { decimal alloationQuantity = bAlloation.GetAlloationQuantity(CConvert.ToString(rows["WAREHOUSE_CODE"]), CConvert.ToString(rows["PRODUCT_CODE"])); rows["ALLOATION_QUANTITY"] = Convert.ToString(alloationQuantity); rows["NO_ALLOATION"] = Convert.ToDecimal(rows["QUANTITY"]) - Convert.ToDecimal(rows["ALLOATION_QUANTITY"]); rows["RECEIPT_PLAN_QUANTITY"] = bStock.GetPurchaseQuantity(rows["WAREHOUSE_CODE"].ToString(), rows["PRODUCT_CODE"].ToString()); } if (_currentDt.Rows.Count > 0 && isSearch) { int result = CommonExport.DataTableToExcel(_currentDt, CConstant.STOCK_HEADER, CConstant.STOCK_COLUMNS, "STOCK", "STOCK"); if (result == CConstant.EXPORT_SUCCESS) { MessageBox.Show("数据已经成功导出!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (result == CConstant.EXPORT_FAILURE) { MessageBox.Show("数据导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void btnPrint_Click(object sender, EventArgs e) { int recordCount = bPaymentMatch.GetPaymentMatchSearchRecordCount(GetCondition()); _currentDt = bPaymentMatch.GetPaymentMatchSearchList(GetCondition(), "", 1, recordCount).Tables[0]; if (isSearch && _currentDt.Rows.Count > 0) { SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_PAYEMNT_MATCH_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx"; sf.Filter = "(文件)|*.xls;*.xlsx"; string header = "序号\t付款编号\t供应商名称\t付款日期\t发票编号\t发票金额\t通货名称\t预付款金额\t付款金额\t状态\t\n"; if (sf.ShowDialog(this) == DialogResult.OK) { if (_currentDt != null) { int result = CommonExport.DataTableToCsv(_currentDt, header, sf.FileName); if (result == 0) { MessageBox.Show("导出成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } }
private void btnPrint_Click(object sender, EventArgs e) { _currentDt = bProductBuild.GetBuildSearchPrintList(GetConduction()).Tables[0]; _currentDt.Columns.Add("STATUS"); foreach (DataRow row in _currentDt.Rows) { if (CConvert.ToInt32(row["STATUS_FLAG"]) == CConstant.BUILD_STATUS) { row["STATUS"] = "组成"; } } _currentDt.Columns.Remove("STATUS_FLAG"); if (_currentDt.Rows.Count > 0 && isSearch) { SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_BUILD_SEARCH_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; string header = "组成编号\t仓库编号\t仓库名称\t组成品编号\t组成品名称\t组成数量\t组成时间\t公司编号\t公司名称\t组成品单位编号\t组成品单位名称\t创建人\t创建时间\t最后更新人\t最后更新时间\t" + "材料明细\t材料编号\t材料名称\t材料数量\t材料单位编号\t材料单位名称\t状态\t\n"; if (sf.ShowDialog(this) == DialogResult.OK) { if (_currentDt != null) { int result = CommonExport.DataTableToCsv(_currentDt, header, sf.FileName); if (result == 0) { MessageBox.Show("成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } }
/// <summary> /// 导出 /// </summary> private void MasterToolBar_DoExport_Click(object sender, EventArgs e) { _currentDt = bHsCode.GetList(GetConduction()).Tables[0]; if (isSearch && _currentDt != null) { foreach (DataRow row in _currentDt.Rows) { try { if (row["CREATE_USER"] != null && bCommon.GetBaseMaster("USER", CConvert.ToString(row["CREATE_USER"])) != null) { row["CREATE_USER"] = bCommon.GetBaseMaster("USER", CConvert.ToString(row["CREATE_USER"])).Name; } if (row["LAST_UPDATE_USER"] != null && bCommon.GetBaseMaster("USER", CConvert.ToString(row["LAST_UPDATE_USER"])) != null) { row["LAST_UPDATE_USER"] = bCommon.GetBaseMaster("USER", CConvert.ToString(row["LAST_UPDATE_USER"])).Name; } } catch { } } int result = CommonExport.DataTableToExcel(_currentDt, CConstant.HS_CODE_HEADER, CConstant.HS_CODE_COLUMNS, "HS_CODE", "HS_CODE"); if (result == CConstant.EXPORT_SUCCESS) { MessageBox.Show("数据已经成功导出!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (result == CConstant.EXPORT_FAILURE) { MessageBox.Show("数据导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("没有可以导出的数据。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnPrint_Click(object sender, EventArgs e) { _currentDt = bReceipt.GetPrintList(GetConduction()).Tables[0]; if (_currentDt.Rows.Count > 0 && isSearch) { //SaveFileDialog sf = new SaveFileDialog(); //sf.FileName = "LZ_RECEIPT_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; //sf.Filter = "(文件)|*.xls;*.xlsx"; //string header = "入库编号\t采购订单编号\t入库行号\t供应商编号\t供应商名称\t入库仓库编号\t入库仓库名称\t" + // "公司编号\t公司名称\t货币编号\t货币名称\t商品编号\t商品名称\t采购数量\t入库预定数量\t入库数量\t" + // "入库日期\t发票编号\t单位编号\t单位名称\t单价\t不含税金额\t税率\t税金\t含税金额\t明细状态\t创建人\t创建时间\t最后更新人\t最后更新时间\t\n"; //if (sf.ShowDialog(this) == DialogResult.OK) //{ // if (_currentDt != null) // { // int result = CommonExport.DataTableToCsv(_currentDt, header, sf.FileName); // if (result == 0) // { // MessageBox.Show("成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); // } // } //} int result = CommonExport.DataTableToExcel(_currentDt, CConstant.RECEIPT_HEADER, CConstant.RECEIPT_COLUMNS, "RECEIPT", "RECEIPT"); if (result == CConstant.EXPORT_SUCCESS) { MessageBox.Show("数据已经成功导出!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (result == CConstant.EXPORT_FAILURE) { MessageBox.Show("数据导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
/// <summary> /// 导出审查表 /// </summary> private void btnExport_Click(object sender, EventArgs e) { if (dgvData.SelectedRows.Count > 0) { DataGridViewRow row = dgvData.SelectedRows[0]; Hashtable ht = new Hashtable(); BaseCustomerTable customerTable = new BCustomer().GetModel(CConvert.ToString(row.Cells["CUSTOMER_CODE"].Value)); BaseCustomerTable endcustomerTable = new BCustomer().GetModel(CConvert.ToString(row.Cells["ENDER_CUSTOMER_CODE"].Value)); if (customerTable == null) { customerTable = new BaseCustomerTable(); } if (endcustomerTable == null) { endcustomerTable = new BaseCustomerTable(); } ht.Add("&CUSTOMER_NAME", customerTable.NAME); ht.Add("&NAME_ENGLSIH", customerTable.NAME_ENGLISH); ht.Add("&CONTACT_NAME", customerTable.CONTACT_NAME); ht.Add("&A", customerTable.MEMO2); ht.Add("&MEMO", customerTable.MEMO); ht.Add("&ORDER_MEMO", row.Cells["MEMO"].Value); ht.Add("&END_CUSTOMER_NAME", endcustomerTable.NAME); ht.Add("&END_NAME_ENGLISH", endcustomerTable.NAME_ENGLISH); ht.Add("&END_CONTACT_NAME", endcustomerTable.CONTACT_NAME); ht.Add("&END_MEMO2", endcustomerTable.MEMO2); ht.Add("&END_MEMO", endcustomerTable.MEMO); ht.Add("&SLIP_NUMBER", row.Cells["SLIP_NUMBER"].Value); SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_ORDER_REVIEW_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; if (sf.ShowDialog(this) == DialogResult.OK) { int ret = CommonExport.ExportReView(@"rpt\review.xls", sf.FileName, ht); if (CConstant.EXPORT_FAILURE.Equals(ret)) { MessageBox.Show("导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_SUCCESS.Equals(ret)) { MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (CConstant.EXPORT_RUNNING.Equals(ret)) { MessageBox.Show("文件正在运行,重新生成文件失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_TEMPLETE_FILE_NOT_EXIST.Equals(ret)) { MessageBox.Show("模版文件不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } else { MessageBox.Show("请先选择一行。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
/// <summary> /// /// </summary> private void btnPrint_Click(object sender, EventArgs e) { _currentDt = bOrderHeader.GetPrintList(_currentConduction).Tables[0]; for (int i = 0; i < _currentDt.Rows.Count; i++) { #region 引当 if (CConstant.ALLOATION_COMPLETE.Equals(_currentDt.Rows[i]["ALLOATION_FLAG"])) { _currentDt.Rows[i]["ALLOATION_NAME"] = "完了"; } else if (CConstant.ALLOATION_PART.Equals(_currentDt.Rows[i]["ALLOATION_FLAG"])) { _currentDt.Rows[i]["ALLOATION_NAME"] = "欠品"; } else { _currentDt.Rows[i]["ALLOATION_NAME"] = "未引当"; } #endregion #region 出库 if (CConvert.ToDecimal(_currentDt.Rows[i]["SHIPMENT_QUANTITY"]) == 0) { _currentDt.Rows[i]["SHIPMENT_NAME"] = "未出库"; } else if (CConvert.ToDecimal(_currentDt.Rows[i]["QUANTITY"]) != CConvert.ToDecimal(_currentDt.Rows[i]["SHIPMENT_QUANTITY"])) { _currentDt.Rows[i]["SHIPMENT_NAME"] = "欠品"; } else { _currentDt.Rows[i]["SHIPMENT_NAME"] = "完了"; } #endregion } if (_currentDt != null) { int result = CommonExport.DataTableToExcel(_currentDt, CConstant.ORDER_HEADER, CConstant.ORDER_COLUMNS, "ORDER", "ORDER"); if (result == CConstant.EXPORT_SUCCESS) { MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (result == CConstant.EXPORT_FAILURE) { MessageBox.Show("数据导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("没有可以导出的数据。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnPrint_Click(object sender, EventArgs e) { if (slipnumber != null && status_flag == CConstant.INVENTORY_END) { try { //if (hashtb.Count > 0) //{ int s = bInventory.UpdataInventory(slipnumber, hashtb, _userInfo.CODE, true); if (s <= 0) { MessageBox.Show("盘点失败!"); } else { MessageBox.Show("盘点成功!"); } //} } catch (Exception ex) { MessageBox.Show(ex.Message); } this.DialogResult = DialogResult.OK; this.Close(); } else if (slipnumber == null) { _currentdt = bInventory.GetStartPrintList(txtWarehouseCode.Text.Trim()).Tables[0]; if (_currentdt.Rows.Count > 0 && isSearch) { SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_INVENTORY_START_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; string header = "仓库编号\t仓库名称\t商品编号\t商品名称\t商品规格\t单位编号\t单位名称\t在库数\t实际在库数\t状态\t创建人\t创建时间\t最后更新人\t最后更新时间\t\n"; if (sf.ShowDialog(this) == DialogResult.OK) { if (_currentdt != null) { int result = CommonExport.DataTableToCsv(_currentdt, header, sf.FileName); if (result == 0) { MessageBox.Show("成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } } }
private void btnPrint_Click(object sender, EventArgs e) { int recordCount = bSales.GetReceiptMatchSearchRecordCount(GetCondition()); _currentDt = bSales.GetReceiptMatchSearchList(GetCondition(), "", 1, recordCount).Tables[0]; if (isSearch && _currentDt.Rows.Count > 0) { string RECEIPT_MATCH_HEADER = "收款编号,请款公司编号,请款公司名称,收款日期,发票编号,发票金额,预收款金额,收款金额,通货"; string RECEIPT_MATCH_COLUMNS = "SLIP_NUMBER,CUSTOMER_CLAIM_CODE, CUSTOMER_CLAIM_NAME,SLIP_DATE, INVOICE_NUMBER, INVOICE_AMOUNT,DEPOSIT_AMOUNT,TOTAL_AMOUNT,CURRENCY_NAME"; int result = CommonExport.DataTableToExcel(_currentDt, RECEIPT_MATCH_HEADER, RECEIPT_MATCH_COLUMNS, "sheet1", "RECEIPT_MATCH"); if (result == CConstant.EXPORT_SUCCESS) { MessageBox.Show("导出成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void btnPrint_Click(object sender, EventArgs e) { DataTable printDataTable = bShipment.GetPrintList(currentConduction).Tables[0]; if (isSearch && printDataTable.Rows.Count > 0) { int result = CommonExport.DataTableToExcel(printDataTable, CConstant.SHIPMENT_HEADER, CConstant.SHIPMENT_COLUMNS, "SHIPMENT", "SHIPMENT"); if (result == CConstant.EXPORT_SUCCESS) { MessageBox.Show("导出成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (result == CConstant.EXPORT_FAILURE) { MessageBox.Show("数据导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void btnPrint_Click(object sender, EventArgs e) { int recordCount = bSales.GetSalesRecordCount(GetCondition()); _currentDt = bSales.GetSalesList(GetCondition(), "", 1, recordCount).Tables[0]; if (isSearch && _currentDt != null) { string SALES_HEADER = "发票系统编号,发票编号,请款公司编号,请款公司名称,开票日期,收款预定日,发票金额,未收款金额," + "收款状态,订单单号,订单金额,出库单号,出库金额,明细开票金额,通货"; string SALES_COLUMNS = "SLIP_NUMBER,INVOICE_NUMBER,CUSTOMER_CLAIM_CODE,CUSTOMER_CLAIM_NAME,SLIP_DATE,CUSTOMER_CLAIM_DATE,INVOICE_AMOUNT,UN_RECEIPT_AMOUNT," + "PAYMENT_STATUS_NAME,ORDER_SLIP_NUMBER,ORDER_AMOUNT,SHIPMENT_SLIP_NUMBER,SHIPMENT_AMOUNT,INVOICE_AMOUNT,CURRENCY_NAME"; int result = CommonExport.DataTableToExcel(_currentDt, SALES_HEADER, SALES_COLUMNS, "sheet1", "SALES"); if (result == CConstant.EXPORT_SUCCESS) { MessageBox.Show("导出成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void btnPrint_Click(object sender, EventArgs e) { _currentDt = bProductBuild.GetBuildPrintList(GetConduction()).Tables[0]; _currentDt.Columns.Add("PURCHASE_QUANTITY"); _currentDt.Columns.Add("NO_ALLOATION"); _currentDt.Columns.Add("STATUE_FLAG"); foreach (DataRow rows in _currentDt.Rows) { rows["PURCHASE_QUANTITY"] = CConvert.ToDecimal(rows["QUANTITY"]) * CConvert.ToDecimal(txtQuantity.Text.Trim()); decimal alloationQuantity = bAlloation.GetAlloationQuantity(txtWarehouse.Text.Trim(), CConvert.ToString(rows["PRODUCT_PART_CODE"])); BaseStockTable stock = new BaseStockTable(); stock = bPurchaseOrder.GetStockModel(txtWarehouse.Text.Trim(), CConvert.ToString(rows["PRODUCT_PART_CODE"])); rows["NO_ALLOATION"] = stock.QUANTITY - alloationQuantity; if (CConvert.ToDecimal(rows["NO_ALLOATION"]) >= CConvert.ToDecimal(rows["PURCHASE_QUANTITY"])) { rows["STATUE_FLAG"] = "OK"; } else { rows["STATUE_FLAG"] = "NG"; } } if (_currentDt.Rows.Count > 0 && isSearch) { SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_BUILD_PRINT_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; string header = "组成品编号\t组成品名称\t材料编号\t材料名称\t材料规格\t单位编号\t单位名称\t最小构成数量\t需求数量\t未引当数量\t状况\t\n"; if (sf.ShowDialog(this) == DialogResult.OK) { if (_currentDt != null) { int result = CommonExport.DataTableToCsv(_currentDt, header, sf.FileName); if (result == 0) { MessageBox.Show("成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } }
/// <summary> /// 导出 /// </summary> private void MasterToolBar_DoExport_Click(object sender, EventArgs e) { _currentDt = bProductParts.GetList(GetConduction()).Tables[0]; if (isSearch && _currentDt != null) { int result = CommonExport.DataTableToExcel(_currentDt, CConstant.PRODUCT_PARTS_HEADER, CConstant.PRODUCT_PARTS_COLUMNS, "PRODUCT_PARTS", "PRODUCT_PARTS"); if (result == CConstant.EXPORT_SUCCESS) { MessageBox.Show("数据已经成功导出!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (result == CConstant.EXPORT_FAILURE) { MessageBox.Show("数据导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("没有可以导出的数据。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 导出 /// </summary> private void btnPrint_Click(object sender, EventArgs e) { _currentDt = bPurchaseOrder.GetPrintList(_currentConduction).Tables[0]; if (isSearch && _currentDt.Rows.Count > 0) { int result = CommonExport.DataTableToExcel(_currentDt, CConstant.PURCHASE_ORDER_HEADER, CConstant.PURCHASE_ORDER_COLUMNS, "PURCHASE_ORDER", "PURCHASE_ORDER"); if (result == CConstant.EXPORT_SUCCESS) { MessageBox.Show("数据已经成功导出!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (result == CConstant.EXPORT_FAILURE) { MessageBox.Show("数据导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("没有可以导出的数据。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 导出 /// </summary> private void MasterToolBar_DoExport_Click(object sender, EventArgs e) { _currentDt = bCustomerReported.GetList(GetConduction()).Tables[0]; if (isSearch && _currentDt.Rows.Count > 0) { int result = CommonExport.DataTableToExcel(_currentDt, CConstant.CUSTOMER_REPORTED_HEADER, CConstant.CUSTOMER_REPORTED_COLUMNS, "CUSTOMER_REPORTED", "CUSTOMER_REPORTED"); if (result == CConstant.EXPORT_SUCCESS) { MessageBox.Show("数据已经成功导出!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (result == CConstant.EXPORT_FAILURE) { MessageBox.Show("数据导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("没有可以导出的数据。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnPrint_Click(object sender, EventArgs e) { _currentDt = bPurchaseOrder.GetPurchaseSupplementList(oldGetCondition).Tables[0]; if (isSearch && _currentDt.Rows.Count > 0) { int result = CommonExport.DataTableToExcel(_currentDt, CConstant.PO_SUPPLEMENT_HEADER, CConstant.PO_SUPPLEMENT_COLUMNS, "PO_SUPPLEMENT", "PO_SUPPLEMENT"); if (result == CConstant.EXPORT_SUCCESS) { MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (result == CConstant.EXPORT_FAILURE) { MessageBox.Show("数据导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("没有可以导出的数据。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnPrint_Click(object sender, EventArgs e) { int recordCount = bSales.GetUnReceiptRecordCount(GetCondition()); _currentDt = bSales.GetUnReceiptList(GetCondition(), "", 1, recordCount).Tables[0]; if (isSearch && _currentDt.Rows.Count > 0) { SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_UNRECEIPT_MATCH_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx"; sf.Filter = "(文件)|*.xls;*.xlsx"; string header = "画面明细编号\t销售内部编号\t请款公司编号\t请款公司名称\t开票日期\t发票编号\t发票金额\t通货\t收款预定日\t未收金额\t状态\t\n"; if (sf.ShowDialog(this) == DialogResult.OK) { //_currentDt.Columns.Remove("Row"); int result = CommonExport.DataTableToCsv(_currentDt, header, sf.FileName); if (result == 0) { MessageBox.Show("导出成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }
private void btnPrint_Click(object sender, EventArgs e) { _currentDt = bStock.GetDelayPrintList(GetConduction()).Tables[0]; if (_currentDt.Rows.Count > 0 && isSearch) { SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_DELAY_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; string header = "商品编号\t商品名称\t商品规格\t单位编号\t单位名称\t商品分类编号\t商品分类名称\t在库数\t" + "仓库编号\t仓库名称\t最后出库时间\t最后入库时间\t状态\t创建人\t创建时间\t最后更新人\t最后更新时间\t\n"; if (sf.ShowDialog(this) == DialogResult.OK) { if (_currentDt != null) { int result = CommonExport.DataTableToCsv(_currentDt, header, sf.FileName); if (result == 0) { MessageBox.Show("成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } }
private void btnPrint_Click(object sender, EventArgs e) { _currentDt = bTransfer.GetPrintList(GetConduction()).Tables[0]; if (isSearch && _currentDt != null) { SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_TRANSFER_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; string header = "调拨编号\t调拨日期\t调拨明细行号\t商品编号\t商品名称\t调出仓库编号\t调出仓库名称\t调入仓库编号\t调入仓库名称\t" + "调拨数量\t单位编号\t单位名称\t公司编号\t公司名称\t状态\t创建人\t创建时间\t最后更新人\t最后更新时间\t\n"; if (sf.ShowDialog(this) == DialogResult.OK) { if (_currentDt != null) { int result = CommonExport.DataTableToCsv(_currentDt, header, sf.FileName); if (result == 0) { MessageBox.Show("成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } }
private void btnPrint_Click(object sender, EventArgs e) { _currentDt = bInventory.GetEndPrintList(GetConduction()).Tables[0]; if (_currentDt.Rows.Count > 0 && isSearch) { SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_INVENTORY_SEARCH_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; string header = "盘点编号\t仓库编号\t仓库名称\t公司编号\t公司名称\t盘点开始日期\t盘点结束日期\t状态\t创建人\t" + "创建时间\t最后更新人\t最后更新时间\t盘点明细行号\t商品编号\t商品名称\t在库数\t实际在库数\t明细状态\n"; if (sf.ShowDialog(this) == DialogResult.OK) { if (_currentDt != null) { int result = CommonExport.DataTableToCsv(_currentDt, header, sf.FileName); if (result == 0) { MessageBox.Show("成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } }
/* This method validates the SIS templates in Views/Templates/SIS * * */ private bool ValidateFormResult(def_FormResults fr, TemplateItems amt = null) { // * * * OT 3-15-16 completed form results need to be validated on every save (Bug 13110) //// * * * OT 1-4-16 form results that are already marked as completed get to skip validation //if (fr.formStatus == (byte)FormResults_formStatus.COMPLETED) // return true; if (amt == null) { amt = new GeneralForm(); } //retrieve all responses for this formResult, by def_ItemVariable identifier List <ValuePair> allResponses = CommonExport.GetDataByFormResultId(fr.formResultId); //pass the response data through generic validation (meta-data driven validation) def_Forms frm = formsRepo.GetFormById(fr.formId); string[] ItemVariableSuffixesToSkip = { "Notes", "portantTo", "portantFor", "cl_age", "int_id" }; SharedValidation sv = new SharedValidation(allResponses); bool invalid = sv.DoGenericValidation(formsRepo, amt, frm, ItemVariableSuffixesToSkip); //pass the response data through one-off validation (rules that can't be encoded into meta-data) //populate amt.valdiationMessages in the process amt.validationMessages = new List <string>(); if (SisOneOffValidation.RunOneOffValidation(formsRepo, frm, fr.EnterpriseID.Value, allResponses, amt)) { invalid = true; } if (invalid) { return(false); } // Mark the FormResult as Complete new Assessments(formsRepo).AssessmentComplete(fr);// formsRepo.FormResultComplete(fr); // Insert status log indicating assessment has been marked complete if (SessionHelper.IsVentureMode == false) { ReviewStatus.AssessmentIsCompleted(formsRepo, fr); if (WebServiceActivity.IsWebServiceEnabled()) { WebServiceActivity.CallWebService(formsRepo, (int)WebServiceActivity.webServiceActivityFunctions.COMPLETE, "formResultId=" + fr.formResultId.ToString()); } } // Populate the hidden Venture Version field upon validation if (SessionHelper.IsVentureMode == true) { string ventureVersion = SessionHelper.Read <string>("venture_version"); if (ventureVersion != null) { Updates.AddField(formsRepo, Updates.SIS_HIDDEN, fr, Updates.VENTURE_VERSION, ventureVersion); } } return(true); }
private void btnPurcahse_Click(object sender, EventArgs e) { if (dgvData.SelectedRows.Count > 0) { Hashtable ht = null; DataTable dt = null; DataGridViewRow row = dgvData.SelectedRows[0]; BaseCompanyTable company = new BCompany().GetModel(_userInfo.COMPANY_CODE); BllPurchaseOrderTable purchase = bPurchaseOrder.GetModel(CConvert.ToString(row.Cells["SLIP_NUMBER"].Value)); BllOrderHeaderTable order = new BOrderHeader().GetModel(purchase.ORDER_SLIP_NUMBER); BaseWarehouseTable warehouse = new BWarehouse().GetModel(purchase.RECEIPT_WAREHOUSE_CODE); if (company == null) { company = new BaseCompanyTable(); } if (warehouse == null) { warehouse = new BaseWarehouseTable(); } if (purchase == null) { purchase = new BllPurchaseOrderTable(); } BaseSupplierTable supplier = new BSupplier().GetModel(purchase.SUPPLIER_CODE); if (supplier.TYPE == 2) { #region 国内 ht = new Hashtable(); ht.Add("&COMPANY_NAME", company.NAME); ht.Add("&ADDRESS", company.ADDRESS_FIRST + company.ADDRESS_MIDDLE + company.ADDRESS_LAST); if (string.IsNullOrEmpty(company.PHONE_NUMBER.ToString())) { ht.Add("&PHONE", "TEL " + "FAX" + company.FAX_NUMBER); } else { ht.Add("&PHONE", "TEL" + company.PHONE_NUMBER.ToString() + "FAX" + company.FAX_NUMBER); } ht.Add("&SLIP_NUMBER", purchase.SLIP_NUMBER); ht.Add("&SLIP_DATE", purchase.SLIP_DATE.ToString("yyyy年MM月dd日")); ht.Add("&SUPPLIER", "厂商名称:" + supplier.NAME); // ht.Add("&NAME", company.NAME); ht.Add("&DUE_DATE", "1.交货日期:" + CConvert.ToDateTime(purchase.DUE_DATE).ToShortDateString()); ht.Add("&PACKING_METHOD", "2.包装方式:" + purchase.PACKING_METHOD); ht.Add("&WAREHOUSE_NAME", "3.交货地址:" + warehouse.ADDRESS_FIRST + warehouse.ADDRESS_MIDDLE + warehouse.ADDRESS_LAST); ht.Add("&PAYMENT_CONDITION", "4.支付方式:" + purchase.PAYMENT_CONDITION); dt = new DataTable(); dt.Columns.Add("NO"); dt.Columns.Add("MODEL_NUMBER"); dt.Columns.Add("PRODUCT_NAME"); dt.Columns.Add("SPEC"); dt.Columns.Add("QUANTITY"); dt.Columns.Add("PRICE"); dt.Columns.Add("AMOUNT_WITHOUT_TAX"); //dt.Columns.Add("AMOUNT_INCLUDED_TAX"); dt.Columns.Add("DUE_DATE"); decimal amount = 0; decimal taxAmount = 0; DataRow rows = null; foreach (BllPurchaseOrderLineTable OLModel in purchase.Items) { rows = dt.NewRow(); rows["NO"] = OLModel.LINE_NUMBER; if (OLModel.PRODUCT_CODE.Length >= 4 && OLModel.PRODUCT_CODE.Substring(0, 4) == "9999") { rows["PRODUCT_NAME"] = OLModel.PRODUCT_NAME; rows["SPEC"] = OLModel.PRODUCT_SPEC; rows["MODEL_NUMBER"] = ""; } else { BaseProductTable product = new BProduct().GetModel(OLModel.PRODUCT_CODE); if (product != null) { rows["PRODUCT_NAME"] = product.NAME; rows["SPEC"] = product.SPEC; rows["MODEL_NUMBER"] = product.MODEL_NUMBER; } } rows["QUANTITY"] = OLModel.QUANTITY; rows["PRICE"] = OLModel.PRICE; rows["AMOUNT_WITHOUT_TAX"] = Convert.ToDouble(CConvert.ToDecimal(rows["QUANTITY"]) * CConvert.ToDecimal(rows["PRICE"])).ToString("0.00"); //rows["AMOUNT_INCLUDED_TAX"] = OLModel.AMOUNT_INCLUDED_TAX; rows["DUE_DATE"] = CConvert.ToDateTime(purchase.DUE_DATE).ToString("yyyy/MM/dd"); amount += OLModel.AMOUNT_WITHOUT_TAX; taxAmount += OLModel.TAX_AMOUNT; dt.Rows.Add(rows); } ht.Add("&AMOUNT", amount); ht.Add("&TAX_AMOUNT", taxAmount); ht.Add("&TOTAL_AMOUNT", amount + taxAmount); SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_PURCHASE_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; if (sf.ShowDialog(this) == DialogResult.OK) { if (dt.Rows.Count > 0) { int ret = CommonExport.ExportPurchase(@"rpt\purchase.xls", sf.FileName, dt, ht); if (CConstant.EXPORT_FAILURE.Equals(ret)) { MessageBox.Show("导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_SUCCESS.Equals(ret)) { MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (CConstant.EXPORT_RUNNING.Equals(ret)) { MessageBox.Show("文件正在运行,重新生成文件失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_TEMPLETE_FILE_NOT_EXIST.Equals(ret)) { MessageBox.Show("模版文件不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("明细信息不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } #endregion } else { decimal AMOUNT_WITHOUT_TAX = 0; decimal ORDER_AMOUNT = 0; #region 国外 ht = new Hashtable(); ht.Add("&SUPPLIER_NAME", supplier.NAME); ht.Add("&CONTACT_NAME", supplier.CONTACT_NAME); ht.Add("&PHONE", supplier.PHONE_NUMBER); ht.Add("&FAX", supplier.FAX_NUMBER); // ht.Add("&ORDER_NUMBER", purchase.ORDER_SLIP_NUMBER); ht.Add("&SLIP_NUMBER", purchase.SLIP_NUMBER); ht.Add("&SUPPLIER_ORDER_CODE", purchase.SUPPLIER_ORDER_NUMBER); ht.Add("&PURCHASE_QUOTATION_NUMBER", purchase.PURCHASE_QUOTATION_NUMBER); if (order != null) { ht.Add("&CUSTOMER_PO_NUMBER", order.CUSTOMER_PO_NUMBER); string customerCode = ""; //if (!string.IsNullOrEmpty(order.CUSTOMER_NAME)) //{ // customerCode = order.CUSTOMER_CODE; // ht.Add("&CUSTOMER_NAME", order.CUSTOMER_NAME); //} //else //{ customerCode = order.ENDER_CUSTOMER_CODE; ht.Add("&CUSTOMER_NAME", order.ENDER_CUSTOMER_NAME); //} ht.Add("&DELIVERY_DATE", order.DUE_DATE); ht.Add("&SERIAL_NUMBER", order.SERIAL_NUMBER); ht.Add("&AIRCRAFT", order.SERIAL_TYPE); BaseCustomerTable customer = new BCustomer().GetModel(customerCode); ht.Add("&CUSTOMER_CONTACT_NAME", customer.CONTACT_NAME); ht.Add("&CUSTOMER_PHONE", customer.PHONE_NUMBER); //ht.Add("&ORDER_AMOUNT", order.AMOUNT_INCLUDED_TAX); } else { ht.Add("&CUSTOMER_PO_NUMBER", ""); ht.Add("&DELIVERY_DATE", ""); ht.Add("&SERIAL_NUMBER", ""); //ht.Add("&ORDER_AMOUNT", ""); ht.Add("&AIRCRAFT", ""); ht.Add("&CUSTOMER_NAME", company.NAME_SHORT); ht.Add("&CUSTOMER_CONTACT_NAME", ""); ht.Add("&CUSTOMER_PHONE", company.PHONE_NUMBER); } ht.Add("&MEMO", purchase.MEMO); ht.Add("&TOTAL_AMOUNT", purchase.TOTAL_AMOUNT); ht.Add("&PAYMENT", purchase.PAYMENT_CONDITION); ht.Add("&SLIP_DATE", purchase.SLIP_DATE); ht.Add("&DUE_DATE", purchase.DUE_DATE); dt = new DataTable(); dt.Columns.Add("NO"); dt.Columns.Add("PRODUCT_CODE"); dt.Columns.Add("X_1", Type.GetType("System.String")); dt.Columns.Add("PRODUCT_NAME"); dt.Columns.Add("X_2", Type.GetType("System.String")); dt.Columns.Add("MODEL_NUMBER"); dt.Columns.Add("X_3", Type.GetType("System.String")); dt.Columns.Add("QUANTITY"); dt.Columns.Add("PRICE"); dt.Columns.Add("AMOUNT_WITHOUT_TAX"); DataRow rows = null; foreach (BllPurchaseOrderLineTable OLModel in purchase.Items) { AMOUNT_WITHOUT_TAX += OLModel.AMOUNT_INCLUDED_TAX; if (order != null) { foreach (BllOrderLineTable line in order.Items) { if (line.PRODUCT_CODE == OLModel.PRODUCT_CODE) { ORDER_AMOUNT += CConvert.ToDecimal(line.AMOUNT); break; } } } else { ORDER_AMOUNT += 0; } rows = dt.NewRow(); rows["NO"] = OLModel.LINE_NUMBER; rows["PRODUCT_CODE"] = OLModel.PRODUCT_CODE; if (OLModel.PRODUCT_CODE.Length >= 4 && OLModel.PRODUCT_CODE.Substring(0, 4) == "9999") { rows["PRODUCT_NAME"] = OLModel.PRODUCT_NAME; rows["MODEL_NUMBER"] = OLModel.PRODUCT_SPEC; } else { BaseProductTable product = new BProduct().GetModel(OLModel.PRODUCT_CODE); if (product != null) { if (!string.IsNullOrEmpty(product.NAME_JP)) { rows["PRODUCT_NAME"] = product.NAME_JP; } else { rows["PRODUCT_NAME"] = product.NAME; } rows["MODEL_NUMBER"] = product.SPEC + " " + product.MODEL_NUMBER; } } rows["QUANTITY"] = OLModel.QUANTITY; rows["PRICE"] = OLModel.PRICE; rows["AMOUNT_WITHOUT_TAX"] = OLModel.AMOUNT_INCLUDED_TAX; dt.Rows.Add(rows); } ht.Add("&AMOUNT_WITHOUT_TAX", AMOUNT_WITHOUT_TAX); ht.Add("&ORDER_AMOUNT", ORDER_AMOUNT); SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_PURCHASE_OVERSEAS_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; if (sf.ShowDialog(this) == DialogResult.OK) { if (dt.Rows.Count > 0) { int ret = CommonExport.ExportPurchaseOverseas(@"rpt\purchase_overseas.xls", sf.FileName, dt, ht); if (CConstant.EXPORT_FAILURE.Equals(ret)) { MessageBox.Show("导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_SUCCESS.Equals(ret)) { MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (CConstant.EXPORT_RUNNING.Equals(ret)) { MessageBox.Show("文件正在运行,重新生成文件失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_TEMPLETE_FILE_NOT_EXIST.Equals(ret)) { MessageBox.Show("模版文件不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("明细信息不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } #endregion } } else { MessageBox.Show("请选择一行!"); } }
/// <summary> /// 纳品书 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnShipper_Click(object sender, EventArgs e) { try { if (isSearch) { //纳品书订单的选择 FrmShipmentPrintSelect frm = new FrmShipmentPrintSelect(currentConduction); if (frm.ShowDialog(this) == DialogResult.Cancel) { return; } string slipNumber = frm.resultValue; if (!string.IsNullOrEmpty(slipNumber)) { Hashtable ht = null; //单个替换用 DataTable dt = null; //数据集 bool isMechanicalBase = false; DataSet ds = bShipment.GetList(" SLIP_NUMBER in (" + slipNumber + ")"); foreach (DataRow dr in ds.Tables[0].Rows) { if (CConstant.MECHANICAL_BASE.Equals(dr["MECHANICAL_DISTINCTION_FLAG"])) { isMechanicalBase = true; break; } } if (isMechanicalBase) { #region 含机械本体 dt = new DataTable(); dt.Columns.Add("NO", Type.GetType("System.String")); dt.Columns.Add("NAME", Type.GetType("System.String")); dt.Columns.Add("SPEC", Type.GetType("System.String")); dt.Columns.Add("QTY", Type.GetType("System.Decimal")); dt.Columns.Add("UNIT_NAME", Type.GetType("System.String")); dt.Columns.Add("SERIAL_NUMBER", Type.GetType("System.String")); DataRow row = null; bool isFirst = true; int i = 1; foreach (DataRow dr in ds.Tables[0].Rows) { if (isFirst) { ht = new Hashtable(); ht.Add("&SLIP_NUMBER", CConvert.ToString(dr["SLIP_NUMBER"])); ht.Add("&DATE", CConvert.ToDateTime(dr["SLIP_DATE"]).ToShortDateString()); ht.Add("&CUSTOMER_NAME", CConvert.ToString(dr["CUSTOMER_NAME"])); ht.Add("&CONTACT_NAME", CConvert.ToString(dr["CONTACT_NAME"])); ht.Add("&MOBIL_NUMBER", CConvert.ToString(dr["MOBIL_NUMBER"])); ht.Add("&MONTH", CConvert.ToDateTime(dr["ARRIVAL_DATE"]).Month); ht.Add("&DAY", CConvert.ToDateTime(dr["ARRIVAL_DATE"]).Day); ht.Add("&HOUR", CConvert.ToDateTime(dr["ARRIVAL_DATE"]).Hour); ht.Add("&MINUTE", CConvert.ToDateTime(dr["ARRIVAL_DATE"]).Minute); ht.Add("&ADDRESS", CConvert.ToString(dr["DELIVERY_POINT_NAME"])); } if (CConstant.PRODUCT_PACKAGE_ALONT.Equals(dr["PACKAGE_MODE"])) { row = dt.NewRow(); row["NO"] = i++; row["NAME"] = CConvert.ToString(dr["PRODUCT_NAME"]); row["SPEC"] = CConvert.ToString(dr["SPEC"]); row["QTY"] = CConvert.ToDecimal(dr["QUANTITY"]); row["UNIT_NAME"] = CConvert.ToString(dr["UNIT_NAME"]); if (CConstant.MECHANICAL_BASE.Equals(dr["MECHANICAL_DISTINCTION_FLAG"])) { row["SERIAL_NUMBER"] = CConvert.ToString(dr["SERIAL_NUMBER"]); } else { row["SERIAL_NUMBER"] = ""; } dt.Rows.Add(row); } } SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_SHIPMENT_BODY_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; if (sf.ShowDialog(this) == DialogResult.OK) { if (dt.Rows.Count > 0) { int ret = CommonExport.ExportShipmentBody(@"rpt\shipper_body.xls", sf.FileName, dt, ht); if (CConstant.EXPORT_FAILURE.Equals(ret)) { MessageBox.Show("导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_SUCCESS.Equals(ret)) { MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (CConstant.EXPORT_RUNNING.Equals(ret)) { MessageBox.Show("文件正在运行,重新生成文件失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_TEMPLETE_FILE_NOT_EXIST.Equals(ret)) { MessageBox.Show("模版文件不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("明细信息不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } #endregion } else { #region 部件出货 dt = new DataTable(); dt.Columns.Add("NO", Type.GetType("System.Int32")); dt.Columns.Add("PRODUCT_NAME", Type.GetType("System.String")); dt.Columns.Add("X_1", Type.GetType("System.String")); dt.Columns.Add("X_2", Type.GetType("System.String")); dt.Columns.Add("MODEL_NUMBER", Type.GetType("System.String")); dt.Columns.Add("X_3", Type.GetType("System.String")); dt.Columns.Add("QUANTITY", Type.GetType("System.Decimal")); dt.Columns.Add("MEMO", Type.GetType("System.String")); DataRow row = null; bool isFirst = true; int i = 1; foreach (DataRow dr in ds.Tables[0].Rows) { if (isFirst) { ht = new Hashtable(); ht.Add("&SLIP_NUMBER", CConvert.ToString(dr["SLIP_NUMBER"])); ht.Add("&DATE", CConvert.ToDateTime(dr["SLIP_DATE"]).ToShortDateString()); ht.Add("&END_CUSTOMER_NAME", CConvert.ToString(dr["ENDER_CUSTOMER_NAME"])); ht.Add("&CONTACT", CConvert.ToString(dr["ENDER_CONTACT_NAME"])); ht.Add("&MOBIL_NUMBER", CConvert.ToString(dr["ENDER_MOBIL_NUMBER"])); ht.Add("&ADDRESS", CConvert.ToString(dr["DELIVERY_POINT_NAME"])); DataTable userDt = new BUser().GetList(" CODE='" + CConvert.ToString(dr["CREATE_USER"]) + "'").Tables[0]; string companyName = ""; if (userDt != null && userDt.Rows.Count > 0) { companyName = CConvert.ToString(userDt.Rows[0]["COMPANY_NAME"]); } ht.Add("&COMPANY_NAME", companyName); ht.Add("&INVOICE_NUMBER", bShipment.GetReceiptInvoiceNumber(CConvert.ToString(dr["ORDER_SLIP_NUMBER"]))); } row = dt.NewRow(); row["NO"] = i++; row["PRODUCT_NAME"] = CConvert.ToString(dr["PRODUCT_NAME"]); row["MODEL_NUMBER"] = CConvert.ToString(dr["SPEC"]) + CConvert.ToString(dr["MODEL_NUMBER"]); row["QUANTITY"] = CConvert.ToDecimal(dr["QUANTITY"]); row["MEMO"] = CConvert.ToString(dr["MEMO"]); dt.Rows.Add(row); } SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_SHIPMENT_ACCESSORIES_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; if (sf.ShowDialog(this) == DialogResult.OK) { if (dt.Rows.Count > 0) { int ret = CommonExport.ExportShipmentAccessories(@"rpt\shipper_accessories.xls", sf.FileName, dt, ht); if (CConstant.EXPORT_FAILURE.Equals(ret)) { MessageBox.Show("导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_SUCCESS.Equals(ret)) { MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (CConstant.EXPORT_RUNNING.Equals(ret)) { MessageBox.Show("文件正在运行,重新生成文件失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_TEMPLETE_FILE_NOT_EXIST.Equals(ret)) { MessageBox.Show("模版文件不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("明细信息不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } #endregion } } // end if (!string.IsNullOrEmpty(slipNumber)) } // end if (isSearch) } catch (Exception ex) { } }
public ActionResult Validate(FormCollection frmCllctn, TemplateItems ti) { //save response from formCollection into the DB ResultsController rc = new ResultsController(formsRepo); rc.ControllerContext = ControllerContext; rc.Save(frmCllctn, ti); int formResultId = SessionHelper.SessionForm.formResultId; SessionHelper.SessionForm.sectionId = -1; //Run generic validation AdapValidationErrorsModel model = new AdapValidationErrorsModel(); model.navMenuModel = AJBoggs.Adap.Templates.TemplateMenus.getAdapNavMenuModel(SessionHelper.SessionForm, formsRepo); model.validationMessages = new List <string>(); model.missingItemVariablesBySectionByPart = new Dictionary <int, Dictionary <int, List <string> > >(); def_Forms frm = formsRepo.GetFormById(SessionHelper.SessionForm.formId); List <ValuePair> allResponses = CommonExport.GetDataByFormResultId(formResultId); SharedValidation sv = new SharedValidation(allResponses); bool invalid = sv.DoGenericValidation(formsRepo, model, frm); //transfer generic validation results to an ADAP-specific model model.titlesOfMissingSubsectionsBySectionByPart = new Dictionary <int, Dictionary <int, List <string> > >(); foreach (int prtId in model.missingItemVariablesBySectionByPart.Keys) { model.titlesOfMissingSubsectionsBySectionByPart.Add(prtId, new Dictionary <int, List <string> >()); foreach (int sctId in model.missingItemVariablesBySectionByPart[prtId].Keys) { def_Sections sct = formsRepo.GetSectionById(sctId); formsRepo.SortSectionItems(sct); List <int> ssSectionIds = new List <int>(); foreach (def_SectionItems si in sct.def_SectionItems.Where(si => si.subSectionId.HasValue)) { ssSectionIds.Add(formsRepo.GetSubSectionById(si.subSectionId.Value).sectionId); } model.titlesOfMissingSubsectionsBySectionByPart[prtId].Add(sctId, new List <string>()); foreach (string itemVariableIdent in model.missingItemVariablesBySectionByPart[prtId][sctId]) { //for each item variable identifier returned by generic validation, //lookup the corresponding subsection's title for display on the ADAP "validation errors" screen def_ItemVariables iv = formsRepo.GetItemVariableByIdentifier(itemVariableIdent); def_Items itm = iv == null ? null : iv.def_Items; def_SectionItems si = itm == null ? null : formsRepo.getSectionItemsForItem(itm).Where(sit => ssSectionIds.Contains(sit.sectionId)).FirstOrDefault(); def_Sections sub = si == null ? null : si.def_Sections; if (sub != null && !model.titlesOfMissingSubsectionsBySectionByPart[prtId][sctId].Contains(sub.title)) { model.titlesOfMissingSubsectionsBySectionByPart[prtId][sctId].Add(sub.title); } } } } //run CO-ADAP one-off validation if (AdapCOOneOffValidation.RunOneOffValidation(sv, model)) { invalid = true; } //return the validation errors screen if any errors were found //model.validationMessages could have some warnings even if no errors were found, in which case "invalid" would be false here if (invalid) { return(View("~/Views/COADAP/ValidationErrors.cshtml", model)); } //if no problems were found, or if warnings were found but no errors, return the next section in the application if (model.validationMessages.Count == 0) { model.validationMessages.Add("No errors were found"); } int sectionId = Convert.ToInt16(frmCllctn["navSectionId"]); return(rc.Template(sectionId, model.validationMessages)); }
private FileContentResult BuildFormResultsCSV(List <string> leadingHeaders) { //debug Debug.WriteLine(" * * * BuildFormResultsCSV - " + DateTime.Now.Ticks + " started"); string includeParts = Request["includeParts"] as string; Dictionary <string, int> formPartMap = (Dictionary <string, int>)Session["formPartMap"]; string formId = Request["formId"] as string; ExportModel exportModel = (ExportModel)Session["ExportModel"]; int iFormId = Convert.ToInt32(formId); List <def_Forms> forms = new List <def_Forms>(); if (iFormId == 0) { foreach (int?id in exportModel.formIds) { forms.Add(formsRepo.GetFormById(Convert.ToInt32(id))); } } else { forms.Add(formsRepo.GetFormById(iFormId)); } string outpath = ControllerContext.HttpContext.Server.MapPath("../Content/formResults_" + System.DateTime.Now.Ticks + ".csv"); Stream stream = new FileStream(outpath, FileMode.Create); CsvWriter writer = new CsvWriter(stream); // Build a map of with all relevent itemVariable identifiers Dictionary <int, string> ivIdentifiersById = new Dictionary <int, string>(); foreach (string leadingIdent in leadingHeaders) { int id = leadingIdent.StartsWith("FORMRESULT_") ? -1 - ivIdentifiersById.Count : formsRepo.GetItemVariableByIdentifier(leadingIdent).itemVariableId; ivIdentifiersById.Add(id, leadingIdent); } int i = 0; Dictionary <int, List <string> > formIdentMap = new Dictionary <int, List <string> >(); foreach (def_Forms form in forms) { List <string> map = new List <string>(); // Use the formPartMap when its not empty. i = (formPartMap.Count() > 0) ? formPartMap[form.formId + " start"] : 0; foreach (def_Parts prt in formsRepo.GetFormParts(form)) { if (prt.identifier.Contains("Scores")) { continue; } if (includeParts[i++] == '1') { //formPartMap.Add(form.formId + " " + prt.partId + " ident start", ivIdentifiersById.Count()); foreach (def_Sections sctn in formsRepo.GetSectionsInPart(prt)) { formsRepo.CollectItemVariableIdentifiersById(sctn, ivIdentifiersById); foreach (def_Items item in formsRepo.GetAllItemsForSection(sctn)) { map.AddRange(formsRepo.GetItemVariablesByItemId(item.itemId).Select(iv => iv.identifier).ToList()); } } Debug.WriteLine("Added more sections to ivIdentifiersById, form: " + form.formId + " part: " + prt.partId + " new Count: " + ivIdentifiersById.Count()); //formPartMap.Add(form.formId + " " + prt.partId + " ident end", ivIdentifiersById.Count()); } } formIdentMap.Add(form.formId, map); } //add additional columns for any unhandled data the comes back from CommonExport.GetFormResultValues foreach (FormResultExportTagName tagName in Enum.GetValues(typeof(FormResultExportTagName))) { string header = "FORMRESULT_" + tagName.ToString(); if (!ivIdentifiersById.Values.Contains(header)) { int id = -1 - ivIdentifiersById.Count; //not used, but must be unique to act as dictionary key ivIdentifiersById.Add(id, header); } } //debug Debug.WriteLine(" * * * BuildFormResultsCSV - " + DateTime.Now.Ticks + " finished Build a map of with all column identifiers"); // Build a list of formresults to export List <int?> formResultIds = exportModel.formResultIds; List <def_FormResults> formResultsToExport; if (iFormId == 0) { formResultsToExport = new List <def_FormResults>(); foreach (def_Forms form in forms) { formResultsToExport.AddRange(formsRepo.GetFormResultsByFormId(form.formId).Where(r => formResultIds.Contains(r.formResultId)).ToList()); } } else { if (formResultIds == null) { formResultsToExport = formsRepo.GetFormResultsByFormId(iFormId).ToList(); } else { formResultsToExport = formsRepo.GetFormResultsByFormId(iFormId).Where(r => formResultIds.Contains(r.formResultId)).ToList(); } } Debug.WriteLine(" * * * BuildFormResultsCSV - " + DateTime.Now.Ticks + " finished building a list of formresults to export"); //build a header record with identifiers int n = ivIdentifiersById.Count; List <int> ivIds = new List <int>(); List <string> identifiers = new List <string>(); List <string> headerText = new List <string>(); int j = 0; foreach (KeyValuePair <int, string> de in ivIdentifiersById) { ivIds.Add(de.Key); identifiers.Add(de.Value); headerText.Add(de.Value.Replace("FORMRESULT_", "")); j++; } HeaderRecord hr = new HeaderRecord(true, headerText); writer.WriteRecord(hr); Debug.WriteLine(" * * * BuildFormResultsCSV - " + DateTime.Now.Ticks + " finished build a header record with identifiers"); //Build a DataRecord with item labels (second row in the output file) string[] values = new string[n]; //used to temporarily store the values for each row in the export for (int k = 0; k < n; k++) { if (identifiers[k].StartsWith("FORMRESULT_")) { FormResultExportTagName tag = (FormResultExportTagName)Enum.Parse(typeof(FormResultExportTagName), headerText[k]); values[k] = getCSVSecondRowLabelForFormResultTagName(tag); } else { values[k] = formsRepo.GetItemVariableById(ivIds[k]).def_Items.label; } } writer.WriteRecord(new DataRecord(hr, values)); Debug.WriteLine(" * * * BuildFormResultsCSV - " + DateTime.Now.Ticks + " finished Build a DataRecord with item labels"); //insert access logs (one for each assessment being exported) int[] arrFrIds = formResultIds.Where(id => id.HasValue).Select(id => id.Value).ToArray(); AccessLogging.InsertMultipleAccessLogRecords(formsRepo, arrFrIds, (int)AccessLogging.accessLogFunctions.EXPORT, "Export CSV of assessment"); // Build a DataRecord for each form result int count = 0, total = formResultsToExport.Count(); foreach (def_FormResults fr in formResultsToExport) { //pull all necessary data for this formResult List <ValuePair> rspValues = CommonExport.GetDataByFormResultId(fr.formResultId); List <ValuePair> frValues = CommonExport.GetFormResultValues(fr, forms.Where(f => f.formId == fr.formId).FirstOrDefault()); //fill in values from formResult for (int k = 0; k < n; k++) { if (identifiers[k].StartsWith("FORMRESULT_")) { //values[k] = GetFormResultValue(fr, headerText[k]); ValuePair vp = frValues.Where(vpt => vpt.identifier == headerText[k]).FirstOrDefault(); if (vp != null) { values[k] = vp.rspValue; } else { values[k] = ""; } } } //replace reponse values (numbers) with meaningful text for certain cells //FormResults_formStatus status; //Enum.TryParse(values[colIndex_status], out status); //values[colIndex_status] = status.ToString(); //values[colIndex_sis_why] = GetDropdownText("assmtReason", values[colIndex_sis_why]); //fill in values from responseVariables for (i = 0; i < n; i++) { if (identifiers[i].StartsWith("FORMRESULT_")) { continue; } ValuePair vp = null; if (identifiers[i].StartsWith("FORMRESULT_") || formIdentMap[fr.formId].Contains(identifiers[i])) { vp = rspValues.Where(vpt => vpt.identifier == identifiers[i]).FirstOrDefault(); } values[i] = vp == null ? "" : vp.rspValue; } writer.WriteRecord(new DataRecord(hr, values)); //debug Debug.WriteLine(" * * * BuildFormResultsCSV - " + DateTime.Now.Ticks + " finished " + (++count) + "/" + total + " records"); } writer.Close(); //<- calls stream.Close() //debug Debug.WriteLine(" * * * BuildFormResultsCSV - " + DateTime.Now.Ticks + " finished everything"); return(File(System.IO.File.ReadAllBytes(outpath), "text/csv", "results.csv")); }
/// <summary> /// OEM销售成绩表 /// </summary> private void ExportOEMSales() { DataTable dt = new DataTable(); dt.Columns.Add("No"); dt.Columns.Add("ORDER_SLIP_DATE"); dt.Columns.Add("RECEIPT_SLIP_DATE"); dt.Columns.Add("MACHINE_CODE"); dt.Columns.Add("MACHINE_NAME"); dt.Columns.Add("CHECK_NUMBER"); dt.Columns.Add("CHECK_DATE"); dt.Columns.Add("CUSTOMER_NAME"); dt.Columns.Add("ENDER_CUSTOMER_NAME"); dt.Columns.Add("ADDRESS"); dt.Columns.Add("ADDRESS2"); string where = GetOEMSalesConduction(); DataTable salesTable = bInvoice.GetSalesProductInfo(where).Tables[0]; DataRow dr = null; int i = 0; foreach (DataRow row in salesTable.Rows) { dr = dt.NewRow(); dr["No"] = i.ToString(); dr["ORDER_SLIP_DATE"] = row["SLIP_DATE"]; dr["RECEIPT_SLIP_DATE"] = row["CREATE_DATE_TIME"]; dr["MACHINE_CODE"] = row["SERIAL_NUMBER"]; dr["MACHINE_NAME"] = row["MACHINE_NAME"]; dr["CHECK_NUMBER"] = row["CHECK_NUMBER"]; dr["CHECK_DATE"] = row["CHECK_DATE"]; dr["CUSTOMER_NAME"] = row["CUSTOMER_NAME"]; dr["ENDER_CUSTOMER_NAME"] = row["END_CUSTOMER_NAME"]; dr["ADDRESS"] = row["ADDRESS"]; dr["ADDRESS2"] = row["ADDRESS"]; i++; dt.Rows.Add(dr); } Hashtable ht = new Hashtable(); SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_OEM_SALES_PERFORMANCE_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; if (sf.ShowDialog(this) == DialogResult.OK) { if (dt.Rows.Count > 0) { int ret = CommonExport.ExportOEMSales(@"rpt\OEM_SALES_PERFORMANCE.xls", sf.FileName, dt, ht); if (CConstant.EXPORT_FAILURE.Equals(ret)) { MessageBox.Show("导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_SUCCESS.Equals(ret)) { MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (CConstant.EXPORT_RUNNING.Equals(ret)) { MessageBox.Show("文件正在运行,重新生成文件失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_TEMPLETE_FILE_NOT_EXIST.Equals(ret)) { MessageBox.Show("模版文件不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } this.Close(); } else { MessageBox.Show("明细信息不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
/// <summary> /// OEM制品管理表 /// </summary> public void ExportOEMProduct() { //OEM制品管理表所需要的导出字段 #region exportDt.Columns.Clear(); exportDt.Columns.Add("MACHINE_CODE", Type.GetType("System.String")); //机械编号 exportDt.Columns.Add("MACHINE_NAME", Type.GetType("System.String")); //机械名称 exportDt.Columns.Add("BODY_PURCHASE_ORDER_SLIP_NUMBER", Type.GetType("System.String")); //机械本体采购订单编号D:\龙泽ERP\ERP.WinUI\Finance\FrmSalesSearch.cs exportDt.Columns.Add("BODY_INVOICE_NUMBER_LOCAL", Type.GetType("System.String")); //机械本体采购发票编号 exportDt.Columns.Add("BODY_PURCHASE_SLIP_DATE", Type.GetType("System.String")); //机械本体采购发票日期 exportDt.Columns.Add("BODY_INVOICE_AMOUNT", Type.GetType("System.String")); //机械本体采购发票金额(含税) exportDt.Columns.Add("PART_PURCHASE_ORDER_SLIP_NUMBER", Type.GetType("System.String")); //机械部件采购订单编号(国内) exportDt.Columns.Add("PART_INVOICE_NUMBER_LOCAL", Type.GetType("System.String")); //机械部件采购发票编号(国内) exportDt.Columns.Add("PART_PURCHASE_SLIP_DATE", Type.GetType("System.String")); //机械部件采购发票日期(国内) exportDt.Columns.Add("PART_INVOICE_AMOUNT", Type.GetType("System.Decimal")); //机械部件采购发票金额(含税)(国内) exportDt.Columns.Add("FOREIGN_PURCHASE_ORDER_SLIP_NUMBER", Type.GetType("System.String")); //机械部件采购订单编号(国外) exportDt.Columns.Add("FOREIGN_PURCHASE_INVOICE_NUMBER", Type.GetType("System.String")); //机械部件采购发票编号(国外) exportDt.Columns.Add("FOREIGN_PURCHASE_SLIP_DATE", Type.GetType("System.String")); //机械部件采购发票日期(国外) exportDt.Columns.Add("FOREIGN_INVOICE_AMOUNT", Type.GetType("System.Decimal")); //机械部件采购发票金额(含税)(国外) exportDt.Columns.Add("EXCHANGE_RATE", Type.GetType("System.Decimal")); //外币汇率 exportDt.Columns.Add("RMB_INVOICE_AMOUNT", Type.GetType("System.Decimal")); //外币拆合人民币 exportDt.Columns.Add("TAX_AMOUNT", Type.GetType("System.Decimal")); //税金 exportDt.Columns.Add("TOTAL", Type.GetType("System.Decimal")); //小计 exportDt.Columns.Add("TOTAL_AMOUNT", Type.GetType("System.Decimal")); //总金额(采购金额) exportDt.Columns.Add("ORDER_SLIP_NUMBER", Type.GetType("System.String")); //销售订单编号 exportDt.Columns.Add("CUSTOMER_PO_NUMBER", Type.GetType("System.String")); //销售合同编号 exportDt.Columns.Add("SHIPMENT_SLIP_DATE", Type.GetType("System.String")); //出库日期 exportDt.Columns.Add("SALES_INVOICE_NUMBER", Type.GetType("System.String")); //销售发票NO exportDt.Columns.Add("ORDER_SLIP_DATE", Type.GetType("System.String")); //销售日期 exportDt.Columns.Add("AMOUNT_WITHOUT_TAX", Type.GetType("System.Decimal")); //不含税金额 exportDt.Columns.Add("TOTAL_BODY_AMOUNT", Type.GetType("System.Decimal")); //机械本体不含税金额 exportDt.Columns.Add("PART_AMOUNT", Type.GetType("System.Decimal")); //机械部件不含税金额 exportDt.Columns.Add("GROSS_PROFIT", Type.GetType("System.Decimal")); //利润 exportDt.Columns.Add("CHECK_NUMBER", Type.GetType("System.String")); //检查编号 exportDt.Columns.Add("CHECK_DATE", Type.GetType("System.String")); //检查日期 exportDt.Columns.Add("CUSTOMER_NAME", Type.GetType("System.String")); //代理店名称 exportDt.Columns.Add("ENDER_CUSTOMER_NAME", Type.GetType("System.String")); //需要家 exportDt.Columns.Add("ADDRESS", Type.GetType("System.String")); //纳入先地址 exportDt.Columns.Add("ADDRESS2", Type.GetType("System.String")); //纳入先地址2 exportDt.Columns.Add("FANUC_SERIAL_NUMBER", Type.GetType("System.String")); exportDt.Columns.Add("FANUC_SLIP_NUMBER", Type.GetType("System.String")); #endregion //销售订单编号的取得 #region DataTable slipTable = bInvoice.GetSlipNumber(GetOEMProductConduction()).Tables[0]; string slip_number = ""; foreach (DataRow row in slipTable.Rows) { slip_number += "'" + row["ORDER_SLIP_NUMBER"].ToString() + "',"; } if (string.IsNullOrEmpty(slip_number)) { return; } slip_number = slip_number.Substring(0, slip_number.Length - 1); #endregion //根据取出的slipnumber取得第一部分的数据 机械本体的采购信息 #region DataTable oneDt = bInvoice.GetStatementOneInfo(slip_number).Tables[0]; DataRow dr = null; string machineCode = CConvert.ToString(oneDt.Rows[0]["MACHINE_CODE"]); foreach (DataRow row in oneDt.Rows) { if (machineCode == row["MACHINE_CODE"].ToString()) { dr = exportDt.NewRow(); dr["ORDER_SLIP_NUMBER"] = row["ORDER_SLIP_NUMBER"]; dr["MACHINE_CODE"] = row["MACHINE_CODE"]; dr["MACHINE_NAME"] = row["MACHINE_NAME"]; dr["BODY_PURCHASE_ORDER_SLIP_NUMBER"] = row["PURCHASE_ORDER_NUMBER"]; dr["BODY_INVOICE_NUMBER_LOCAL"] = row["INVOICE_NUMBER"]; dr["BODY_PURCHASE_SLIP_DATE"] = row["SLIP_DATE"]; dr["FANUC_SERIAL_NUMBER"] = row["FANUC_SERIAL_NUMBER"]; dr["FANUC_SLIP_NUMBER"] = row["FANUC_SLIP_NUMBER"]; dr["BODY_INVOICE_AMOUNT"] = addDecimal(dr["BODY_INVOICE_AMOUNT"], row["INVOICE_AMOUNT"]); } else { exportDt.Rows.Add(dr); dr = exportDt.NewRow(); dr["ORDER_SLIP_NUMBER"] = row["ORDER_SLIP_NUMBER"]; dr["MACHINE_CODE"] = row["MACHINE_CODE"]; dr["MACHINE_NAME"] = row["MACHINE_NAME"]; dr["BODY_PURCHASE_ORDER_SLIP_NUMBER"] = row["PURCHASE_ORDER_NUMBER"]; dr["BODY_INVOICE_NUMBER_LOCAL"] = row["INVOICE_NUMBER"]; dr["BODY_PURCHASE_SLIP_DATE"] = row["SLIP_DATE"]; dr["FANUC_SERIAL_NUMBER"] = row["FANUC_SERIAL_NUMBER"]; dr["FANUC_SLIP_NUMBER"] = row["FANUC_SLIP_NUMBER"]; dr["BODY_INVOICE_AMOUNT"] = row["INVOICE_AMOUNT"]; machineCode = row["MACHINE_CODE"].ToString(); } } if (dr != null) { exportDt.Rows.Add(dr); } #endregion //根据取出的ORDER_SLIP_NUMBER取得第二部分的数据 机械部件的采购信息 #region dr = null; BExchange bExchange = new BExchange(); DataTable tmpDt = exportDt.Clone(); DataTable twoDt = bInvoice.GetStatementTwoInfo(slip_number).Tables[0]; string orderSlipNumber = CConvert.ToString(oneDt.Rows[0]["ORDER_SLIP_NUMBER"]); foreach (DataRow row in twoDt.Rows) { if (orderSlipNumber == row["ORDER_SLIP_NUMBER"].ToString()) { dr = tmpDt.NewRow(); dr["ORDER_SLIP_NUMBER"] = row["ORDER_SLIP_NUMBER"]; if (CConvert.ToInt32(row["TYPE"]) == CConstant.ERP_FOREIGN_NUMBER)//国外 { dr["FOREIGN_PURCHASE_ORDER_SLIP_NUMBER"] = addString(dr["FOREIGN_PURCHASE_ORDER_SLIP_NUMBER"], row["PURCHASE_ORDER_SLIP_NUMBER"]); dr["FOREIGN_PURCHASE_INVOICE_NUMBER"] = addString(dr["FOREIGN_PURCHASE_INVOICE_NUMBER"], row["INVOICE_NUMBER"]); dr["FOREIGN_PURCHASE_SLIP_DATE"] = addString(dr["FOREIGN_PURCHASE_SLIP_DATE"], row["SLIP_DATE"]); dr["FOREIGN_INVOICE_AMOUNT"] = addDecimal(dr["FOREIGN_INVOICE_AMOUNT"], row["INVOICE_AMOUNT"]); DateTime datatime = CConvert.ToDateTime(CConvert.ToDateTime(CConvert.ToDateTime(dr["FOREIGN_PURCHASE_SLIP_DATE"]).ToString("yyyy/MM") + "/1")); dr["EXCHANGE_RATE"] = bExchange.GetExchange(datatime, CConstant.EXCHANGE_JP, CConstant.EXCHANGE_RMB); dr["RMB_INVOICE_AMOUNT"] = addDecimal(dr["RMB_INVOICE_AMOUNT"], CConvert.ToDecimal(row["INVOICE_AMOUNT"]) * CConvert.ToDecimal(dr["EXCHANGE_RATE"])); } else if (CConvert.ToInt32(row["TYPE"]) == CConstant.ERP_DOMESTIC_NUMBER)//国内 { dr["PART_PURCHASE_ORDER_SLIP_NUMBER"] = addString(dr["PART_PURCHASE_ORDER_SLIP_NUMBER"], row["PURCHASE_ORDER_SLIP_NUMBER"]); dr["PART_INVOICE_NUMBER_LOCAL"] = addString(dr["PART_INVOICE_NUMBER_LOCAL"], row["INVOICE_NUMBER"]); dr["PART_PURCHASE_SLIP_DATE"] = addString(dr["PART_PURCHASE_SLIP_DATE"], row["SLIP_DATE"]); dr["PART_INVOICE_AMOUNT"] = addDecimal(dr["PART_INVOICE_AMOUNT"], row["INVOICE_AMOUNT"]); } dr["TAX_AMOUNT"] = addDecimal(dr["TAX_AMOUNT"], row["TAX_AMOUNT"]); } else { tmpDt.Rows.Add(dr); orderSlipNumber = row["ORDER_SLIP_NUMBER"].ToString(); dr = tmpDt.NewRow(); dr["ORDER_SLIP_NUMBER"] = row["ORDER_SLIP_NUMBER"]; if (CConvert.ToInt32(row["SUPPLIER_CODE"]) == CConstant.ERP_FOREIGN_NUMBER)//国外 { dr["FOREIGN_PURCHASE_ORDER_SLIP_NUMBER"] = addString(dr["FOREIGN_PURCHASE_ORDER_SLIP_NUMBER"], row["PURCHASE_ORDER_SLIP_NUMBER"]); dr["FOREIGN_PURCHASE_INVOICE_NUMBER"] = addString(dr["FOREIGN_PURCHASE_INVOICE_NUMBER"], row["INVOICE_NUMBER"]); dr["FOREIGN_PURCHASE_SLIP_DATE"] = addString(dr["FOREIGN_PURCHASE_SLIP_DATE"], row["SLIP_DATE"]); dr["FOREIGN_INVOICE_AMOUNT"] = addDecimal(dr["FOREIGN_INVOICE_AMOUNT"], row["INVOICE_AMOUNT"]); dr["EXCHANGE_RATE"] = 0.07; dr["RMB_INVOICE_AMOUNT"] = addDecimal(dr["RMB_INVOICE_AMOUNT"], CConvert.ToDecimal(row["INVOICE_AMOUNT"]) * CConvert.ToDecimal(dr["EXCHANGE_RATE"])); } else if (CConvert.ToInt32(row["SUPPLIER_CODE"]) == CConstant.ERP_DOMESTIC_NUMBER)//国内 { dr["PART_PURCHASE_ORDER_SLIP_NUMBER"] = addString(dr["PART_PURCHASE_ORDER_SLIP_NUMBER"], row["PURCHASE_ORDER_SLIP_NUMBER"]); dr["PART_INVOICE_NUMBER_LOCAL"] = addString(dr["PART_INVOICE_NUMBER_LOCAL"], row["INVOICE_NUMBER"]); dr["PART_PURCHASE_SLIP_DATE"] = addString(dr["PART_PURCHASE_SLIP_DATE"], row["SLIP_DATE"]); dr["PART_INVOICE_AMOUNT"] = addDecimal(dr["PART_INVOICE_AMOUNT"], row["INVOICE_AMOUNT"]); } dr["TAX_AMOUNT"] = addDecimal(dr["TAX_AMOUNT"], row["TAX_AMOUNT"]); } } if (dr != null) { tmpDt.Rows.Add(dr); } #endregion //采购信息段的合并 #region foreach (DataRow row in exportDt.Rows) { foreach (DataRow tRow in tmpDt.Rows) { if (row["ORDER_SLIP_NUMBER"].Equals(tRow["ORDER_SLIP_NUMBER"])) { row["FOREIGN_PURCHASE_ORDER_SLIP_NUMBER"] = tRow["FOREIGN_PURCHASE_ORDER_SLIP_NUMBER"]; row["FOREIGN_PURCHASE_INVOICE_NUMBER"] = tRow["FOREIGN_PURCHASE_INVOICE_NUMBER"]; row["FOREIGN_PURCHASE_SLIP_DATE"] = tRow["FOREIGN_PURCHASE_SLIP_DATE"]; row["FOREIGN_INVOICE_AMOUNT"] = tRow["FOREIGN_INVOICE_AMOUNT"]; row["EXCHANGE_RATE"] = tRow["EXCHANGE_RATE"]; row["RMB_INVOICE_AMOUNT"] = tRow["RMB_INVOICE_AMOUNT"]; row["PART_PURCHASE_ORDER_SLIP_NUMBER"] = tRow["PART_PURCHASE_ORDER_SLIP_NUMBER"]; row["PART_INVOICE_NUMBER_LOCAL"] = tRow["PART_INVOICE_NUMBER_LOCAL"]; row["PART_PURCHASE_SLIP_DATE"] = tRow["PART_PURCHASE_SLIP_DATE"]; row["PART_INVOICE_AMOUNT"] = tRow["PART_INVOICE_AMOUNT"]; row["TAX_AMOUNT"] = tRow["TAX_AMOUNT"]; } } } #endregion //销售信息的取得 #region DataTable OrderTable = bInvoice.GetOrderHeaderInfo(slip_number).Tables[0]; foreach (DataRow erow in exportDt.Rows) { foreach (DataRow Orow in OrderTable.Rows) { if (erow["ORDER_SLIP_NUMBER"].Equals(Orow["SLIP_NUMBER"])) { erow["CUSTOMER_PO_NUMBER"] = Orow["CUSTOMER_PO_NUMBER"]; erow["SALES_INVOICE_NUMBER"] = Orow["SERIAL_NUMBER"]; erow["ORDER_SLIP_DATE"] = Orow["SLIP_DATE"]; erow["AMOUNT_WITHOUT_TAX"] = Orow["AMOUNT_WITHOUT_TAX"]; erow["CHECK_NUMBER"] = Orow["CHECK_NUMBER"]; erow["CHECK_DATE"] = Orow["CHECK_DATE"]; erow["CUSTOMER_NAME"] = Orow["CUSTOMER_NAME"]; erow["ENDER_CUSTOMER_NAME"] = Orow["ENDER_CUSTOMER_NAME"]; erow["ADDRESS"] = Orow["DELIVERY_POINT_NAME"]; erow["ADDRESS2"] = Orow["DELIVERY_POINT_NAME"]; } } } #endregion //销售发票信息的取得 #region DataTable InvoiceTable = bInvoice.GetInvoiceNumber(slip_number).Tables[0]; foreach (DataRow irow in exportDt.Rows) { foreach (DataRow Irow in InvoiceTable.Rows) { if (irow["ORDER_SLIP_NUMBER"].Equals(Irow["ORDER_SLIP_NUMBER"])) { irow["SALES_INVOICE_NUMBER"] = Irow["SALES_INVOICE_NUMBER"]; irow["SHIPMENT_SLIP_DATE"] = Irow["SLIP_DATE"]; } } } #endregion //机器本体的销售信息的取得 #region DataTable TotalBodyAmount = bInvoice.GetAmountWithoutTaxa(slip_number).Tables[0]; foreach (DataRow totalrow in exportDt.Rows) { foreach (DataRow Totalrow in TotalBodyAmount.Rows) { if (totalrow["ORDER_SLIP_NUMBER"].Equals(Totalrow["SLIP_NUMBER"])) { totalrow["TOTAL_BODY_AMOUNT"] = Totalrow["AMOUNT_WITHOUT_TAX"]; } } } #endregion //各种合计金额的计算 #region foreach (DataRow row in exportDt.Rows) { row["TOTAL"] = addDecimal(row["RMB_INVOICE_AMOUNT"], row["TAX_AMOUNT"]); row["TOTAL_AMOUNT"] = addDecimal(row["BODY_INVOICE_AMOUNT"], row["PART_INVOICE_AMOUNT"], row["TOTAL"]); } #endregion //数据的导出 #region Hashtable ht = new Hashtable(); SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_PRODUCT_MANAGEMENT_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; if (sf.ShowDialog(this) == DialogResult.OK) { if (exportDt.Rows.Count > 0) { int ret = CommonExport.ExportOEMProduct(@"rpt\OEM_PRODUCT_MANAGEMENT.xls", sf.FileName, exportDt, ht); if (CConstant.EXPORT_FAILURE.Equals(ret)) { MessageBox.Show("导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_SUCCESS.Equals(ret)) { MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (CConstant.EXPORT_RUNNING.Equals(ret)) { MessageBox.Show("文件正在运行,重新生成文件失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_TEMPLETE_FILE_NOT_EXIST.Equals(ret)) { MessageBox.Show("模版文件不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } this.Close(); } else { MessageBox.Show("明细信息不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } #endregion }
/// <summary> /// 应收账款管理表 /// </summary> private void ExportFinanceInfo() { exportDt = new DataTable(); exportDt.Columns.Add("SLIP_NUMBER", Type.GetType("System.String")); //开票内部订单编号 exportDt.Columns.Add("SLIP_DATE", Type.GetType("System.String")); //开票日期 exportDt.Columns.Add("SERIAL_NUMBER", Type.GetType("System.String")); //发票内容 exportDt.Columns.Add("MODEL_NUMBER", Type.GetType("System.String")); //机械型号 exportDt.Columns.Add("CUSTOMER_PO_NUMBER", Type.GetType("System.String")); //合同编号 exportDt.Columns.Add("CUSTOMER_NAME", Type.GetType("System.String")); //代理店 exportDt.Columns.Add("ENDUSER_CUSTOMER_NAME", Type.GetType("System.String")); //最终客户 exportDt.Columns.Add("SHIPMENT_SLIP_DATE", Type.GetType("System.String")); //出库日期 exportDt.Columns.Add("QUANTITY", Type.GetType("System.Decimal")); //数量 exportDt.Columns.Add("INVOICE_NUMBER", Type.GetType("System.String")); //发票No exportDt.Columns.Add("INVOICE_AMOUNT_WITHOUT_TAX", Type.GetType("System.Decimal")); //未含税金额 exportDt.Columns.Add("INVOICE_AMOUNT", Type.GetType("System.Decimal")); //含税金额 exportDt.Columns.Add("CUSTOMER_CLAIM_DATE", Type.GetType("System.String")); //收款预定日期 exportDt.Columns.Add("RECEIVABLES_DATE_1", Type.GetType("System.String")); //收款日期1 exportDt.Columns.Add("RECEIVABLES_1", Type.GetType("System.Decimal")); //收款金额1 exportDt.Columns.Add("RECEIVABLES_DATE_2", Type.GetType("System.String")); //收款日期2 exportDt.Columns.Add("RECEIVABLES_2", Type.GetType("System.Decimal")); //收款金额2 exportDt.Columns.Add("RECEIVABLES_DATE_3", Type.GetType("System.String")); //收款日期3 exportDt.Columns.Add("RECEIVABLES_3", Type.GetType("System.Decimal")); //收款金额3 exportDt.Columns.Add("UN_RECEIVABLES", Type.GetType("System.Decimal")); //未收款金额 exportDt.Columns.Add("TOTAL_RECEIVABLES", Type.GetType("System.Decimal")); //总收款金额 DataTable exportMachineDt = exportDt.Clone(); DataTable exportPartsDt = exportDt.Clone(); string invoiceNumber = ""; DataRow eDr = null; //获得机械本体应收账款 #region DataTable machineDT = bInvoice.GetMachineAccountReceivable(GetConduction()).Tables[0]; foreach (DataRow dr in machineDT.Rows) { if (!invoiceNumber.Equals(dr["INVOICE_NUMBER"])) { if (invoiceNumber != "") { exportMachineDt.Rows.Add(eDr); } eDr = exportMachineDt.NewRow(); eDr["SLIP_NUMBER"] = dr["SLIP_NUMBER"]; //开票内部订单编号 eDr["SLIP_DATE"] = dr["SLIP_DATE"]; //开票日期 eDr["SERIAL_NUMBER"] = dr["SERIAL_NUMBER"]; //发票内容 eDr["MODEL_NUMBER"] = dr["MODEL_NUMBER"]; //机械型号 eDr["CUSTOMER_PO_NUMBER"] = dr["CUSTOMER_PO_NUMBER"]; //合同编号 eDr["CUSTOMER_NAME"] = dr["CUSTOMER_NAME"]; //代理店 eDr["ENDUSER_CUSTOMER_NAME"] = dr["ENDUSER_CUSTOMER_NAME"]; //最终客户 eDr["SHIPMENT_SLIP_DATE"] = dr["SHIPMENT_SLIP_DATE"]; //出库日期 eDr["QUANTITY"] = 1; //dr["QUANTITY"]; //数量 eDr["INVOICE_NUMBER"] = dr["INVOICE_NUMBER"]; //发票No eDr["INVOICE_AMOUNT_WITHOUT_TAX"] = GetAmountWithoutTax(dr["INVOICE_AMOUNT"], dr["TAX_RATE"]); //未含税金额 eDr["INVOICE_AMOUNT"] = dr["INVOICE_AMOUNT"]; //含税金额 eDr["CUSTOMER_CLAIM_DATE"] = dr["CUSTOMER_CLAIM_DATE"]; //收款预定日期 invoiceNumber = CConvert.ToString(dr["INVOICE_NUMBER"]); } } if (eDr != null) { exportMachineDt.Rows.Add(eDr); } #endregion //获得机械部件应收账款 #region DataTable partsDT = bInvoice.GetPartsAccountReceivable(GetConduction()).Tables[0]; invoiceNumber = ""; eDr = null; foreach (DataRow dr in partsDT.Rows) { if (!invoiceNumber.Equals(dr["INVOICE_NUMBER"])) { if (invoiceNumber != "") { exportPartsDt.Rows.Add(eDr); } eDr = exportPartsDt.NewRow(); eDr["SLIP_NUMBER"] = dr["SLIP_NUMBER"]; //开票内部订单编号 eDr["SLIP_DATE"] = dr["SLIP_DATE"]; //开票日期 eDr["SERIAL_NUMBER"] = dr["SERIAL_NUMBER"]; //发票内容 eDr["MODEL_NUMBER"] = ""; //dr["MODEL_NUMBER"]; //机械型号 eDr["CUSTOMER_PO_NUMBER"] = dr["CUSTOMER_PO_NUMBER"]; //合同编号 eDr["CUSTOMER_NAME"] = dr["CUSTOMER_NAME"]; //代理店 eDr["ENDUSER_CUSTOMER_NAME"] = dr["ENDUSER_CUSTOMER_NAME"]; //最终客户 eDr["SHIPMENT_SLIP_DATE"] = dr["SHIPMENT_SLIP_DATE"]; //出库日期 eDr["QUANTITY"] = 1; //dr["QUANTITY"]; //数量 eDr["INVOICE_NUMBER"] = dr["INVOICE_NUMBER"]; //发票No eDr["INVOICE_AMOUNT_WITHOUT_TAX"] = GetAmountWithoutTax(dr["INVOICE_AMOUNT"], dr["TAX_RATE"]); //未含税金额 eDr["INVOICE_AMOUNT"] = dr["INVOICE_AMOUNT"]; //含税金额 eDr["CUSTOMER_CLAIM_DATE"] = dr["CUSTOMER_CLAIM_DATE"]; //收款预定日期 invoiceNumber = CConvert.ToString(dr["INVOICE_NUMBER"]); } } if (eDr != null) { exportPartsDt.Rows.Add(eDr); } #endregion decimal totalAmount = 0; decimal machineTotalAmount = 0; decimal machineTotalAmountWithoutTax = 0; decimal partTotalAmountWithoutTax = 0; //付款信息的实装 #region //获得开票付款信息 DataTable receiptDT = bInvoice.GetReceiptMatch(GetReceiptMatchConduction()).Tables[0]; //机械本体的开票信息的实装 foreach (DataRow dr in exportMachineDt.Rows) { int i = 1; foreach (DataRow rDr in receiptDT.Rows) { if (CConvert.ToString(dr["SLIP_NUMBER"]).Equals(rDr["SLIP_NUMBER"])) { dr["RECEIVABLES_DATE_" + i] = rDr["SLIP_DATE"]; dr["RECEIVABLES_" + i] = rDr["RECEIPT_AMOUNT"]; i++; if (i > 3) { break; } } } dr["TOTAL_RECEIVABLES"] = addDecimal(dr["RECEIVABLES_1"], dr["RECEIVABLES_2"], dr["RECEIVABLES_3"]); dr["UN_RECEIVABLES"] = CConvert.ToDecimal(dr["INVOICE_AMOUNT"]) - CConvert.ToDecimal(dr["TOTAL_RECEIVABLES"]); machineTotalAmountWithoutTax += CConvert.ToDecimal(dr["INVOICE_AMOUNT_WITHOUT_TAX"]); machineTotalAmount += CConvert.ToDecimal(dr["INVOICE_AMOUNT"]); totalAmount += machineTotalAmount; } //机械部件的开票信息的实装 foreach (DataRow dr in exportPartsDt.Rows) { int i = 1; foreach (DataRow rDr in receiptDT.Rows) { if (CConvert.ToString(dr["SLIP_NUMBER"]).Equals(rDr["SLIP_NUMBER"])) { dr["RECEIVABLES_DATE_" + i] = rDr["SLIP_DATE"]; dr["RECEIVABLES_" + i] = rDr["RECEIPT_AMOUNT"]; i++; if (i > 3) { break; } } } dr["TOTAL_RECEIVABLES"] = addDecimal(dr["RECEIVABLES_1"], dr["RECEIVABLES_2"], dr["RECEIVABLES_3"]); dr["UN_RECEIVABLES"] = CConvert.ToDecimal(dr["INVOICE_AMOUNT"]) - CConvert.ToDecimal(dr["TOTAL_RECEIVABLES"]); partTotalAmountWithoutTax += CConvert.ToDecimal(dr["INVOICE_AMOUNT_WITHOUT_TAX"]); totalAmount += CConvert.ToDecimal(dr["INVOICE_AMOUNT"]);; } #endregion //数据的导出 string[] headerTitles = { "发票内部编号", "発行年月", "発票内容", "機械型番", "契約書No.", "商社名", "顧客名", "出荷日", "台数", "発票No.", "金額(税抜)(元)", "金額(税込)(元)", "入金予定日", "入金日1", "入金額(元)1", "入金日2", "入金額(元)2", "入金日3", "入金額(元)3", "未入金額(元)", "入金総額(元)" }; #region Hashtable ht = new Hashtable(); ht.Add("&DATE", dateFrom.Text + (dateTo.Checked == true ? " 至 " + dateTo.Text : "")); ht.Add("&TOTAL_AMOUNT", totalAmount); ht.Add("&MACHINE_TOTAL_AMOUNT", machineTotalAmount); ht.Add("&B_MACHINE_TOTAL_AMOUNT_WITHOUT_TAX", machineTotalAmountWithoutTax); ht.Add("&PART_TOTAL_AMOUNT_WITHOUT_TAX", partTotalAmountWithoutTax); SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_RECEIVABLES_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; if (sf.ShowDialog(this) == DialogResult.OK) { if (exportMachineDt.Rows.Count > 0 || exportPartsDt.Rows.Count > 0) { int ret = CommonExport.ExportReceivables(@"rpt\Receivables.xls", sf.FileName, exportMachineDt, exportPartsDt, ht, headerTitles); if (CConstant.EXPORT_FAILURE.Equals(ret)) { MessageBox.Show("导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_SUCCESS.Equals(ret)) { MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (CConstant.EXPORT_RUNNING.Equals(ret)) { MessageBox.Show("文件正在运行,重新生成文件失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_TEMPLETE_FILE_NOT_EXIST.Equals(ret)) { MessageBox.Show("模版文件不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } this.Close(); } else { MessageBox.Show("明细信息不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } #endregion }