Beispiel #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            registereduser.LoginName = txt_LoginName.Text.Trim();
            if (!string.IsNullOrEmpty(txt_Password.Text.Trim()))
            {
                registereduser.Password = txt_Password.Text.Trim();
            }
            registereduser.Remarks      = txt_Remarks.Text.Trim();
            registereduser.OperatorId   = MainForm.user.ReUId;
            registereduser.OperatorDate = DateTime.Now;

            if (string.IsNullOrEmpty(registereduser.LoginName))
            {
                MessageBox.Show("用户名不能为空!");
                return;
            }

            aers_tbl_registereduser check = dal.Uniquenessverification(registereduser.LoginName);

            if (state == FormState.Add)
            {
                if (string.IsNullOrEmpty(registereduser.Password))
                {
                    MessageBox.Show("密码不能为空!");
                    return;
                }
                if (check != null)
                {
                    MessageBox.Show("用户名已存在!");
                    return;
                }
            }

            if (staff == null)
            {
                staff = new aers_tbl_staff();
            }


            if (txt_HospId.EditValue == null)
            {
                MessageBox.Show("请选择医院");
                return;
            }


            if (txt_HospdepId.SelectedRow == null || string.IsNullOrEmpty(txt_HospdepId.SelectedRow["HospdepId"].ToString()))
            {
                if (txt_HospdepId.Tag != null)
                {
                    staff.DepId = txt_HospdepId.Tag.ToString();
                }
                else
                {
                    MessageBox.Show("请选择科室");
                    return;
                }
            }
            else
            {
                staff.DepId = txt_HospdepId.SelectedRow["HospdepId"].ToString();
            }



            staff.Name      = txt_Name.Text;
            staff.RoleState = txt_RoleState.Text;
            staff.IDNumber  = "";
            staff.Position  = "";
            staff.Address   = "";
            staff.Sex       = txt_Sex.SelectedValue.ToString();

            if (!string.IsNullOrEmpty(txt_Phone.Text.Trim()))
            {
                staff.Phone = txt_Phone.Text;
            }

            if (!string.IsNullOrEmpty(txt_StaffRemarks.Text.Trim()))
            {
                staff.Remarks = txt_StaffRemarks.Text;
            }

            staff.OperatorId   = MainForm.user.ReUId;
            staff.OperatorDate = DateTime.Now;



            if (string.IsNullOrEmpty(staff.Name))
            {
                MessageBox.Show("姓名不能为空!");
                return;
            }

            if (staff.RoleState == "")
            {
                MessageBox.Show("请选择权限!");
                return;
            }



            if (state == FormState.Add)
            {
                string ReguserId = dal.Insert(registereduser);
                if (!string.IsNullOrEmpty(ReguserId))
                {
                    check           = dal.Uniquenessverification(registereduser.LoginName);
                    staff.ReguserId = check.ReguserId;
                    int i;
                    if (dalstaff.FindByRUid(check.ReguserId) == null)
                    {
                        i = dalstaff.Insert(staff);
                    }
                    else
                    {
                        i = dalstaff.Update(staff);
                    }

                    if (i > 0)
                    {
                        this.DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        MessageBox.Show("人员信息增加失败!");
                    }
                }
                else
                {
                    MessageBox.Show("增加失败!");
                }
            }
            else
            {
                int i = dal.Update(registereduser);
                if (i > 0)
                {
                    staff.ReguserId = registereduser.ReguserId;
                    i = dalstaff.Update(staff);
                    if (i > 0)
                    {
                        this.DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        MessageBox.Show("人员信息修改失败!");
                    }
                }
                else
                {
                    MessageBox.Show("修改失败!");
                }
            }
        }
Beispiel #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            staff.ReguserId    = "0";
            staff.Name         = txt_Name.Text;
            staff.RoleState    = txt_RoleState.SelectedValue.ToString();
            staff.IDNumber     = "";
            staff.Position     = "";
            staff.Address      = "";
            staff.Sex          = txt_Sex.SelectedValue.ToString();
            staff.Phone        = txt_Phone.Text;
            staff.Remarks      = txt_StaffRemarks.Text;
            staff.OperatorId   = MainForm.user.ReUId;
            staff.OperatorDate = DateTime.Now;



            if (txt_HospId.EditValue == null)
            {
                MessageBox.Show("请选择医院");
                return;
            }


            if (txt_HospdepId.SelectedRow == null || string.IsNullOrEmpty(txt_HospdepId.SelectedRow["HospdepId"].ToString()))
            {
                if (txt_HospdepId.Tag != null)
                {
                    staff.DepId = txt_HospdepId.Tag.ToString();
                }
                else
                {
                    MessageBox.Show("请选择科室");
                    return;
                }
            }
            else
            {
                staff.DepId = txt_HospdepId.SelectedRow["HospdepId"].ToString();
            }



            if (state == FormState.Add)
            {
                int i = dalstaff.Insert(staff);
                if (i > 0)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("增加失败!");
                }
            }
            else
            {
                int i = dalstaff.Update(staff);
                if (i > 0)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("修改失败!");
                }
            }
        }