Exemplo n.º 1
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            try
            {
                DataRow dr = gv_User.GetDataRow(gv_User.FocusedRowHandle);

                if (dr != null)
                {
                    if (UserInfo.userID == dr["用户名"].ToString() && UserInfo.userID != "system")
                    {
                        MessageBox.Show("自己不能修改自己部门!");
                        return;
                    }

                    FrmSetDept frm = new FrmSetDept(dr["用户名"].ToString());
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        ModTS_USER_DEPT model = bllTsUserDept.Get_Model(dr["用户名"].ToString());
                        if (model != null)
                        {
                            model.C_DEPT_ID = frm.strDeptID;
                            bllTsUserDept.Update(model);
                        }
                        else
                        {
                            model           = new ModTS_USER_DEPT();
                            model.C_DEPT_ID = frm.strDeptID;
                            model.C_USER_ID = dr["用户名"].ToString();

                            bllTsUserDept.Add(model);
                        }

                        BindList();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txt_UserName.Text.Trim()))
                {
                    MessageBox.Show("姓名不能为空!");
                    return;
                }

                if (string.IsNullOrEmpty(txt_LoginName.Text.Trim()))
                {
                    MessageBox.Show("账号不能为空!");
                    return;
                }

                //if (string.IsNullOrEmpty(txt_Email.Text.Trim()))
                //{
                //    MessageBox.Show("邮箱不能为空!");
                //    return;
                //}

                //if (string.IsNullOrEmpty(txt_Tel.Text.Trim()))
                //{
                //    MessageBox.Show("电话不能为空!");
                //    return;
                //}

                ModTS_USER mod = bll.GetModel(strUserID);
                if (mod != null)
                {
                    mod.C_NAME     = txt_UserName.Text.Trim();              //姓名
                    mod.C_EMAIL    = txt_Email.Text.Trim();                 //邮箱
                    mod.C_MOBILE   = txt_Tel.Text.Trim();                   //电话
                    mod.N_STATUS   = Convert.ToInt32(icbo_State.EditValue); //状态(1正常,2,3,4冻结)
                    mod.C_EMP_ID   = UserInfo.userID;                       //系统操作人编号
                    mod.C_EMP_NAME = UserInfo.userName;                     //系统操作人姓名
                    mod.D_MOD_DT   = ServerTime.timeNow();                  //系系统操作时间

                    if (bll.Update(mod))
                    {
                        if (!string.IsNullOrEmpty(btnEdit_Dept.Text.Trim()))
                        {
                            BllTS_USER_DEPT bllUserDept = new BllTS_USER_DEPT();

                            ModTS_USER_DEPT model = bllUserDept.Get_Model(strUserID);
                            if (model != null)
                            {
                                model.C_DEPT_ID = strDeptID;
                                bllUserDept.Update(model);
                            }
                            else
                            {
                                model           = new ModTS_USER_DEPT();
                                model.C_DEPT_ID = strDeptID;
                                model.C_USER_ID = strUserID;

                                bllUserDept.Add(model);
                            }
                        }

                        MessageBox.Show("修改成功!");
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }