private void btnSave_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtCustFullName.Text.Trim())) { throw new Exception("Vollständiger Name Cannot be empty"); } if (!dxReqValidationProvider.Validate()) { return; } if (ObjECustomer == null) { ObjECustomer = new ECustomer(); } ParseCustomerDetails(); ObjBCustomer = new BCustomer(); ObjECustomer.Customer_CustomerID = ObjBCustomer.SaveCustomerDetails(ObjECustomer); BindCustomerData(); cmbCustomer.EditValue = ObjECustomer.Customer_CustomerID; cmbCustomer.Focus(); } catch (Exception ex) { Utility.ShowError(ex); } }
public ActionResult CustomerAcivities(int customerId) { CustomerManagement customerMgr = new CustomerManagement(User.Identity.GetUserId <int>()); List <BCustomer> customers = customerMgr.FindCustomers(User.Identity.GetUserId <int>(), customerId, out total); if (customers.Count == 0) { ViewBag.Message = string.Format("编号为:{0}的客户不是你的客户", customerId); return(View("Error")); } BCustomer customer = customers[0]; ActivityManagement activityMgr = new ActivityManagement(customerMgr.CurrentLoginUser); int page = 1; int pageSize = 20; int.TryParse(Request["page"], out page); page = page > 0 ? page : 1; List <BActivity> activities = activityMgr.FindActivities(0, User.Identity.GetUserId <int>(), customerId, out total, true, page, pageSize); PageItemsResult <BActivity> result = new PageItemsResult <BActivity>() { CurrentPage = page, EnablePaging = true, Items = activities, PageSize = pageSize, TotalRecords = total }; KMBit.Grids.KMGrid <BActivity> grid = new Grids.KMGrid <BActivity>(result); ViewBag.Customer = customer; return(View("CustomerAcivities", grid)); }
public ActionResult EditCustomer(int customerId) { CustomerManagement customerMgr = new CustomerManagement(User.Identity.GetUserId <int>()); List <BCustomer> customers = customerMgr.FindCustomers(User.Identity.GetUserId <int>(), customerId, out total); if (customers == null || customers.Count <= 0) { ViewBag.Message = string.Format("编号为{0}的客户不存在", customerId); return(View("Error")); } BCustomer customer = customers[0]; CreateCustomerModel model = new CreateCustomerModel() { Amount = customer.RemainingAmount, ContactAddress = customer.ContactAddress, ContactEmail = customer.ContactEmail, ContactPeople = customer.ContactPeople, ContactPhone = customer.ContactPhone, CreditAmount = customer.CreditAmount, Description = customer.Description, Id = customer.Id, Name = customer.Name, OpenAccount = customer.OpenId, OpenType = customer.OpenType }; List <DictionaryTemplate> types = StaticDictionary.GetOpenTypeList(); ViewBag.OpenTypes = new SelectList(types, "Id", "Value"); return(View("CreateCustomer", model)); }
private void btnSaveContact_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtContactName.Text.Trim())) { _isValidate = false; throw new Exception("Bitte eingeben: Name"); } bool isvalidName = dxValidationProviderContactName.Validate(txtContactName); if (!isvalidName) { _isValidate = false; } else { _isValidate = true; } if (_isValidate == true) { if (ObjECustomer == null) { ObjECustomer = new ECustomer(); } ParseCustomerContactsDetails(); ObjBCustomer = new BCustomer(); ObjECustomer.ContactPersonID = ObjBCustomer.SaveCustomerContactDetails(ObjECustomer); _isValidate = true; } } catch (Exception ex) { Utility.ShowError(ex); } }
private void txtCustomerCode_Leave(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtCustomerCode.Text.Trim())) { BaseCustomerTable Customer = new BaseCustomerTable(); BCustomer bCustomer = new BCustomer(); Customer = bCustomer.GetModel(txtCustomerCode.Text); if (Customer == null) { txtCustomerCode.Focus(); txtCustomerCode.Text = ""; txtCustomerName.Text = ""; MessageBox.Show("客户编号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { txtCustomerCode.Text = Customer.CODE; txtCustomerName.Text = Customer.NAME; } } else { txtCustomerName.Text = ""; } }
/// <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); } }
public string CheckCustomer(string customer, string title) { if (customer == null || "".Equals(customer)) { return(title + ERROR_NULL); } if (_customerTable[customer.ToString()] != null) { return(""); } BCustomer bCustomer = new BCustomer(); if (bCustomer.Exists(customer)) { _customerTable.Add(customer, customer); return(""); } return(title + ERROR_EXIST); }
public JsonResult AddCustomer(string CustomerName, string CustomerAddress, string CustomerPhone) { var mongoContext = new mongoCloud(); //Data d = new Data(); //d.AddCustomer(CustomerName, CustomerAddress, CustomerPhone); var customer = new BCustomer { NAME = CustomerName, ADDRESS = CustomerAddress, PHONE = CustomerPhone }; mongoContext.Customers.InsertOne(customer); return(Json(new { Data = RenderRazorViewToString("Customers", mongoContext.Customers.Find(x => true).ToList()) })); }
public ActionResult SaveCustomer(CreateCustomerModel model) { if (ModelState.IsValid) { CustomerManagement customerMgr = new CustomerManagement(User.Identity.GetUserId <int>()); BCustomer customer = new BCustomer() { AgentId = User.Identity.GetUserId <int>(), ContactAddress = model.ContactAddress, ContactEmail = model.ContactEmail, ContactPeople = model.ContactPeople, ContactPhone = model.ContactPhone, CreatedTime = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now), CreditAmount = model.CreditAmount, Description = model.Description, Id = model.Id, Name = model.Name, OpenId = model.OpenAccount, OpenType = model.OpenType, RemainingAmount = model.Amount }; try { if (customerMgr.SaveCustomer(customer)) { return(RedirectToAction("Customers")); } }catch (KMBitException ex) { ViewBag.Message = ex.Message; } } List <DictionaryTemplate> types = StaticDictionary.GetOpenTypeList(); ViewBag.OpenTypes = new SelectList(types, "Id", "Value"); return(View("CreateCustomer", model)); }
public override string[] doUpdateDB() { BaseCustomerTable CustomerTable = null; BCustomer bCustomer = new BCustomer(); StringBuilder strError = new StringBuilder(); int successData = 0; int failureData = 0; string errorFilePath = ""; string backupFilePath = ""; //数据导入处理 foreach (DataRow dr in _csvDataTable.Rows) { StringBuilder str = new StringBuilder(); //编号 if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "CODE")))) { str.Append(CheckString(GetValue(dr, "CODE"), 20, "编号")); } else { str.Append("编号不能为空!"); } str.Append(CheckLenght(GetValue(dr, "NAME"), 100, "名称")); //简称 str.Append(CheckLenght(GetValue(dr, "NAME_SHORT"), 50, "简称")); //英文名称 str.Append(CheckLenght(GetValue(dr, "NAME_ENGLISH"), 100, "英文名称")); //邮编 str.Append(CheckLenght(GetValue(dr, "ZIP_CODE"), 8, "邮编")); //地址1 str.Append(CheckLenght(GetValue(dr, "ADDRESS_FIRST"), 100, "地址1")); //地址2 str.Append(CheckLenght(GetValue(dr, "ADDRESS_MIDDLE"), 100, "地址2")); //地址3 str.Append(CheckLenght(GetValue(dr, "ADDRESS_LAST"), 100, "地址3")); //电话 str.Append(CheckLenght(GetValue(dr, "PHONE_NUMBER"), 20, "电话")); //传真 str.Append(CheckLenght(GetValue(dr, "FAX_NUMBER"), 20, "传真")); //联系人名称 str.Append(CheckLenght(GetValue(dr, "CONTACT_NAME"), 50, "联系人名称")); //联系人电话 str.Append(CheckLenght(GetValue(dr, "MOBIL_NUMBER"), 20, "联系人电话")); //邮箱 str.Append(CheckLenght(GetValue(dr, "EMIAL"), 50, "邮箱")); //网址 str.Append(CheckLenght(GetValue(dr, "URL"), 50, "网址")); //备注 str.Append(CheckLenght(GetValue(dr, "MEMO"), 255, "备注")); //类型 if (CConvert.ToInt32(GetValue(dr, "TYPE", 1)) != 1 && CConvert.ToInt32(GetValue(dr, "TYPE", 1)) != 2 && CConvert.ToString(GetValue(dr, "TYPE", 1)) != "") { str.Append("类型只能为1或2!"); } else { str.Append(CheckInt(GetValue(dr, "TYPE", 1), 2, "类型")); } //是否请款公司 if (CConvert.ToInt32(GetValue(dr, "CLAIM_FLAG", 1)) != 1 && CConvert.ToInt32(GetValue(dr, "CLAIM_FLAG", 1)) != 2 && CConvert.ToString(GetValue(dr, "CLAIM_FLAG", 1)) != "") { str.Append("是否请款公司只能为1或2!"); } else { str.Append(CheckInt(GetValue(dr, "CLAIM_FLAG", 1), 2, "是否请款公司")); } //请款公司编号 str.Append(CheckLenght(GetValue(dr, "CLAIM_CODE"), 20, "请款公司编号")); //货币 if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "CURRENCE_CODE")))) { str.Append(CheckCurrency(CConvert.ToString(GetValue(dr, "CURRENCE_CODE")), "货币")); } //状态 str.Append(CheckInt(GetValue(dr, "STATUS_FLAG", 1), 9, "状态")); //备考2 str.Append(CheckLenght(GetValue(dr, "MEMO2"), 100, "备考2")); //日文名称 str.Append(CheckLenght(GetValue(dr, "NAME_JP"), 100, "日文名称")); if (str.ToString().Trim().Length > 0) { strError.Append(GetStringBuilder(dr, str.ToString().Trim())); failureData++; continue; } try { CustomerTable = new BaseCustomerTable(); CustomerTable.CODE = CConvert.ToString(GetValue(dr, "CODE")); CustomerTable.NAME = CConvert.ToString(GetValue(dr, "NAME")); CustomerTable.NAME_SHORT = CConvert.ToString(GetValue(dr, "NAME_SHORT")); CustomerTable.NAME_ENGLISH = CConvert.ToString(GetValue(dr, "NAME_ENGLISH")); CustomerTable.ZIP_CODE = CConvert.ToString(GetValue(dr, "ZIP_CODE")); CustomerTable.ADDRESS_FIRST = CConvert.ToString(GetValue(dr, "ADDRESS_FIRST")); CustomerTable.ADDRESS_MIDDLE = CConvert.ToString(GetValue(dr, "ADDRESS_MIDDLE")); CustomerTable.ADDRESS_LAST = CConvert.ToString(GetValue(dr, "ADDRESS_LAST")); CustomerTable.PHONE_NUMBER = CConvert.ToString(GetValue(dr, "PHONE_NUMBER")); CustomerTable.FAX_NUMBER = CConvert.ToString(GetValue(dr, "FAX_NUMBER")); CustomerTable.CONTACT_NAME = CConvert.ToString(GetValue(dr, "CONTACT_NAME")); CustomerTable.MOBIL_NUMBER = CConvert.ToString(GetValue(dr, "MOBIL_NUMBER")); CustomerTable.EMAIL = CConvert.ToString(GetValue(dr, "EMIAL")); CustomerTable.URL = CConvert.ToString(GetValue(dr, "URL")); CustomerTable.MEMO = CConvert.ToString(GetValue(dr, "MEMO")); CustomerTable.TYPE = CConvert.ToInt32(GetValue(dr, "TYPE", 1)); CustomerTable.CLAIM_FLAG = CConvert.ToInt32(GetValue(dr, "CLAIM_FLAG", 1)); CustomerTable.CLAIM_CODE = CConvert.ToString(GetValue(dr, "CLAIM_CODE")); CustomerTable.CURRENCE_CODE = CConvert.ToString(GetValue(dr, "CURRENCE_CODE")); CustomerTable.STATUS_FLAG = CConvert.ToInt32(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL)); CustomerTable.MEMO2 = CConvert.ToString(GetValue(dr, "MEMO2")); CustomerTable.NAME_JP = CConvert.ToString(GetValue(dr, "NAME_JP")); CustomerTable.CREATE_USER = _userInfo.CODE; CustomerTable.LAST_UPDATE_USER = _userInfo.CODE; if (!bCustomer.Exists(CustomerTable.CODE)) { bCustomer.Add(CustomerTable); } else { bCustomer.Update(CustomerTable); } successData++; } catch { strError.Append(GetStringBuilder(dr, " 数据导入失败,请与系统管理员联系!").ToString()); failureData++; } } //错误记录处理 if (strError.Length > 0) { errorFilePath = WriteFile(strError.ToString()); } //备份处理 backupFilePath = BackupFile(); return(new string[] { successData.ToString(), failureData.ToString(), errorFilePath, backupFilePath }); }
public WalletModel() { _customer = new BCustomer(); _transaction = new BTransaction(); }
public bool SaveCustomer(BCustomer customer) { bool ret = false; if (customer == null) { throw new KMBitException("Customer is NULL"); } if (CurrentLoginUser.IsAdmin) { //TBD } else { if (customer.AgentId > 0 && customer.AgentId != CurrentLoginUser.User.Id) { throw new KMBitException("不能为其他代理商创建客户"); } } using (chargebitEntities db = new chargebitEntities()) { Customer dbCus = null; if (customer.Id > 0) { dbCus = (from c in db.Customer where c.Id == customer.Id select c).FirstOrDefault <Customer>(); if (dbCus == null) { throw new KMBitException(string.Format("编号为{0}的客户不存在", customer.Id)); } dbCus.Description = customer.Description != null ? dbCus.Description : dbCus.Description; dbCus.ContactEmail = customer.ContactEmail; dbCus.ContactAddress = customer.ContactAddress; dbCus.ContactPeople = customer.ContactPeople; dbCus.ContactPhone = customer.ContactPhone; if (string.IsNullOrEmpty(dbCus.Token)) { dbCus.Token = Guid.NewGuid().ToString(); } } else { if (string.IsNullOrEmpty(customer.Name)) { throw new KMBitException("客户名称不能为空"); } Customer existed = (from c in db.Customer where c.Name == customer.Name select c).FirstOrDefault <Customer>(); if (existed != null) { throw new KMBitException(string.Format("名称为:{0}的客户已经存在", customer.Name)); } dbCus = new Customer() { AgentId = customer.AgentId, ContactEmail = customer.ContactEmail, ContactAddress = customer.ContactAddress, ContactPeople = customer.ContactPeople, ContactPhone = customer.ContactPhone, CreatedTime = customer.CreatedTime > 0 ? customer.CreatedTime : DateTimeUtil.ConvertDateTimeToInt(DateTime.Now), CreditAmount = customer.CreditAmount, Description = customer.Description, Name = customer.Name, OpenId = customer.OpenId, OpenType = customer.OpenType, RemainingAmount = customer.RemainingAmount, Token = Guid.NewGuid().ToString() }; db.Customer.Add(dbCus); } db.SaveChanges(); ret = true; } return(ret); }
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("请选择一行!"); } }