示例#1
0
 private void txtCompanyCode_Leave(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(this.txtCompanyCode.Text.Trim()))
     {
         BaseCompanyTable Company  = new BaseCompanyTable();
         BCompany         bCompany = new BCompany();
         Company = bCompany.GetModel(this.txtCompanyCode.Text);
         if (Company == null || "".Equals(Company))
         {
             txtCompanyCode.Focus();
             txtCompanyCode.Text = "";
             txtCompanyName.Text = "";
             MessageBox.Show("公司编号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             txtCompanyCode.Text = Company.CODE;
             txtCompanyName.Text = Company.NAME;
         }
     }
     else
     {
         txtCompanyName.Text = "";
     }
 }
示例#2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CZZD.ERP.Model.BaseCompanyTable GetModel(string CODE)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 CODE,NAME,NAME_SHORT,NAME_ENGLISH,ZIP_CODE,ADDRESS_FIRST,ADDRESS_MIDDLE,ADDRESS_LAST,PHONE_NUMBER,FAX_NUMBER,EMAIL,URL,MEMO,STATUS_FLAG,CREATE_USER,CREATE_DATE_TIME,LAST_UPDATE_USER,LAST_UPDATE_TIME from BASE_COMPANY ");
            strSql.Append(" where CODE=@CODE ");
            strSql.AppendFormat(" and STATUS_FLAG <> {0}", CConstant.DELETE_STATUS);
            SqlParameter[] parameters =
            {
                new SqlParameter("@CODE", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = CODE;

            BaseCompanyTable model = new BaseCompanyTable();
            DataSet          ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                model.CODE           = ds.Tables[0].Rows[0]["CODE"].ToString();
                model.NAME           = ds.Tables[0].Rows[0]["NAME"].ToString();
                model.NAME_SHORT     = ds.Tables[0].Rows[0]["NAME_SHORT"].ToString();
                model.NAME_ENGLISH   = ds.Tables[0].Rows[0]["NAME_ENGLISH"].ToString();
                model.ZIP_CODE       = ds.Tables[0].Rows[0]["ZIP_CODE"].ToString();
                model.ADDRESS_FIRST  = ds.Tables[0].Rows[0]["ADDRESS_FIRST"].ToString();
                model.ADDRESS_MIDDLE = ds.Tables[0].Rows[0]["ADDRESS_MIDDLE"].ToString();
                model.ADDRESS_LAST   = ds.Tables[0].Rows[0]["ADDRESS_LAST"].ToString();
                model.PHONE_NUMBER   = ds.Tables[0].Rows[0]["PHONE_NUMBER"].ToString();
                model.FAX_NUMBER     = ds.Tables[0].Rows[0]["FAX_NUMBER"].ToString();
                model.EMAIL          = ds.Tables[0].Rows[0]["EMAIL"].ToString();
                model.URL            = ds.Tables[0].Rows[0]["URL"].ToString();
                model.MEMO           = ds.Tables[0].Rows[0]["MEMO"].ToString();
                if (ds.Tables[0].Rows[0]["STATUS_FLAG"].ToString() != "")
                {
                    model.STATUS_FLAG = int.Parse(ds.Tables[0].Rows[0]["STATUS_FLAG"].ToString());
                }
                model.CREATE_USER = ds.Tables[0].Rows[0]["CREATE_USER"].ToString();
                if (ds.Tables[0].Rows[0]["CREATE_DATE_TIME"].ToString() != "")
                {
                    model.CREATE_DATE_TIME = DateTime.Parse(ds.Tables[0].Rows[0]["CREATE_DATE_TIME"].ToString());
                }
                model.LAST_UPDATE_USER = ds.Tables[0].Rows[0]["LAST_UPDATE_USER"].ToString();
                if (ds.Tables[0].Rows[0]["LAST_UPDATE_TIME"].ToString() != "")
                {
                    model.LAST_UPDATE_TIME = DateTime.Parse(ds.Tables[0].Rows[0]["LAST_UPDATE_TIME"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        /// <summary>
        /// 获得当前选中的数据
        /// </summary>
        private void GetCurrentSelectedTable()
        {
            try
            {
                string code = dgvData.SelectedRows[0].Cells[0].Value.ToString();
                if (code != "")
                {
                    _currentCompanyTable = bCompany.GetModel(code);
                }
            }
            catch (Exception ex) { }

            if (_currentCompanyTable == null || _currentCompanyTable.CODE == null || "".Equals(_currentCompanyTable.CODE))
            {
                _currentCompanyTable = null;
            }
        }
示例#4
0
        /// <summary>
        /// 保存
        /// </summary>
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                if (_currentCompanyTable == null)
                {
                    _currentCompanyTable = new BaseCompanyTable();
                }
                _currentCompanyTable.CODE             = txtCode.Text.Trim().PadLeft(2, '0');
                _currentCompanyTable.NAME             = txtName.Text;
                _currentCompanyTable.NAME_SHORT       = txtNameShort.Text;
                _currentCompanyTable.NAME_ENGLISH     = txtEnglishName.Text;
                _currentCompanyTable.ZIP_CODE         = txtZipCode.Text;
                _currentCompanyTable.ADDRESS_FIRST    = txtAddressFirst.Text;
                _currentCompanyTable.ADDRESS_MIDDLE   = txtAddressMiddle.Text;
                _currentCompanyTable.ADDRESS_LAST     = txtAddressLast.Text;
                _currentCompanyTable.PHONE_NUMBER     = txtPhone.Text;
                _currentCompanyTable.FAX_NUMBER       = txtFax.Text;
                _currentCompanyTable.EMAIL            = txtEmail.Text;
                _currentCompanyTable.URL              = txtURL.Text;
                _currentCompanyTable.MEMO             = txtMemo.Text;
                _currentCompanyTable.LAST_UPDATE_USER = _userInfo.CODE;

                try
                {
                    if (bCompany.Exists(txtCode.Text.Trim()))
                    {
                        bCompany.Update(_currentCompanyTable);
                    }
                    else
                    {
                        _currentCompanyTable.CREATE_USER = _userInfo.CODE;
                        bCompany.Add(_currentCompanyTable);
                    }
                }
                catch (Exception ex)
                {
                    //log.error
                    MessageBox.Show("");
                    return;
                }
                result = DialogResult.OK;
                this.Close();
                CCacheData.Company = null;
            }
        }
示例#5
0
 private void txtCode_Leave(object sender, EventArgs e)
 {
     //判断编号是否已存在
     if (!string.IsNullOrEmpty(this.txtCode.Text.Trim()))
     {
         if (txtCode.Text.Trim().Length < 2)
         {
             txtCode.Text = txtCode.Text.Trim().PadLeft(2, '0');
         }
         BaseCompanyTable CompanyCode = new BaseCompanyTable();
         CompanyCode = bCompany.GetModel(txtCode.Text.Trim());
         if (CompanyCode != null)
         {
             txtCode.Focus();
             txtCode.Text = "";
             MessageBox.Show("编号已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }
示例#6
0
 /// <summary>
 /// 打开新窗口
 /// </summary>
 private void OpenDialogFrm(int mode)
 {
     if (mode == CConstant.MODE_NEW || _currentCompanyTable != null)
     {
         FrmCompanyDialog frm = new FrmCompanyDialog();
         frm.UserInfo            = _userInfo;
         frm.CurrentCompanyTable = _currentCompanyTable;
         frm.Mode = mode;
         DialogResult resule = frm.ShowDialog(this);
         if (resule == DialogResult.OK && isSearch)
         {
             Search(this.pgControl.GetCurrentPage());
         }
         frm.Dispose();
     }
     else
     {
         //MessageBox.Show("请选择正确的行!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     _currentCompanyTable = null;
 }
示例#7
0
 /// <summary>
 /// 删除
 /// </summary>
 private void MasterToolBar_DoDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("确定要删除吗?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.OK)
     {
         try
         {
             GetCurrentSelectedTable();
             if (_currentCompanyTable != null)
             {
                 bCompany.Delete(_currentCompanyTable.CODE);
                 Search(this.pgControl.GetCurrentPage());
             }
             else
             {
                 MessageBox.Show("请选择正确的行!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("删除失败,请重试或与系统管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         _currentCompanyTable = null;
     }
 }
示例#8
0
        /// <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);
            }
        }
示例#9
0
文件: BCompany.cs 项目: zhr008/ERP-1
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(BaseCompanyTable model)
 {
     return(dal.Update(model));
 }
示例#10
0
文件: BCompany.cs 项目: zhr008/ERP-1
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(BaseCompanyTable model)
 {
     return(dal.Add(model));
 }
示例#11
0
        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("请选择一行!");
            }
        }
示例#12
0
 /// <summary>
 /// 保存
 /// </summary>
 private void btnSave_Click_1(object sender, EventArgs e)
 {
     if (CheckInput())
     {
         if (_currentCompanyTable == null)
         {
             _currentCompanyTable = new BaseCompanyTable();
         }
         _currentCompanyTable.CODE             = txtCode.Text.Trim().PadLeft(2, '0');
         _currentCompanyTable.NAME             = txtName.Text.Trim();
         _currentCompanyTable.NAME_SHORT       = txtNameShort.Text.Trim();
         _currentCompanyTable.NAME_ENGLISH     = txtEnglishName.Text.Trim();
         _currentCompanyTable.ZIP_CODE         = txtZipCode.Text.Trim();
         _currentCompanyTable.ADDRESS_FIRST    = txtAddressFirst.Text.Trim();
         _currentCompanyTable.ADDRESS_MIDDLE   = txtAddressMiddle.Text.Trim();
         _currentCompanyTable.ADDRESS_LAST     = txtAddressLast.Text.Trim();
         _currentCompanyTable.PHONE_NUMBER     = txtPhone.Text.Trim();
         _currentCompanyTable.FAX_NUMBER       = txtFax.Text.Trim();
         _currentCompanyTable.EMAIL            = txtEmail.Text.Trim();
         _currentCompanyTable.URL              = txtURL.Text.Trim();
         _currentCompanyTable.MEMO             = txtMemo.Text.Trim();
         _currentCompanyTable.LAST_UPDATE_USER = _userInfo.CODE;
         if (txtLogo.Text.ToString() != "")
         {
             string[]             sArray = Regex.Split(txtLogo.Text.Trim(), @"\\", RegexOptions.IgnoreCase);
             System.IO.FileStream fs     = new System.IO.FileStream(txtLogo.Text.Trim(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
             byte[] imgByte = new byte[fs.Length];
             fs.Read(imgByte, 0, (int)fs.Length);
             _currentCompanyTable.LOGO = imgByte;
         }
         if (txtCompanyPicture.Text.ToString() != "")
         {
             string[]             sArray = Regex.Split(txtCompanyPicture.Text.Trim(), @"\\", RegexOptions.IgnoreCase);
             System.IO.FileStream fs     = new System.IO.FileStream(txtCompanyPicture.Text.Trim(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
             byte[] imgByte = new byte[fs.Length];
             fs.Read(imgByte, 0, (int)fs.Length);
             _currentCompanyTable.COMPANY_PICTURE = imgByte;
         }
         try
         {
             if (bCompany.Exists(txtCode.Text.Trim()))
             {
                 bCompany.Update(_currentCompanyTable);
             }
             else
             {
                 _currentCompanyTable.CREATE_USER = _userInfo.CODE;
                 bCompany.Add(_currentCompanyTable);
             }
         }
         catch (Exception ex)
         {
             //log.error
             MessageBox.Show("");
             return;
         }
         result = DialogResult.OK;
         this.Close();
         CCacheData.Company = null;
     }
 }