Ejemplo n.º 1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                if (_currentProductTable == null)
                {
                    _currentProductTable = new BaseProductTable();
                }
                _currentProductTable.CODE             = txtCode.Text.Trim();
                _currentProductTable.NAME             = txtName.Text.Trim();
                _currentProductTable.SPEC             = txtSpec.Text.Trim();
                _currentProductTable.GROUP_CODE       = txtGroupCode.Text.Trim();
                _currentProductTable.BASIC_UNIT_CODE  = txtUnitCode.Text.Trim();
                _currentProductTable.SALES_PRICE      = Convert.ToDecimal(txtPrice.Text.Trim());
                _currentProductTable.LAST_UPDATE_USER = _userInfo.CODE;
                _currentProductTable.PURCHASE_PRICE   = CConvert.ToDecimal(txtPurchase_Price.Text.Trim());
                _currentProductTable.SELL_LOCATION    = CConstant.PRODUCT_SELL_CHINA;
                _currentProductTable.PACKAGE_MODE     = CConstant.PRODUCT_PACKAGE_ALONT;
                _currentProductTable.SAFETY_STOCK     = CConvert.ToDecimal(txtSafetyStock.Text.Trim());
                _currentProductTable.PRODUCT_FLAG     = CConstant.PRODUCT_FLAG_PARTS;

                try
                {
                    bool ret = false;
                    if (bProduct.Exists(txtCode.Text.Trim()))
                    {
                        ret = bProduct.Update(_currentProductTable);
                    }
                    else
                    {
                        _currentProductTable.CREATE_USER = _userInfo.CODE;
                        ret = bProduct.Add(_currentProductTable);
                    }

                    if (ret)
                    {
                        result = DialogResult.OK;
                        if ("btnSaveAndNew".Equals(((Button)sender).Name))
                        {
                            ClearAll();
                        }
                        else
                        {
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("保存失败,请重试或与系统管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("保存失败,请重试或与系统管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Logger.Error("原料保存失败。", ex);
                    return;
                }
            }
        }
Ejemplo n.º 2
0
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                if (_currentProductTable == null)
                {
                    _currentProductTable = new BaseProductTable();
                }
                _currentProductTable.CODE            = txtCode.Text.Trim();
                _currentProductTable.NAME            = txtName.Text.Trim();
                _currentProductTable.SPEC            = txtSpec.Text.Trim();
                _currentProductTable.MODEL_NUMBER    = txtModelNumber.Text.Trim();
                _currentProductTable.GROUP_CODE      = txtGroupCode.Text.Trim();
                _currentProductTable.BASIC_UNIT_CODE = txtBasic.Text.Trim();
                //_currentProductTable.HS_CODE = txtHsCode.Text.Trim();
                _currentProductTable.SALES_PRICE                 = Convert.ToDecimal(txtPrice.Text.Trim());
                _currentProductTable.LAST_UPDATE_USER            = _userInfo.CODE;
                _currentProductTable.PURCHASE_PRICE              = CConvert.ToDecimal(txtPurchase_Price.Text.Trim());
                _currentProductTable.ACCOUTING_TARGET            = 1;
                _currentProductTable.STOCK_FLAG                  = 1;
                _currentProductTable.PROPERTY_FLAG               = 1;
                _currentProductTable.FROMSET_FLAG                = 1;
                _currentProductTable.MECHANICAL_DISTINCTION_FLAG = 1;
                _currentProductTable.SELL_LOCATION               = CConstant.PRODUCT_SELL_CHINA;
                _currentProductTable.PACKAGE_MODE                = CConstant.PRODUCT_PACKAGE_ALONT;
                //_currentProductTable.SUPPLIER_CODE = txtSupplierCode.Text;
                _currentProductTable.SAFETY_STOCK = CConvert.ToDecimal(txtSafetyStock.Text.Trim());

                try
                {
                    if (bProduct.Exists(txtCode.Text.Trim()))
                    {
                        bProduct.Update(_currentProductTable);
                    }
                    else
                    {
                        _currentProductTable.CREATE_USER = _userInfo.CODE;
                        bProduct.Add(_currentProductTable);
                    }
                }
                catch (Exception ex)
                {
                    //log.error
                    MessageBox.Show("");
                    return;
                }
                result = DialogResult.OK;
                this.Close();
            }
        }
Ejemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                if (_currentProductTable == null)
                {
                    _currentProductTable = new BaseProductTable();
                }
                _currentProductTable.CODE             = txtCode.Text.Trim();
                _currentProductTable.NAME             = txtName.Text.Trim();
                _currentProductTable.SPEC             = txtSpec.Text.Trim();
                _currentProductTable.BASIC_UNIT_CODE  = txtUnitCode.Text.Trim();
                _currentProductTable.LAST_UPDATE_USER = _userInfo.CODE;
                _currentProductTable.PRODUCT_FLAG     = CConstant.PRODUCT_FLAG_PRODUCE;

                try
                {
                    bool ret = false;
                    if (bProduct.Exists(txtCode.Text.Trim()))
                    {
                        ret = bProduct.Update(_currentProductTable);
                    }
                    else
                    {
                        _currentProductTable.CREATE_USER = _userInfo.CODE;
                        ret = bProduct.Add(_currentProductTable);
                    }
                    if (ret)
                    {
                        result = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("保存失败,请重试或与系统管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("保存失败,请重试或与系统管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Logger.Error("自制件保存失败。", ex);
                }
            }
        }
Ejemplo n.º 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                if (_currentProductTable == null)
                {
                    _currentProductTable = new BaseProductTable();
                }
                _currentProductTable.CODE             = txtCode.Text.Trim();
                _currentProductTable.NAME             = txtName.Text.Trim();
                _currentProductTable.SPEC             = txtSpec.Text.Trim();
                _currentProductTable.BASIC_UNIT_CODE  = txtBasic.Text.Trim();
                _currentProductTable.SALES_PRICE      = CConvert.ToDecimal(txtPrice.Text.Trim());
                _currentProductTable.LAST_UPDATE_USER = _userInfo.CODE;
                _currentProductTable.PRODUCT_FLAG     = CConstant.PRODUCT_FLAG_SPEC;

                try
                {
                    if (bProduct.Exists(txtCode.Text.Trim()))
                    {
                        bProduct.Update(_currentProductTable);
                    }
                    else
                    {
                        _currentProductTable.CREATE_USER = _userInfo.CODE;
                        bProduct.Add(_currentProductTable);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("保存失败,请重试或与系统管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Logger.Error("规格/型号保存失败。", ex);
                    return;
                }
                result = DialogResult.OK;
                this.Close();
            }
        }
Ejemplo n.º 5
0
        public string CheckProduct(string product, string title)
        {
            if (product == null || "".Equals(product))
            {
                return(title + ERROR_NULL);
            }
            BProduct bProuduct = new BProduct();

            if (bProuduct.Exists(product))
            {
                return("");
            }
            return(title + ERROR_EXIST);
        }
Ejemplo n.º 6
0
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                if (_currentProductTable == null)
                {
                    _currentProductTable = new BaseProductTable();
                }
                _currentProductTable.CODE                        = txtCode.Text;
                _currentProductTable.NAME                        = txtName.Text;
                _currentProductTable.SPEC                        = txtSpec.Text;
                _currentProductTable.MODEL_NUMBER                = txtModelNumber.Text;
                _currentProductTable.GROUP_CODE                  = txtGroupCode.Text;
                _currentProductTable.BASIC_UNIT_CODE             = txtBasic.Text;
                _currentProductTable.HS_CODE                     = txtHsCode.Text;
                _currentProductTable.SALES_PRICE                 = Convert.ToDecimal(txtPrice.Text);
                _currentProductTable.LAST_UPDATE_USER            = _userInfo.CODE;
                _currentProductTable.NAME_JP                     = txtName_Jp.Text;
                _currentProductTable.PURCHASE_PRICE_INCLUDED_TAX = CConvert.ToDecimal(txtPurchasePrice.Text);
                _currentProductTable.CUSTOMER_SALES_PRICE        = CConvert.ToDecimal(txtCustomerSalesPrice.Text);
                _currentProductTable.PURCHASE_PRICE_WITHOUT_TAX  = CConvert.ToDecimal(txtPurchasePriceWithoutTax.Text);
                _currentProductTable.PRICE_JP                    = CConvert.ToDecimal(txtPrice_Jp.Text.Trim());

                if (rAccout1.Checked)
                {
                    _currentProductTable.ACCOUTING_TARGET = 1;
                }
                else
                {
                    _currentProductTable.ACCOUTING_TARGET = 2;
                }

                if (rStock1.Checked)
                {
                    _currentProductTable.STOCK_FLAG = 1;
                }
                else
                {
                    _currentProductTable.STOCK_FLAG = 2;
                }

                if (rProperty1.Checked)
                {
                    _currentProductTable.PROPERTY_FLAG = 1;
                }
                else
                {
                    _currentProductTable.PROPERTY_FLAG = 2;
                }

                if (rbNoFromSet.Checked)
                {
                    _currentProductTable.FROMSET_FLAG = 1;
                }
                else
                {
                    _currentProductTable.FROMSET_FLAG = 2;
                }

                if (rbBody.Checked)
                {
                    _currentProductTable.MECHANICAL_DISTINCTION_FLAG = 1;
                }
                else
                {
                    _currentProductTable.MECHANICAL_DISTINCTION_FLAG = 2;
                }

                if (rdoChaina.Checked)
                {
                    _currentProductTable.SELL_LOCATION = CConstant.PRODUCT_SELL_CHINA;
                }
                else
                {
                    _currentProductTable.SELL_LOCATION = CConstant.PRODUCT_SELL_JAPAN;
                }

                if (rdoAlone.Checked)
                {
                    _currentProductTable.PACKAGE_MODE = CConstant.PRODUCT_PACKAGE_ALONT;
                }
                else
                {
                    _currentProductTable.PACKAGE_MODE = CConstant.PRODUCT_PACKAGE_COMPOSE;
                }

                try
                {
                    if (bProduct.Exists(txtCode.Text.Trim()))
                    {
                        bProduct.Update(_currentProductTable);
                    }
                    else
                    {
                        _currentProductTable.CREATE_USER = _userInfo.CODE;
                        bProduct.Add(_currentProductTable);
                    }
                }
                catch (Exception ex)
                {
                    //log.error
                    MessageBox.Show("");
                    return;
                }
                result = DialogResult.OK;
                this.Close();
            }
        }
Ejemplo n.º 7
0
        public override string[] doUpdateDB()
        {
            BaseProductTable SpecificationTable = null;
            BProduct         bSpecification     = new BProduct();
            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, "SPEC"), 50, "规格"));
                //单位
                if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE"))))
                {
                    str.Append(CheckUnit(CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE")), "单位编号"));
                }
                //销售单价
                str.Append(CheckDecimal(GetValue(dr, "SALES_PRICE", 0), 12, 2, "销售单价"));

                if (str.ToString().Trim().Length > 0)
                {
                    strError.Append(GetStringBuilder(dr, str.ToString().Trim()));
                    failureData++;
                    continue;
                }
                try
                {
                    SpecificationTable                  = new BaseProductTable();
                    SpecificationTable.CODE             = CConvert.ToString(GetValue(dr, "CODE"));
                    SpecificationTable.NAME             = CConvert.ToString(GetValue(dr, "NAME"));
                    SpecificationTable.SPEC             = CConvert.ToString(GetValue(dr, "SPEC"));
                    SpecificationTable.BASIC_UNIT_CODE  = CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE"));
                    SpecificationTable.SALES_PRICE      = CConvert.ToDecimal(GetValue(dr, "SALES_PRICE"));
                    SpecificationTable.PRODUCT_FLAG     = CConstant.PRODUCT_FLAG_SPEC;
                    SpecificationTable.STATUS_FLAG      = CConstant.INIT;
                    SpecificationTable.CREATE_USER      = _userInfo.CODE;
                    SpecificationTable.LAST_UPDATE_USER = _userInfo.CODE;

                    if (!bSpecification.Exists(SpecificationTable.CODE))
                    {
                        bSpecification.Add(SpecificationTable);
                    }
                    else
                    {
                        bSpecification.Update(SpecificationTable);
                    }
                    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 });
        }
Ejemplo n.º 8
0
        public override string[] doUpdateDB()
        {
            BaseProductTable ProductTable = null;
            BProduct         bProduct     = new BProduct();
            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 (GetValue(dr, "CODE").ToString().Length > 40)
                {
                    if (!string.IsNullOrEmpty(GetValue(dr, "CODE").ToString().Substring(0, 40)))
                    {
                        str.Append(CheckString(GetValue(dr, "CODE"), "编号"));
                    }
                    else
                    {
                        str.Append("编号不能为空!");
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "CODE"))))
                    {
                        str.Append(CheckString(GetValue(dr, "CODE"), "编号"));
                    }
                    else
                    {
                        str.Append("编号不能为空!");
                    }
                }
                //名称
                str.Append(CheckLenght(GetValue(dr, "NAME"), 100, "名称"));
                //商品规格
                str.Append(CheckLenght(GetValue(dr, "SPEC"), 50, "商品规格"));
                //机器型号
                str.Append(CheckLenght(GetValue(dr, "MODEL_NUMBER"), 50, "机器型号"));
                //商品类别编号
                if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "GROUP_CODE"))))
                {
                    str.Append(CheckProductGroup(CConvert.ToString(GetValue(dr, "GROUP_CODE")), "商品类别编号"));
                }
                //基本单位
                if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE"))))
                {
                    str.Append(CheckUnit(CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE")), "基本单位"));
                }

                //原价计算对象
                str.Append(CheckLenght(GetValue(dr, "ACCOUTING_TARGET"), 100, "原价计算对象"));
                //海关商品编号
                if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "HS_CODE"))))
                {
                    str.Append(CheckHsCode(CConvert.ToString(GetValue(dr, "HS_CODE")), "海关商品编号"));
                }
                //默认售价
                str.Append(CheckDecimal(GetValue(dr, "SALES_PRICE", 0), 12, 2, "默认售价"));
                //货位
                str.Append(CheckLenght(GetValue(dr, "LOCATION_CODE"), 20, "货位"));
                //在库Flag
                if (CConvert.ToInt32(GetValue(dr, "STOCK_FLAG", 1)) != 1 && CConvert.ToInt32(GetValue(dr, "STOCK_FLAG", 1)) != 2 && CConvert.ToString(GetValue(dr, "STOCK_FLAG", 1)) != "")
                {
                    str.Append("在库Flag只能为1或2!");
                }
                else
                {
                    str.Append(CheckInt(GetValue(dr, "STOCK_FLAG", 1), 2, "在库Flag"));
                }
                //1:组成品  2:材料
                if (CConvert.ToInt32(GetValue(dr, "PROPERTY_FLAG", 1)) != 1 && CConvert.ToInt32(GetValue(dr, "PROPERTY_FLAG", 1)) != 2 && CConvert.ToString(GetValue(dr, "PROPERTY_FLAG", 1)) != "")
                {
                    str.Append("是否组成品只能为1或2!");
                }
                //一式品
                if (CConvert.ToInt32(GetValue(dr, "FROMSET_FLAG", 1)) != 1 && CConvert.ToInt32(GetValue(dr, "FROMSET_FLAG", 1)) != 2 && CConvert.ToString(GetValue(dr, "FROMSET_FLAG", 1)) != "")
                {
                    str.Append("一式品输入只能为1或2!");
                }
                //机械区分
                if (CConvert.ToInt32(GetValue(dr, "MECHANICAL_DISTINCTION_FLAG", 1)) != 1 && CConvert.ToInt32(GetValue(dr, "MECHANICAL_DISTINCTION_FLAG", 1)) != 2 && CConvert.ToString(GetValue(dr, "MECHANICAL_DISTINCTION_FLAG", 1)) != "")
                {
                    str.Append("机械区分输入只能为1或2!");
                }
                //安全在库数
                str.Append(CheckDecimal(GetValue(dr, "SAFETY_STOCK", 0), 12, 2, "安全在库数"));
                //状态
                str.Append(CheckInt(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS), 1, "状态"));
                //销售地点
                str.Append(CheckInt(GetValue(dr, "SELL_LOCATION", CConstant.NORMAL_STATUS), 1, "销售地点"));
                //包装方式
                str.Append(CheckInt(GetValue(dr, "PACKAGE_MODE", CConstant.NORMAL_STATUS), 1, "包装方式"));
                //名称
                str.Append(CheckLenght(GetValue(dr, "NAME_JP"), 100, "日文名称"));
                //含税单价
                str.Append(CheckDecimal(GetValue(dr, "PURCHASE_PRICE", 0), 12, 2, "含税单价"));
                //代理店销售价格
                str.Append(CheckDecimal(GetValue(dr, "CUSTOMER_SALES_PRICE", 0), 12, 2, "代理店销售价格"));
                //不含税单价
                str.Append(CheckDecimal(GetValue(dr, "PURCHASE_PRICE_WITHOUT_TAX", 0), 12, 2, "不含税单价"));
                //含税单价
                //str.Append(CheckDecimal(GetValue(dr, "PURCHASE_PRICE_INCLUDED_TAX", 0), 12, 2, "含税单价"));
                //日元单价
                str.Append(CheckDecimal(GetValue(dr, "PRICE_JP", 0), 12, 2, "日元单价"));

                if (str.ToString().Trim().Length > 0)
                {
                    strError.Append(GetStringBuilder(dr, str.ToString().Trim()));
                    failureData++;
                    continue;
                }
                try
                {
                    int ret = 0;
                    ProductTable = new BaseProductTable();
                    if (GetValue(dr, "CODE").ToString().Length > 20)
                    {
                        ProductTable.CODE = CConvert.ToString(GetValue(dr, "CODE")).Substring(0, 20);
                    }
                    else
                    {
                        ProductTable.CODE = CConvert.ToString(GetValue(dr, "CODE"));
                    }
                    ProductTable.NAME         = CConvert.ToString(GetValue(dr, "NAME"));
                    ProductTable.SPEC         = CConvert.ToString(GetValue(dr, "SPEC"));
                    ProductTable.MODEL_NUMBER = CConvert.ToString(GetValue(dr, "MODEL_NUMBER"));
                    ProductTable.GROUP_CODE   = CConvert.ToString(GetValue(dr, "GROUP_CODE"));
                    if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE"))))
                    {
                        ProductTable.BASIC_UNIT_CODE = CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE"));
                    }
                    else
                    {
                        ProductTable.BASIC_UNIT_CODE = "01";
                    }
                    ProductTable.ACCOUTING_TARGET            = CConvert.ToInt32(GetValue(dr, "ACCOUTING_TARGET"));
                    ProductTable.HS_CODE                     = CConvert.ToString(GetValue(dr, "HS_CODE"));
                    ProductTable.LOCATION_CODE               = CConvert.ToString(GetValue(dr, "LOCATION_CODE"));
                    ProductTable.STOCK_FLAG                  = CConvert.ToInt32(GetValue(dr, "STOCK_FLAG", 1));
                    ProductTable.PROPERTY_FLAG               = CConvert.ToInt32(GetValue(dr, "PROPERTY_FLAG", 1));
                    ProductTable.FROMSET_FLAG                = CConvert.ToInt32(GetValue(dr, "FROMSET_FLAG", 1));
                    ProductTable.MECHANICAL_DISTINCTION_FLAG = CConvert.ToInt32(GetValue(dr, "MECHANICAL_DISTINCTION_FLAG", 1));
                    ProductTable.SAFETY_STOCK                = CConvert.ToDecimal(GetValue(dr, "SAFETY_STOCK", 0));
                    ProductTable.STATUS_FLAG                 = CConvert.ToInt32(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS));

                    ProductTable.SELL_LOCATION = CConvert.ToInt32(GetValue(dr, "SELL_LOCATION", 1));
                    ProductTable.PACKAGE_MODE  = CConvert.ToInt32(GetValue(dr, "PACKAGE_MODE", 1));
                    ProductTable.NAME_JP       = CConvert.ToString(GetValue(dr, "NAME_JP"));

                    ProductTable.PURCHASE_PRICE_INCLUDED_TAX = CConvert.ToDecimal(GetValue(dr, "PURCHASE_PRICE", 0));
                    ProductTable.SALES_PRICE = CConvert.ToDecimal(GetValue(dr, "SALES_PRICE", 0));
                    ProductTable.PURCHASE_PRICE_WITHOUT_TAX = CConvert.ToDecimal(GetValue(dr, "PURCHASE_PRICE_WITHOUT_TAX", 0));
                    ProductTable.CUSTOMER_SALES_PRICE       = CConvert.ToDecimal(GetValue(dr, "CUSTOMER_SALES_PRICE", 0));
                    ProductTable.PRICE_JP = CConvert.ToDecimal(GetValue(dr, "PRICE_JP", 0));

                    ProductTable.CREATE_USER      = _userInfo.CODE;
                    ProductTable.LAST_UPDATE_USER = _userInfo.CODE;

                    if (!bProduct.Exists(ProductTable.CODE))
                    {
                        bProduct.Add(ProductTable);
                    }
                    else
                    {
                        bProduct.Update(ProductTable);
                    }
                    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 });
        }
Ejemplo n.º 9
0
        public override string[] doUpdateDB()
        {
            BaseProductTable ProductTable = null;
            BProduct         bProduct     = new BProduct();
            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 (GetValue(dr, "CODE").ToString().Length > 20)
                {
                    if (!string.IsNullOrEmpty(GetValue(dr, "CODE").ToString().Substring(0, 20)))
                    {
                        str.Append(CheckString(GetValue(dr, "CODE"), "外购件编号"));
                    }
                    else
                    {
                        str.Append("外购件编号不能为空!");
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "CODE"))))
                    {
                        str.Append(CheckString(GetValue(dr, "CODE"), "外购件编号"));
                    }
                    else
                    {
                        str.Append("外购件编号不能为空!");
                    }
                }
                //外购件名称
                str.Append(CheckLenght(GetValue(dr, "NAME"), 100, "外购件名称"));
                //外购件规格
                str.Append(CheckLenght(GetValue(dr, "SPEC"), 50, "外购件规格"));
                //外购件类别编号
                if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "GROUP_CODE"))))
                {
                    str.Append(CheckProductGroup(CConvert.ToString(GetValue(dr, "GROUP_CODE")), "外购件类别编号"));
                }
                //外购件单位
                if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE"))))
                {
                    str.Append(CheckUnit(CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE")), "外购件单位"));
                }
                //外购件销售价格
                str.Append(CheckDecimal(GetValue(dr, "SALES_PRICE", 0), 12, 2, "外购件销售价格"));
                //外购件采购价格
                str.Append(CheckDecimal(GetValue(dr, "PURCHASE_PRICE", 0), 12, 2, "外购件采购价格"));
                //外购件安全库存
                str.Append(CheckDecimal(GetValue(dr, "SAFETY_STOCK", 0), 12, 2, "外购件安全库存"));

                if (str.ToString().Trim().Length > 0)
                {
                    strError.Append(GetStringBuilder(dr, str.ToString().Trim()));
                    failureData++;
                    continue;
                }
                try
                {
                    int ret = 0;
                    ProductTable = new BaseProductTable();
                    if (GetValue(dr, "CODE").ToString().Length > 20)
                    {
                        ProductTable.CODE = CConvert.ToString(GetValue(dr, "CODE")).Substring(0, 20);
                    }
                    else
                    {
                        ProductTable.CODE = CConvert.ToString(GetValue(dr, "CODE"));
                    }
                    ProductTable.NAME       = CConvert.ToString(GetValue(dr, "NAME"));
                    ProductTable.SPEC       = CConvert.ToString(GetValue(dr, "SPEC"));
                    ProductTable.GROUP_CODE = CConvert.ToString(GetValue(dr, "GROUP_CODE"));
                    if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE"))))
                    {
                        ProductTable.BASIC_UNIT_CODE = CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE"));
                    }
                    else
                    {
                        ProductTable.BASIC_UNIT_CODE = "01";
                    }
                    ProductTable.SALES_PRICE      = Convert.ToDecimal(GetValue(dr, "SALES_PRICE", 0));
                    ProductTable.PURCHASE_PRICE   = Convert.ToDecimal(GetValue(dr, "PURCHASE_PRICE", 0));
                    ProductTable.SAFETY_STOCK     = CConvert.ToDecimal(GetValue(dr, "SAFETY_STOCK", 0));
                    ProductTable.PRODUCT_FLAG     = CConstant.PRODUCT_FLAG_PURCHASE;
                    ProductTable.STATUS_FLAG      = CConstant.INIT;
                    ProductTable.CREATE_USER      = _userInfo.CODE;
                    ProductTable.LAST_UPDATE_USER = _userInfo.CODE;

                    if (!bProduct.Exists(ProductTable.CODE))
                    {
                        bProduct.Add(ProductTable);
                    }
                    else
                    {
                        bProduct.Update(ProductTable);
                    }
                    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 });
        }