Example #1
0
 private void txtUnitCode_Leave(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(this.txtUnitCode.Text.Trim()))
     {
         BaseUnitTable Unit  = new BaseUnitTable();
         BUnit         bUnit = new BUnit();
         Unit = bUnit.GetModel(this.txtUnitCode.Text);
         if (Unit == null || "".Equals(Unit))
         {
             txtUnitCode.Focus();
             txtUnitCode.Text = "";
             txtUnitName.Text = "";
             MessageBox.Show("单位编号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             txtUnitCode.Text = Unit.CODE;
             txtUnitName.Text = Unit.NAME;
         }
     }
     else
     {
         txtUnitName.Text = "";
     }
 }
Example #2
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();
            }
        }
Example #3
0
 private void txtCode_Leave(object sender, EventArgs e)
 {
     //判断编号是否已存在
     if (!string.IsNullOrEmpty(this.txtCode.Text.Trim()))
     {
         BaseUnitTable UnitCode = new BaseUnitTable();
         UnitCode = bUnit.GetModel(txtCode.Text);
         if (UnitCode != null)
         {
             txtCode.Focus();
             txtCode.Text = "";
             MessageBox.Show("单位编号已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }
Example #4
0
        /// <summary>
        /// 获得当前选中的数据
        /// </summary>
        private void GetCurrentSelectedTable()
        {
            try
            {
                string code = dgvData.SelectedRows[0].Cells["CODE"].Value.ToString();
                if (code != "")
                {
                    _currentUnitTable = bUnit.GetModel(code);
                }
            }
            catch (Exception ex) { }

            if (_currentUnitTable == null || _currentUnitTable.CODE == null || "".Equals(_currentUnitTable.CODE))
            {
                _currentUnitTable = null;
            }
        }
Example #5
0
        /// <summary>
        /// 打开新窗口
        /// </summary>
        private void OpenDialogFrm(int mode)
        {
            if (mode == CConstant.MODE_NEW || _currentUnitTable != null)
            {
                FrmUnitDialog frm = new FrmUnitDialog();
                frm.UserInfo         = _userInfo;
                frm.CurrentUnitTable = _currentUnitTable;
                frm.Mode             = mode;
                DialogResult resule = frm.ShowDialog(this);
                if (resule == DialogResult.OK && isSearch)
                {
                    Search(this.pgControl.GetCurrentPage());
                }
                frm.Dispose();
            }
            else
            {
                //MessageBox.Show("请选择正确的行!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            _currentUnitTable = null;
        }
Example #6
0
 /// <summary>
 /// 删除
 /// </summary>
 private void MasterToolBar_DoDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("确定要删除吗?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.OK)
     {
         try
         {
             GetCurrentSelectedTable();
             if (_currentUnitTable != null)
             {
                 bUnit.Delete(_currentUnitTable.CODE);
                 Search(this.pgControl.GetCurrentPage());
             }
             else
             {
                 MessageBox.Show("请选择正确的行!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("删除失败,请重试或与系统管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         _currentUnitTable = null;
     }
 }
Example #7
0
        private void txtUnitCode_Leave(object sender, EventArgs e)
        {
            //判断编号是否已存在
            if (!string.IsNullOrEmpty(this.txtProductCode.Text.Trim()) && !string.IsNullOrEmpty(this.txtUnitCode.Text.Trim()))
            {
                BaseProductUnitTable ProductUnitCode = new BaseProductUnitTable();
                ProductUnitCode = bProductUnit.GetModel(txtProductCode.Text, txtUnitCode.Text);
                if (ProductUnitCode != null)
                {
                    txtProductCode.Text = "";
                    txtProductName.Text = "";
                    txtUnitCode.Text    = "";
                    txtUnitName.Text    = "";
                    txtProductCode.Focus();
                    MessageBox.Show("商品编号与单位编号组合已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            if (!string.IsNullOrEmpty(this.txtUnitCode.Text.Trim()))
            {
                BaseUnitTable Unit  = new BaseUnitTable();
                BUnit         bUnit = new BUnit();
                Unit = bUnit.GetModel(this.txtUnitCode.Text);
                if (Unit == null || "".Equals(Unit))
                {
                    txtUnitCode.Focus();
                    txtUnitCode.Text = "";
                    txtUnitName.Text = "";
                    MessageBox.Show("单位编号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    txtUnitName.Text = Unit.NAME;
                }
            }
        }
Example #8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(BaseUnitTable model)
 {
     return(dal.Update(model));
 }
Example #9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(BaseUnitTable model)
 {
     return(dal.Add(model));
 }
Example #10
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 });
        }