示例#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("保存仓管人员信息失败!");
            }
        }
示例#2
0
 private void btnDel_Click(object sender, EventArgs e)
 {
     if (lstKeeper.SelectedIndex == -1) //如果没选,就什么都不做
     {
         return;
     }
     if (UnitCommon.ConfirmMsg("确定删除该保管人员吗?"))
     {
         KeeperManager keeperMgr = new KeeperManager();
         bool          done      = keeperMgr.DeleteKeeper(int.Parse(lstKeeper.SelectedValue.ToString()));
         if (done)
         {
             // 如果删除成功,重新绑定listBox
             DataTable dt2 = keeperMgr.BingListBox();
             lstKeeper.DataSource    = dt2;
             lstKeeper.DisplayMember = "keeper";
             lstKeeper.ValueMember   = "id";
             this.FormState          = "查看";
         }
         else
         {
             UnitCommon.ErrorMsg("删除仓库保管人员失败!");
         }
     }
 }
示例#3
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("保存资产信息失败!");
            }
        }
示例#4
0
 private void btnDel_Click(object sender, EventArgs e)
 {
     if (tvwDepart.SelectedNode == null)
     {
         UnitCommon.WarnMsg("请选择待删除的部门!");
         return;
     }
     if (tvwDepart.SelectedNode.Level == 0)
     {
         UnitCommon.WarnMsg("不能删除公司!"); // 根节点不能删除
         return;
     }
     if (UnitCommon.ConfirmMsg("确定要删除该部门吗?"))
     {
         int id = int.Parse(tvwDepart.SelectedNode.Tag.ToString());
         DepartmentManager deptMgr = new DepartmentManager();
         bool succ3 = deptMgr.DelDept(id);
         if (succ3)
         {
             FormState = "查看";
             BuildDeptTree();
         }
         else
         {
             UnitCommon.ErrorMsg("删除部门失败!");
         }
     }
 }
示例#5
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            if (lstInfo.SelectedIndex == -1)
            {
                return;                              //表示没有选择要删除的项
            }
            Resources res = lstInfo.SelectedItem as Resources;

            if (res != null)
            {
                if (UnitCommon.ConfirmMsg("您确定要删除此条记录吗?"))
                {
                    bool isok = ResFactoryManager.Del(res.Id, this.resType);
                    if (isok)
                    {
                        DataTable dt = ResFactoryManager.GetAllRes(resType);
                        this.BindLstRes(dt);
                        this.FormState = "查看";
                    }
                    else
                    {
                        UnitCommon.ErrorMsg("删除资产信息失败!");
                    }
                }
            }
        }
示例#6
0
        private void toolbtnDel_Click(object sender, EventArgs e)
        {
            if (UnitCommon.ConfirmMsg("您确定要删除此员工的信息吗?"))
            {
                tabControl1.SelectedIndex = 0; // 切换到tabControl1的第一个界面,员工信息
                //当双击dataGridView1某行时,获取所选行(可能有多行)的第一行、第一列的值,即员工编号
                int             id     = int.Parse(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
                EmployeeManager empMgr = new EmployeeManager();
                empMgr.DelEmployee(id);
                int result = empMgr.DelEmployee(id);
                if (result == -1)
                {
                    UnitCommon.WarnMsg("该员工是仓库保管员,必须取消其仓管身份之后才请允许删除,删除失败!");
                    return;
                }

                if (result == -2)
                {
                    UnitCommon.WarnMsg("该员工领取的固定资产尚未归还,必须归还之后才允许删除,删除失败!");
                    return;
                }
                if (result > 0)
                {
                    BindDataGridView(); // 重新刷新DataGridView
                    BuildEmpTree();     // 重新刷新TreeView
                }
                else
                {
                    UnitCommon.ErrorMsg("删除员工信息失败!");
                }
            }
        }
示例#7
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if (!CheckInput()) //用户名或密码输入为空
     {
         return;
     }
     else
     {
         资产管理系统.Model.SysUser user = null;
         bool valid = 资产管理系统.BLL.LoginManager.Login(txtUser.Text.Trim(), txtPass.Text.Trim(), out user);
         if (valid)
         {
             loginUser         = user;
             this.DialogResult = DialogResult.OK;
         }
         else
         {
             UnitCommon.ErrorMsg("用户名或密码不正确,请重新输入!");
             txtUser.Focus();
             txtUser.SelectAll();
         }
     }
 }
示例#8
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("修改部门信息失败!");
                    }
                }
            }
        }
示例#9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedIndex == 1) // 代表控件tabControl1的第二个界面,新员工注册
            {
                Employee emp = new Employee();
                if (txtNewName.Text.Trim() == "")
                {
                    UnitCommon.WarnMsg("请输入新员工姓名!");
                    return;
                }
                else
                {
                    emp.Name     = txtNewName.Text.Trim();
                    emp.Sex      = rabFemale.Checked ? "女" : "男";
                    emp.Departid = int.Parse(cbxNewDepart.SelectedValue.ToString());

                    EmployeeManager empMgr = new EmployeeManager();
                    bool            succ   = empMgr.AddEmployee(emp);
                    if (succ)
                    {
                        BindEmpInfo();                     //重新 刷新dataGridView
                        txtNewName.Text            = "";   // 重新初始化为空
                        rabMale.Checked            = true; // 默认勾选 男
                        cbxNewDepart.SelectedIndex = 0;    // 下拉框ComoBox默认显示第一项
                        tabControl1.SelectedIndex  = 0;    // 默认显示控件tabControl1的第一个界面,员工信息
                        BuildEmpTree();                    // 重新 刷新TreeView
                    }
                    else
                    {
                        UnitCommon.ErrorMsg("新员工注册失败!");
                        return;
                    }
                }
            }
            if (tabControl1.SelectedIndex == 2) //代表修改
            {
                int             id     = int.Parse(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
                EmployeeManager empMgr = new EmployeeManager();
                Employee        emp    = empMgr.GetEmployeeById(id);
                if (emp != null)
                {
                    emp.Name     = txtName.Text;
                    emp.Sex      = rabBoy.Checked ? "男" : "女";
                    emp.Departid = int.Parse(cbxDepart.SelectedValue.ToString());

                    bool succ = empMgr.UpdateEmployee(emp);
                    if (succ)
                    {
                        BindEmpInfo();                     //重新 刷新dataGridView
                        txtName.Text              = "";
                        rabBoy.Checked            = false; // 不勾选 男
                        rabGirl.Checked           = false; // 不勾选 女
                        cbxDepart.SelectedIndex   = -1;    // 下拉框不显示下拉项值
                        tabControl1.SelectedIndex = 0;     // 回到第一个界面,员工信息
                        BuildEmpTree();                    //重新 刷新TreeView
                    }
                    else
                    {
                        UnitCommon.ErrorMsg("修改员工信息失败!");
                        return;
                    }
                }
            }
        }