예제 #1
0
        /// <summary>
        /// 附件上传载
        /// </summary>
        private void btnUpLoad_Click(object sender, EventArgs e)
        {
            if (CConstant.ORDER_MODIFY.Equals(CTag))
            {
                Czzd.Common.Library.FTPOperate myftp = new Czzd.Common.Library.FTPOperate("112.82.245.2", "YS_ERP\\order\\" + _slipNumber, "FTP_user", "czzd", 21);

                OpenFileDialog of = new OpenFileDialog();
                if (DialogResult.OK == of.ShowDialog(this))
                {
                    string[] files = myftp.Dir("\\YS_ERP\\order\\" + _slipNumber);
                    foreach (string file in files)
                    {
                        if (file != "")
                        {
                            if (file.Substring(0, file.Length - 1).Equals(of.SafeFileName))
                            {
                                MessageBox.Show("文件己经存在,请确认!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                        }
                    }
                    myftp.Put(of.FileName);

                    MessageBox.Show("文件上传成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
            else
            {
                try
                {
                    OpenFileDialog of = new OpenFileDialog();
                    if (DialogResult.OK == of.ShowDialog(this))
                    {
                        if (!Directory.Exists(_fullPath))
                        {
                            Directory.CreateDirectory(_fullPath);
                        }
                        foreach (DataRow dr in _currentDt.Rows)
                        {
                            if (of.SafeFileName.Equals(dr["NAME"]))
                            {
                                MessageBox.Show("文件己经存在,请确认!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                        }

                        AddAttached(new FileInfo(of.FileName));

                        File.Copy(of.FileName, _fullPath + of.SafeFileName);
                    }
                }
                catch (IOException ex) { }
            }
        }
예제 #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
        private void btnUpLoad_Click(object sender, EventArgs e)
        {
            string _tmpAttachedDirectoryName = SLIPNUMBER;
            string _attachedDirectory        = CCacheData.GetAttacheDirectory(CConstant.ATTACHE_DIRECTORY_PRODUCTION);

            if (txtFileName.Text.Trim() == "")
            {
                MessageBox.Show("文件名不能为空!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }


            try
            {
                if (!Directory.Exists(_attachedDirectory + _tmpAttachedDirectoryName + "\\"))
                {
                    Directory.CreateDirectory(_attachedDirectory + _tmpAttachedDirectoryName + "\\");
                    //Directory.CreateDirectory(_attachedDirectory + _tmpAttachedDirectoryName);
                    Czzd.Common.Library.FTPOperate myftp = new Czzd.Common.Library.FTPOperate("112.82.245.2", "YS_ERP\\production", "FTP_user", "czzd", 21);
                    myftp.MkDir(_tmpAttachedDirectoryName);
                }
                foreach (DataRow dr in _currentDt.Rows)
                {
                    if (openFileDialog.SafeFileName.Equals(dr["NAME"]))
                    {
                        MessageBox.Show("文件己经存在,请确认!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
                AddAttached(new FileInfo(openFileDialog.FileName));
                File.Copy(openFileDialog.FileName, _attachedDirectory + _tmpAttachedDirectoryName + "\\" + openFileDialog.SafeFileName);



                if (Directory.Exists(_attachedDirectory + _tmpAttachedDirectoryName))
                {
                    DirectoryInfo di    = new DirectoryInfo(_attachedDirectory + _tmpAttachedDirectoryName);
                    FileInfo[]    files = di.GetFiles();
                    Czzd.Common.Library.FTPOperate myftp1 = new Czzd.Common.Library.FTPOperate("112.82.245.2", "YS_ERP\\production\\" + _tmpAttachedDirectoryName, "FTP_user", "czzd", 21);
                    foreach (FileInfo file in files)
                    {
                        myftp1.Put("\\YY模具\\bin\\production\\" + _tmpAttachedDirectoryName + "\\" + file);
                    }

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

            catch (IOException ex)
            { }
            int result = 0;

            productionDrawing.Items.Clear();
            for (int i = 0; i < this.clbDrawing.Items.Count; i++)
            {
                BaseProductionDrawingTable productionDrawing1 = new BaseProductionDrawingTable();

                if (clbDrawing.GetItemChecked(i))
                {
                    productionDrawing1.SLIPNUMBER = SLIPNUMBER;
                    string[] sArray = Regex.Split(txtFileName.Text.Trim(), @"\\", RegexOptions.IgnoreCase);

                    //productionDrawing1.FILENAME = txtFileName.Text.Trim();
                    //productionDrawing1.SERVERFILENAME = sArray[sArray.Length - 1];


                    productionDrawing1.FILENAME       = sArray[sArray.Length - 1];
                    productionDrawing1.SERVERFILENAME = sArray[sArray.Length - 1] + "_" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    clbDrawing.SelectedIndex          = i;
                    productionDrawing1.DRAWINGCODE    = clbDrawing.SelectedValue.ToString();

                    productionDrawing.AddItem(productionDrawing1);
                }
            }
            result = bProductionDrawing.Add(productionDrawing);
            if (result < 1)
            {
                MessageBox.Show("上传失败!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                MessageBox.Show("上传成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);

                txtFileName.Text = "";
                DataTable dt = new DataTable();
                clbDrawing.DataSource = dt;
                dgvData.DataSource    = dt;
                DataSet ds = bProductionDrawing.GetProductionDrawing(" PSDL_SLIP_NUMBER = '" + SLIPNUMBER + "'" + " AND PSDL_STATUS_FLAG= '0'");
                clbDrawing.DataSource    = ds.Tables[0];
                clbDrawing.ValueMember   = "PSDL_DRAWING_CODE";
                clbDrawing.DisplayMember = "NAME";
                DataSet dsUpload = bProductionDrawing.GetProductionDrawingUpload(" SLIP_NUMBER = '" + SLIPNUMBER + "'" + " AND DRAWING_CODE= '" + DRAWING_CODE + "'");
                dgvData.DataSource = dsUpload.Tables[0];
            }
        }