Exemple #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtKeeper.Text.Trim() == "")
            {
                UnitCommon.InfoMsg("请输入仓管人员信息!");
                txtKeeper.Focus();
                return;
            }

            Keeper keeper = new Keeper();

            keeper.Name = txtKeeper.Text.Trim(); // keeper的id字段是自增字段,不用管

            KeeperManager keeperMgr = new KeeperManager();
            bool          done      = keeperMgr.AddKeeper(keeper);

            if (done)
            {
                DataTable dt3 = keeperMgr.BingListBox();
                lstKeeper.DataSource    = dt3;
                lstKeeper.DisplayMember = "keeper";
                lstKeeper.ValueMember   = "id";
                this.FormState          = "查看";
            }
            else
            {
                UnitCommon.ErrorMsg("保存仓管人员信息失败!");
            }
        }
Exemple #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtInput.Text == "" || txtInput.Text == "请输入新加项的内容")
            {
                UnitCommon.InfoMsg("请输入新添加项的内容!");
                txtInput.Focus();
                txtInput.SelectAll();
                return;
            }

            Resources res = new Resources();

            res.Name = txtInput.Text.Trim();
            bool isOK = ResFactoryManager.Add(res, this.resType);

            if (isOK)
            {
                DataTable dt = ResFactoryManager.GetAllRes(resType);
                BindLstRes(dt);
                this.FormState = "查看";
            }
            else
            {
                UnitCommon.ErrorMsg("保存资产信息失败!");
            }
        }
Exemple #3
0
 private bool CheckInput()
 {
     if (txtUser.Text.Trim() == "")
     {
         UnitCommon.InfoMsg("用户名不能为空!");
         txtUser.Focus(); //鼠标聚焦在此文本框内
         return(false);
     }
     else if (txtPass.Text.Trim() == "")
     {
         UnitCommon.InfoMsg("密码不能为空!");
         txtPass.Focus(); //鼠标聚焦在此文本框内
         return(false);
     }
     return(true);
 }
Exemple #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string state    = FormState; // 获取当前的状态
            string deptName = "";

            if (state == "添加")
            {
                // 遍历Tree根节点下的所有子节点,找到添加的新节点
                foreach (TreeNode node in tvwDepart.Nodes[0].Nodes)
                {
                    if (node.Tag.ToString() == "new")
                    {
                        deptName = node.Text.Trim(); // 获取添加节点的名字
                        break;
                    }
                }

                if (deptName == "" || deptName == "请输入新部门名称")
                {
                    UnitCommon.InfoMsg("请输入新部门名称!");
                    return;
                }

                Department dept = new Department();
                dept.Name = deptName;
                DepartmentManager deptMgr = new DepartmentManager();
                bool succ = deptMgr.AddDept(dept);
                if (succ)             // 保存成功
                {
                    FormState = "查看"; // 注意不要写成formState
                    BuildDeptTree();
                }
                else
                {
                    UnitCommon.ErrorMsg("保存新部门失败!");
                }

                return;
            }
            else if (state == "修改")
            {
                if (deptofModified != null)
                {
                    int    id   = int.Parse(deptofModified.Tag.ToString());
                    string name = deptofModified.Text.Trim();
                    if (name == "")
                    {
                        UnitCommon.WarnMsg("部门名称不能为空!");
                        return;
                    }

                    Department dept = new Department();
                    dept.Id   = id;
                    dept.Name = name;
                    DepartmentManager deptMgr = new DepartmentManager();
                    bool succ2 = deptMgr.UpadateDept(dept);
                    if (succ2)
                    {
                        FormState = "查看";
                        BuildDeptTree();
                    }
                    else
                    {
                        UnitCommon.ErrorMsg("修改部门信息失败!");
                    }
                }
            }
        }