예제 #1
0
        /// <summary>
        /// 报价单数据初始化
        /// </summary>
        private void initData()
        {
            BllQuotationTable QTTable = bQuotation.GetModel(_oldSlipNumber);

            this.txtSlipNumber.Text   = QTTable.SLIP_NUMBER;
            this.txtCustomerCode.Text = QTTable.CUSTOMER_CODE;
            this.txtCustomerName.Text = QTTable.CUSTOMER_NAME;
            this.txtSlipDate.Text     = string.Format("{0:d}", QTTable.SLIP_DATE);
            //foreach (DataRow dr in CCacheData.Taxation.Rows)
            //{
            //    if (CConvert.ToDecimal(dr["TAX_RATE"]) == CConvert.ToDecimal(QTTable.TAX_RATE) * 100)
            //    {
            //        this.cboTax.SelectedValue = dr["CODE"];
            //        break;
            //    }
            //}
            this.txtdiscountrate.Text      = QTTable.DISCOUNT_RATE.ToString();
            this.txtEnquiryMethod.Text     = QTTable.ENQUIRY_METHOD;
            this.txtEnquiryDate.Text       = QTTable.ENQUIRY_DATE.ToString();
            this.txtDeliveryPeriod.Text    = QTTable.DELIVERY_PERIOD;
            this.txtDeliveryTerms.Text     = QTTable.DELIVERY_TERMS;
            this.txtPaymentTerms.Text      = QTTable.PAYMENT_TERMS;
            this.txtver.Text               = QTTable.VER;
            this.cboCurrency.SelectedValue = QTTable.CURRENCY_CODE;
            this.txtPaymentTerms.Text      = QTTable.PAYMENT_TERMS;
            this.txtMemo.Text              = QTTable.MEMO;
            //this.txtAmountIncludedTax.Text = string.Format("{0:N2}", QTTable.AMOUNT_INCLUDED_TAX);
            this.txtTotal.Text = string.Format("{0:N2}", QTTable.AMOUNT_INCLUDED_TAX);
            //this.txtTaxAmount.Text = string.Format("{0:N2}", QTTable.TAX_AMOUNT);
            this.rtxtMemo.Text = QTTable.TO_CUSTOMER_MEMO;
            foreach (BllQuotationLineTable lineModel in QTTable.Items)
            {
                int             currentRowIndex = dgvData.Rows.Add(1);
                DataGridViewRow row             = dgvData.Rows[currentRowIndex];
                row.Cells["CODE"].Value                      = lineModel.PRODUCT_CODE;
                row.Cells["NAME"].Value                      = lineModel.PRODUCT_NAME;
                row.Cells["DESCRIPTION"].Value               = lineModel.DESCRIPTION;
                row.Cells["PRICE_DISCOUNT"].Value            = lineModel.PRICE_DISCOUNT;
                row.Cells["QUANTITY"].Value                  = lineModel.QUANTITY;
                row.Cells["SPEC"].Value                      = lineModel.SPEC;
                row.Cells["PRICE"].Value                     = lineModel.PRICE;
                row.Cells["AMOUNT"].Value                    = lineModel.AMOUNT;
                row.Cells["MEMO"].Value                      = lineModel.MEMO;
                row.Cells["METERIAL"].Value                  = lineModel.METERIAL;
                row.Cells["COMPOSITION_PRODUCTS_CODE"].Value = lineModel.PARTS_CODE;
                row.Cells["COMPOSITION_PRODUCTS_NAME"].Value = lineModel.COMPOSITION_PRODUCTS_NAME;
                row.Cells["DESCRIPTION1"].Value              = lineModel.DESCRIPTION1;
                // bool b = CConvert.ToBoolean(row.Cells["COMPOSITION_PRODUCTS_CODE"].Value);
                if (lineModel.PARTS_CODE != "")
                {
                    row.Cells["checkboxflag"].Value = true;
                }
                else
                {
                    row.Cells["checkboxflag"].Value = false;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 数据保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!CheckHeaderInput())
            {
                return;
            }

            if (!CheckLineInput())
            {
                return;
            }

            BllQuotationTable     QTTable = new BllQuotationTable();
            BllQuotationLineTable QLTable = null;

            //报价单类型
            QTTable.SLIP_TYPE = "";
            //报价单编号
            QTTable.SLIP_NUMBER = txtSlipNumber.Text.Trim();
            //客户
            QTTable.CUSTOMER_CODE   = txtCustomerCode.Text.Trim();
            QTTable.DISCOUNT_RATE   = CConvert.ToDecimal(txtdiscountrate.Text.Trim());
            QTTable.ENQUIRY_METHOD  = txtEnquiryMethod.Text.Trim();
            QTTable.ENQUIRY_DATE    = CConvert.ToDateTime(txtEnquiryDate.Text.Trim());
            QTTable.DELIVERY_PERIOD = txtDeliveryPeriod.Text.Trim();
            QTTable.DELIVERY_TERMS  = txtDeliveryTerms.Text.Trim();
            QTTable.PAYMENT_TERMS   = txtPaymentTerms.Text.Trim();
            if ((txtver.Text.Trim()).Equals(""))
            {
                QTTable.VER = "1";
            }
            else
            {
                QTTable.VER = txtver.Text.Trim();
            }
            QTTable.UPDATE_COUNT = 0;
            //出库仓库
            //QTTable.DEPARTUAL_WAREHOUSE_CODE = CConstant.DEFAULT_WAREHOUSE_CODE;
            //报价单日期
            QTTable.SLIP_DATE = txtSlipDate.Value;
            //货币
            QTTable.CURRENCY_CODE = cboCurrency.SelectedValue.ToString();
            //QTTable.CURRENCY_CODE = CConstant.DEFAULT_CURRENCY_CODE;
            //备注
            QTTable.MEMO = txtMemo.Text.Trim();
            //状态 OR 出库状况
            QTTable.STATUS_FLAG = CConstant.UN_SHIPMENT;
            //含税金额
            QTTable.AMOUNT_INCLUDED_TAX = CConvert.ToDecimal(txtTotal.Text.Trim());
            //税金
            //QTTable.TAX_AMOUNT = CConvert.ToDecimal(txtTaxAmount.Text.Trim());
            //税后金额
            //QTTable.DISCOUNT_AMOUNT = CConvert.ToDecimal(txtTotal.Text.Trim());
            //销售人员
            QTTable.SALES_EMPLOYEE_CODE = UserTable.CODE;
            //创建人
            QTTable.CREATE_USER = UserTable.CODE;
            //最后更新人
            QTTable.LAST_UPDATE_USER = UserTable.CODE;
            //公司编号
            QTTable.COMPANY_CODE = UserTable.COMPANY_CODE;
            //税率
            //QTTable.TAX_RATE = CConvert.ToDecimal(cboTax.Text.Replace("%", "")) / 100;
            QTTable.QUANTITY = 1;


            // QTTable.ORDER_FLAG = 0;
            if (attachedNumber > 0)
            {
                QTTable.ORDER_FLAG = CConstant.EXIST_ATTACHED;
            }
            else
            {
                QTTable.ORDER_FLAG = CConstant.NO_ATTACHED;
            }

            QTTable.PAYMENT_CONDITION = txtPaymentTerms.Text;
            // QTTable.DISCOUNT_AMOUNT = CConvert.ToDecimal(txtAmountIncludedTax.Text.Trim()) / 100 * (100 - CConvert.ToDecimal(txtdiscountrate.Text.Trim()));
            //客户备注
            QTTable.TO_CUSTOMER_MEMO = rtxtMemo.Text;

            //明细的整理
            foreach (DataGridViewRow row in dgvData.Rows)
            {
                if (row.Index + 1 == dgvData.Rows.Count)
                {
                    break;
                }
                QLTable             = new BllQuotationLineTable();
                QLTable.SLIP_NUMBER = QTTable.SLIP_NUMBER;
                //明细编号
                QLTable.LINE_NUMBER = row.Index + 1;
                //商品编号
                QLTable.PRODUCT_CODE = CConvert.ToString(row.Cells["CODE"].Value);

                QLTable.DESCRIPTION    = CConvert.ToString(row.Cells["DESCRIPTION"].Value);
                QLTable.DESCRIPTION1   = CConvert.ToString(row.Cells["DESCRIPTION1"].Value);
                QLTable.SPEC           = CConvert.ToString(row.Cells["SPEC"].Value);
                QLTable.PRICE_DISCOUNT = CConvert.ToDecimal(row.Cells["PRICE_DISCOUNT"].Value);;

                // 数量
                QLTable.QUANTITY = CConvert.ToDecimal(QTTable.QUANTITY * CConvert.ToDecimal(row.Cells["QUANTITY"].Value.ToString()));
                //单位编号
                QLTable.UNIT_CODE = "01";
                //单价
                QLTable.PRICE = CConvert.ToDecimal(row.Cells["PRICE"].Value);
                //金额
                QLTable.AMOUNT = CConvert.ToDecimal(row.Cells["AMOUNT"].Value);
                //货币编号
                //QLTable.CURRENCY_CODE = CConstant.DEFAULT_CURRENCY_CODE;
                //备注
                QLTable.MEMO = CConvert.ToString(row.Cells["MEMO"].Value);
                //明细状态
                QLTable.STATUS_FLAG = CConstant.INIT;
                QLTable.METERIAL    = CConvert.ToString(row.Cells["METERIAL"].Value);
                QLTable.PARTS_CODE  = CConvert.ToString(row.Cells["COMPOSITION_PRODUCTS_CODE"].Value);

                if (QLTable.PRODUCT_CODE != "")
                {
                    QTTable.AddItem(QLTable);
                }
            }

            int result = 0;

            //if (CConvert.ToDecimal(txtAmountIncludedTax.Text) == 0)
            //{
            //    if (MessageBox.Show("【警告】含税金额为0;", "报价单保存提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) != DialogResult.OK)
            //    {
            //        return;
            //    }
            //}
            if (String.IsNullOrEmpty(_oldSlipNumber))
            {
                try
                {
                    string slipNumber = bQuotation.Add(QTTable);
                    if (slipNumber == null)
                    {
                        MessageBox.Show("报价单保存失败,请重试或与管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        Czzd.Common.Library.FTPOperate myftp = new Czzd.Common.Library.FTPOperate("112.82.245.2", "YS_ERP\\quotation", "FTP_user", "czzd", 21);
                        myftp.MkDir(slipNumber);
                        Czzd.Common.Library.FTPOperate myftp1 = new Czzd.Common.Library.FTPOperate("112.82.245.2", "YS_ERP\\quotation\\" + slipNumber, "FTP_user", "czzd", 21);
                        if (Directory.Exists(_attachedDirectory + _tmpAttachedDirectoryName))
                        {
                            DirectoryInfo di    = new DirectoryInfo(_attachedDirectory + _tmpAttachedDirectoryName);
                            FileInfo[]    files = di.GetFiles();

                            foreach (FileInfo file in files)
                            {
                                myftp1.Put("\\YY模具\\bin\\quotation\\" + _tmpAttachedDirectoryName + "\\" + file);
                            }

                            if (di.Exists)
                            {
                                DirectoryInfo[] childs = di.GetDirectories();
                                foreach (DirectoryInfo child in childs)
                                {
                                    child.Delete(true);
                                }
                                di.Delete(true);
                            }
                        }

                        MessageBox.Show("报价单保存成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        initPage();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    MessageBox.Show("报价单保存失败,请重试或与管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Logger.Error("新建报价单保存失败。", ex);
                }
            }
            else if (CConstant.QUOTATION_MODIFY.Equals(CTag)) //报价单修正
            {
                BllQuotationTable oldQLTable = bQuotation.GetModel(_oldSlipNumber);

                QTTable.UPDATE_COUNT = oldQLTable.UPDATE_COUNT + 1;
                try
                {
                    result = bQuotation.Update(QTTable);
                    if (result <= 0)
                    {
                        MessageBox.Show("报价单保存失败,请重试或与管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("报价单保存成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        initPage();
                        _dialogResult = DialogResult.OK;
                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("报价单保存失败,系统错误,请与管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Logger.Error("报价单修改保存失败。", ex);
                }
            }
        }
예제 #3
0
 public int Update(BllQuotationTable QuotationModel)
 {
     return(dal.Update(QuotationModel));
 }
예제 #4
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());
            BllQuotationTable quotationTable = bQuotation.GetModel(_slipNumber);
            BaseCustomerTable customerTable  = bCustomer.GetModel(quotationTable.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 (BllQuotationLineTable lineModel in quotationTable.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\Quotation_CN.frx";
                amountName = NumberConvert.NumberToChinese(CConvert.ToDouble(quotationTable.AMOUNT_INCLUDED_TAX));
            }
            else if (CConstant.LANGUAGE_EN.Equals(cboLanguage.SelectedValue))
            {
                fileName   = @"Reports\Quotation_EN.frx";
                amountName = NumberConvert.NumberToEnglish(CConvert.ToString(quotationTable.AMOUNT_INCLUDED_TAX), false);
            }
            int COUNT = 0;

            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);
                    if (fileName.Equals(@"Reports\Quotation_CN.frx"))
                    {
                        report.SetParameterValue("CompanyAddress", companyTable.ADDRESS_FIRST);
                    }
                    else
                    {
                        report.SetParameterValue("CompanyAddress", companyTable.ADDRESS_MIDDLE);
                    }

                    report.SetParameterValue("CompanyUrl", companyTable.URL);
                    report.SetParameterValue("CompanyEmail", companyTable.EMAIL);
                    report.SetParameterValue("SlipNumber", _slipNumber + "R" + quotationTable.VER);
                    report.SetParameterValue("Currency", quotationTable.CURRENCY_NAME);
                    report.SetParameterValue("CustomerName", customerTable.NAME);

                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        if (dr["DISCOUNT"].ToString() != "")
                        {
                            COUNT++;
                        }
                    }
                    if (COUNT > 0)
                    {
                        if (fileName.Equals(@"Reports\Quotation_CN.frx"))
                        {
                            report.SetParameterValue("DISCOUNT", "折扣");
                        }
                        else
                        {
                            report.SetParameterValue("DISCOUNT", "Discount");
                        }
                    }
                    if (!customerTable.PHONE_NUMBER.ToString().Equals(""))
                    {
                        if (fileName.Equals(@"Reports\Quotation_CN.frx"))
                        {
                            report.SetParameterValue("CustomerTel", "电话:" + customerTable.PHONE_NUMBER);
                        }
                        else
                        {
                            report.SetParameterValue("CustomerTel", "Tel:" + customerTable.PHONE_NUMBER);
                        }
                    }
                    if (!customerTable.FAX_NUMBER.ToString().Equals(""))
                    {
                        if (fileName.Equals(@"Reports\Quotation_CN.frx"))
                        {
                            report.SetParameterValue("CustomerFax", "传真:" + customerTable.FAX_NUMBER);
                        }
                        else
                        {
                            report.SetParameterValue("CustomerFax", "Fax:" + customerTable.FAX_NUMBER);
                        }
                    }
                    if (!customerTable.ADDRESS_FIRST.ToString().Equals(""))
                    {
                        if (fileName.Equals(@"Reports\Quotation_CN.frx"))
                        {
                            report.SetParameterValue("CustomerAddress", "地址:" + customerTable.ADDRESS_FIRST);
                        }
                        else
                        {
                            report.SetParameterValue("CustomerAddress", "Address:" + customerTable.ADDRESS_FIRST);
                        }
                    }
                    report.SetParameterValue("EnquiryMethod", quotationTable.ENQUIRY_METHOD);
                    report.SetParameterValue("EnquiryDate", CConvert.ToDateTime(quotationTable.ENQUIRY_DATE).ToString("yyyy/MM/dd"));
                    report.SetParameterValue("DeliveryPeriod", quotationTable.DELIVERY_PERIOD);
                    report.SetParameterValue("DeliveryTerms", quotationTable.DELIVERY_TERMS);
                    report.SetParameterValue("PaymentTerms", quotationTable.PAYMENT_TERMS);
                    if (quotationTable.DISCOUNT_RATE > 0)
                    {
                        report.SetParameterValue("DiscountRate", "-" + quotationTable.DISCOUNT_RATE + "%");
                        report.SetParameterValue("DiscountAmount", quotationTable.AMOUNT_INCLUDED_TAX);
                    }
                    report.SetParameterValue("AmountName", amountName);
                    report.SetParameterValue("ToCustomerMemo", quotationTable.TO_CUSTOMER_MEMO);

                    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\Quotation_CN.frx"))
                    {
                        report.Export(new FastReport.Export.Pdf.PDFExport(), this.txtFilePath.Text + "\\Quotation_CN" + _slipNumber + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf");
                    }
                    else
                    {
                        report.Export(new FastReport.Export.Pdf.PDFExport(), this.txtFilePath.Text + "\\Quotation_EN" + _slipNumber + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf");
                    }
                    MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                Logger.Error("", ex);
            }
        }
예제 #5
0
 public string Add(BllQuotationTable model)
 {
     return(dal.Add(model));
 }