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 = ""; } }
private void txtCode_Leave(object sender, EventArgs e) { //判断编号是否已存在 if (!string.IsNullOrEmpty(txtCode.Text.Trim())) { BaseCustomerTable CustomerCode = new BaseCustomerTable(); CustomerCode = bCustomer.GetModel(txtCode.Text); if (CustomerCode != null) { txtCode.Focus(); txtCode.Text = ""; MessageBox.Show("编号已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
/// <summary> /// 获得当前选中的数据 /// </summary> private void GetCurrentSelectedTable() { try { string code = dgvData.SelectedRows[0].Cells[0].Value.ToString(); if (code != "") { _currentCustomerTable = bCustomer.GetModel(code); } } catch (Exception ex) { } if (_currentCustomerTable == null || _currentCustomerTable.CODE == null || "".Equals(_currentCustomerTable.CODE)) { _currentCustomerTable = null; } }
/// <summary> /// 导出 /// </summary> private void btnExport_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtCompanyCode.Text)) { MessageBox.Show("请选择公司。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (string.IsNullOrEmpty(txtFilePath.Text)) { MessageBox.Show("请选择保存路径。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } BaseCompanyTable companyTable = bCompany.GetModel(txtCompanyCode.Text.Trim()); BllOrderHeaderTable orderTable = bOrderH.GetModel(_slipNumber); BaseCustomerTable customerTable = bCustomer.GetModel(orderTable.ENDER_CUSTOMER_CODE); report.Preview = previewControl1; DataTable dt = new DataTable(); dt.TableName = "ds"; dt.Columns.Add("i", System.Type.GetType("System.Decimal")); dt.Columns.Add("SPEC", System.Type.GetType("System.String")); dt.Columns.Add("QUANTITY", System.Type.GetType("System.Decimal")); dt.Columns.Add("PRICE", System.Type.GetType("System.Decimal")); dt.Columns.Add("DISCOUNT", System.Type.GetType("System.Decimal")); dt.Columns.Add("AMOUNT", System.Type.GetType("System.Decimal")); dt.Columns.Add("MATERIAL", System.Type.GetType("System.String")); dt.Columns.Add("MEMO", System.Type.GetType("System.String")); dt.Columns.Add("DESCRIPTION", System.Type.GetType("System.String")); dt.Columns.Add("DESCRIPTION1", System.Type.GetType("System.String")); int j = 1; foreach (BllOrderLineTable lineModel in orderTable.Items) { if (lineModel.PRICE_DISCOUNT.ToString().Equals("0.00")) { object[] rows = { j++, lineModel.SPEC, lineModel.QUANTITY, lineModel.PRICE, null, lineModel.AMOUNT, lineModel.METERIAL, lineModel.MEMO, lineModel.DESCRIPTION, lineModel.DESCRIPTION1 }; dt.Rows.Add(rows); } else { object[] rows = { j++, lineModel.SPEC, lineModel.QUANTITY, lineModel.PRICE, 0 - lineModel.PRICE_DISCOUNT, lineModel.AMOUNT, lineModel.METERIAL, lineModel.MEMO, lineModel.DESCRIPTION, lineModel.DESCRIPTION1 }; dt.Rows.Add(rows); } } DataSet ds = new DataSet(); ds.Tables.Add(dt); string fileName = ""; string amountName = ""; if (CConstant.LANGUAGE_CN.Equals(cboLanguage.SelectedValue)) { fileName = @"Reports\Proforma_Invoice.frx"; amountName = NumberConvert.NumberToEnglish(CConvert.ToString(orderTable.AMOUNT_INCLUDED_TAX), false); } else if (CConstant.LANGUAGE_EN.Equals(cboLanguage.SelectedValue)) { fileName = @"Reports\Order_EN.frx"; amountName = NumberConvert.NumberToEnglish(CConvert.ToString(orderTable.AMOUNT_INCLUDED_TAX), false); } try { if (File.Exists(fileName)) { report.Load(fileName); report.SetParameterValue("CompanyName", companyTable.NAME); report.SetParameterValue("EnglishCompanyName", companyTable.NAME_ENGLISH); report.SetParameterValue("CompanyTel", companyTable.PHONE_NUMBER); report.SetParameterValue("CompanyFax", companyTable.FAX_NUMBER); report.SetParameterValue("CompanyAddress", companyTable.ADDRESS_MIDDLE); report.SetParameterValue("CompanyUrl", companyTable.URL); report.SetParameterValue("CompanyEmail", companyTable.EMAIL); report.SetParameterValue("SlipNumber", _slipNumber); report.SetParameterValue("SlipDate", CConvert.ToDateTime(orderTable.SLIP_DATE).ToString("yyyy/MM/dd")); report.SetParameterValue("Currency", orderTable.CURRENCY_NAME); report.SetParameterValue("CustomerName", customerTable.NAME); int COUNT = 0; foreach (DataRow dr in ds.Tables[0].Rows) { if (dr["DISCOUNT"].ToString() != "") { COUNT++; } } if (COUNT > 0) { report.SetParameterValue("DISCOUNT", "Discount"); } if (customerTable.PHONE_NUMBER.ToString() != "") { report.SetParameterValue("CustomerTel", "Tel:" + customerTable.PHONE_NUMBER); } if (customerTable.FAX_NUMBER.ToString() != "") { report.SetParameterValue("CustomerFax", "Fax:" + customerTable.FAX_NUMBER); } if (customerTable.ADDRESS_FIRST.ToString() != "") { report.SetParameterValue("CustomerAddress", "Address:" + customerTable.ADDRESS_FIRST); } report.SetParameterValue("CustomerMessage", txtMessage.Text); report.SetParameterValue("DeliveryTerms", orderTable.DELIVERY_TERMS); report.SetParameterValue("PaymentTerms", orderTable.PAYMENT_TERMS); if (orderTable.DISCOUNT_RATE > 0) { report.SetParameterValue("DiscountRate", "-" + orderTable.DISCOUNT_RATE + "%"); report.SetParameterValue("DiscountAmount", orderTable.AMOUNT_INCLUDED_TAX); } report.SetParameterValue("AmountName", amountName); report.SetParameterValue("FullNameEn", txtBankEn.Text); report.SetParameterValue("DetailEn", rtxtDetail.Text); if (companyTable.COMPANY_PICTURE != null) { MemoryStream ms = new MemoryStream((byte[])companyTable.COMPANY_PICTURE); Image image = Image.FromStream(ms); ((FastReport.PictureObject)report.FindObject("CompanyPicture")).Image = image; } if (companyTable.LOGO != null) { MemoryStream ms1 = new MemoryStream((byte[])companyTable.LOGO); Image image1 = Image.FromStream(ms1); ((FastReport.PictureObject)report.FindObject("Logo")).Image = image1; } report.RegisterData(ds); report.Prepare(); if (fileName.Equals(@"Reports\Proforma_Invoice.frx")) { report.Export(new FastReport.Export.Pdf.PDFExport(), this.txtFilePath.Text + "\\Proforma_Invoice" + _slipNumber + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf"); } else { report.Export(new FastReport.Export.Pdf.PDFExport(), this.txtFilePath.Text + "\\Order_" + _slipNumber + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf"); } MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } catch (Exception ex) { Logger.Error("", ex); } }
private void FrmCustomerDialog_Load(object sender, EventArgs e) { if (_currentCustomerTable != null) { txtCode.Text = _currentCustomerTable.CODE; txtName.Text = _currentCustomerTable.NAME; txtNameShort.Text = _currentCustomerTable.NAME_SHORT; txtEnglishName.Text = _currentCustomerTable.NAME_ENGLISH; txtZipCode.Text = _currentCustomerTable.ZIP_CODE; txtAddressFirst.Text = _currentCustomerTable.ADDRESS_FIRST; txtAddressMiddle.Text = _currentCustomerTable.ADDRESS_MIDDLE; txtAddressLast.Text = _currentCustomerTable.ADDRESS_LAST; txtPhone.Text = _currentCustomerTable.PHONE_NUMBER; txtFax.Text = _currentCustomerTable.FAX_NUMBER; txtMobilNumber.Text = _currentCustomerTable.MOBIL_NUMBER; txtContactName.Text = _currentCustomerTable.CONTACT_NAME; txtEmail.Text = _currentCustomerTable.EMAIL; txtURL.Text = _currentCustomerTable.URL; txtMemo.Text = _currentCustomerTable.MEMO; txtMemo2.Text = _currentCustomerTable.MEMO2; txtClaimCode.Text = _currentCustomerTable.CLAIM_CODE; BaseCustomerTable customerTable = bCustomer.GetModel(txtClaimCode.Text); txtClaimName.Text = customerTable.NAME; txtCurrencyCode.Text = _currentCustomerTable.CURRENCE_CODE; txtCurrencyName.Text = _currentCustomerTable.CURRENCE_NAME; txtName_Japan.Text = _currentCustomerTable.NAME_JP; if (_currentCustomerTable.TYPE == 1) { rType1.Checked = true; } else { rType2.Checked = true; } if (_currentCustomerTable.CLAIM_FLAG == 1) { rClaim1.Checked = true; } else { rClaim2.Checked = true; txtClaimCode.Enabled = true; } } if (_mode == CConstant.MODE_NEW) { this.Text = "新建"; btnClaim.Enabled = false; txtClaimCode.Enabled = false; txtClaimName.Enabled = false; } else if (_mode == CConstant.MODE_MODIFY) { this.Text = "编辑"; txtCode.BackColor = Color.WhiteSmoke; txtCode.Enabled = false; } else if (_mode == CConstant.MODE_COPY) { this.Text = "新建"; txtCode.Text = ""; } }