private void txtParentCode_Leave(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(this.txtParentCode.Text.Trim()))
     {
         BaseProductGroupTable ProductGroup  = new BaseProductGroupTable();
         BProductGroup         bProductGroup = new BProductGroup();
         ProductGroup = bProductGroup.GetModel(this.txtParentCode.Text);
         if (ProductGroup == null || "".Equals(ProductGroup))
         {
             txtParentCode.Focus();
             txtParentCode.Text = "";
             txtParentName.Text = "";
             MessageBox.Show("上级商品类别不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             txtParentCode.Text = ProductGroup.CODE;
             txtParentName.Text = ProductGroup.NAME;
             txtIndicatesOrder.Focus();
         }
     }
     else
     {
         txtParentName.Text = "";
     }
 }
Exemple #2
0
 private void txtProduct_Group_Code_Leave(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(this.txtProduct_Group_Code.Text.Trim()))
     {
         BaseProductGroupTable product  = new BaseProductGroupTable();
         BProductGroup         bProduct = new BProductGroup();
         product = bProduct.GetModel(this.txtProduct_Group_Code.Text);
         if (product == null || "".Equals(product))
         {
             txtProduct_Group_Code.Focus();
             txtProduct_Group_Code.Text = "";
             txtProduct_Group_Name.Text = "";
             MessageBox.Show("商品种类不存在!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             txtProduct_Group_Code.Text = product.CODE;
             txtProduct_Group_Name.Text = product.NAME;
         }
     }
     else
     {
         txtProduct_Group_Name.Text = "";
     }
 }
Exemple #3
0
        protected string CheckProductGroup(string productGroup, string title)
        {
            if ((productGroup == null || "".Equals(productGroup.ToString())))
            {
                return(title + ERROR_NULL);
            }
            BProductGroup bProductGroup = new BProductGroup();

            if (bProductGroup.Exists(productGroup))
            {
                return("");
            }
            return(title + ERROR_EXIST);
        }
Exemple #4
0
 private void txtGroupCode_Leave(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(this.txtGroupCode.Text.Trim()))
     {
         BaseProductGroupTable productGroup  = new BaseProductGroupTable();
         BProductGroup         bProductGroup = new BProductGroup();
         productGroup = bProductGroup.GetModel(this.txtGroupCode.Text);
         if (productGroup == null || "".Equals(productGroup))
         {
             txtGroupCode.Focus();
             txtGroupCode.Text = "";
             txtGroupName.Text = "";
             MessageBox.Show("类别型号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             txtGroupName.Text = productGroup.NAME;
         }
     }
 }
Exemple #5
0
        public override string[] doUpdateDB()
        {
            BaseProductGroupTable productGroupTable = null;
            BProductGroup         bProductGroup     = new BProductGroup();
            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, "名称"));
                //上级名称
                if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "PARENT_CODE"))))
                {
                    str.Append(CheckProductGroup(CConvert.ToString(GetValue(dr, "PARENT_CODE")), "上级名称"));
                }
                //表示顺序
                str.Append(CheckLenght(GetValue(dr, "INDICATES_ORDER"), 1000000, "表示顺序"));
                //状态
                str.Append(CheckInt(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS), 9, "状态"));

                if (str.ToString().Trim().Length > 0)
                {
                    strError.Append(GetStringBuilder(dr, str.ToString().Trim()));
                    failureData++;
                    continue;
                }
                try
                {
                    productGroupTable                  = new BaseProductGroupTable();
                    productGroupTable.CODE             = CConvert.ToString(GetValue(dr, "CODE"));
                    productGroupTable.NAME             = CConvert.ToString(GetValue(dr, "NAME"));
                    productGroupTable.PARENT_CODE      = CConvert.ToString(GetValue(dr, "PARENT_CODE"));
                    productGroupTable.INDICATES_ORDER  = CConvert.ToInt32(GetValue(dr, "INDICATES_ORDER", 0));
                    productGroupTable.STATUS_FLAG      = CConvert.ToInt32(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS));
                    productGroupTable.CREATE_USER      = _userInfo.CODE;
                    productGroupTable.LAST_UPDATE_USER = _userInfo.CODE;

                    if (!bProductGroup.Exists(productGroupTable.CODE))
                    {
                        bProductGroup.Add(productGroupTable);
                    }
                    else
                    {
                        bProductGroup.Update(productGroupTable);
                    }
                    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 });
        }
        public override string[] doUpdateDB()
        {
            BaseProductGroupTable productGroupTable = null;
            BProductGroup         bProductGroup     = new BProductGroup();
            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, "名称"));
                //上级名称
                if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "PARENT_CODE"))))
                {
                    str.Append(CheckProductGroup(CConvert.ToString(GetValue(dr, "PARENT_CODE")), "上级名称"));
                }
                //默认供应商
                str.Append(CheckSupplier(CConvert.ToString(GetValue(dr, "BASIC_SUPPLIER")), "默认供应商"));
                //供应商2
                if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "SECOND_SUPPLIER_CODE"))))
                {
                    str.Append(CheckSupplier(CConvert.ToString(GetValue(dr, "SECOND_SUPPLIER_CODE")), "供应商2"));
                }
                //供应商3
                if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "THIRD_SUPPLIER_CODE"))))
                {
                    str.Append(CheckSupplier(CConvert.ToString(GetValue(dr, "THIRD_SUPPLIER_CODE")), "供应商3"));
                }

                if (str.ToString().Trim().Length > 0)
                {
                    strError.Append(GetStringBuilder(dr, str.ToString().Trim()));
                    failureData++;
                    continue;
                }
                try
                {
                    productGroupTable                      = new BaseProductGroupTable();
                    productGroupTable.CODE                 = CConvert.ToString(GetValue(dr, "CODE"));
                    productGroupTable.NAME                 = CConvert.ToString(GetValue(dr, "NAME"));
                    productGroupTable.PARENT_CODE          = CConvert.ToString(GetValue(dr, "PARENT_CODE"));
                    productGroupTable.BASIC_SUPPLIER       = CConvert.ToString(GetValue(dr, "BASIC_SUPPLIER"));
                    productGroupTable.SECOND_SUPPLIER_CODE = CConvert.ToString(GetValue(dr, "SECOND_SUPPLIER_CODE"));
                    productGroupTable.THIRD_SUPPLIER_CODE  = CConvert.ToString(GetValue(dr, "THIRD_SUPPLIER_CODE"));
                    productGroupTable.STATUS_FLAG          = CConstant.INIT;
                    productGroupTable.CREATE_USER          = _userInfo.CODE;
                    productGroupTable.LAST_UPDATE_USER     = _userInfo.CODE;

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