Exemple #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                if (_currentUnitTable == null)
                {
                    _currentUnitTable = new BaseUnitTable();
                }

                _currentUnitTable.CODE             = txtCode.Text.Trim();
                _currentUnitTable.NAME             = txtName.Text.Trim();
                _currentUnitTable.LAST_UPDATE_USER = _userInfo.CODE;

                try
                {
                    if (bUnit.Exists(txtCode.Text.Trim()))
                    {
                        bUnit.Update(_currentUnitTable);
                    }
                    else
                    {
                        _currentUnitTable.CREATE_USER = _userInfo.CODE;
                        bUnit.Add(_currentUnitTable);
                    }
                }
                catch (Exception ex)
                {
                    //log.error
                    MessageBox.Show("");
                    return;
                }
                result = DialogResult.OK;
                this.Close();
            }
        }
Exemple #2
0
        /// <summary>
        /// 单位编号存在CHECK
        /// </summary>
        protected string CheckUnit(string unitCode, string title)
        {
            if (unitCode == null || "".Equals(unitCode.ToString()))
            {
                return(title + ERROR_NULL);
            }

            if (_unitTable[unitCode.ToString()] != null)
            {
                return("");
            }
            BUnit bUnit = new BUnit();

            if (bUnit.Exists(unitCode))
            {
                _unitTable.Add(unitCode, unitCode);
                return("");
            }

            return(title + ERROR_EXIST);
        }
Exemple #3
0
        public override string[] doUpdateDB()
        {
            BaseUnitTable UnitTable      = null;
            BUnit         bUnit          = new BUnit();
            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(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
                {
                    UnitTable                  = new BaseUnitTable();
                    UnitTable.CODE             = CConvert.ToString(GetValue(dr, "CODE"));
                    UnitTable.NAME             = CConvert.ToString(GetValue(dr, "NAME"));
                    UnitTable.STATUS_FLAG      = CConvert.ToInt32(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS));
                    UnitTable.CREATE_USER      = _userInfo.CODE;
                    UnitTable.LAST_UPDATE_USER = _userInfo.CODE;

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