/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_ok_Click(object sender, EventArgs e) { SysdatOrg Org = new SysdatOrg(); bool isSuccess = false; if (txtCurrentOrg.Text == string.Empty) { new PubUtils().ShowNoteNGMsg("节点名称不能为空", 2, grade.RepeatedError); return; } Org.ParentID = Common.Helper.SqlInput.ChangeNullToInt(cbo_ParentOrg.SelectedValue, 0); Org.text = txtCurrentOrg.Text.Trim(); Org.ID = Common.Helper.SqlInput.ChangeNullToInt(_current_orgID, 0); if (operationType == OperationType.Add) { string strSql = string.Format("select * from SysdatOrg where text='{0}' and ParentID='{1}'", txtCurrentOrg.Text.Trim(), Common.Helper.SqlInput.ChangeNullToInt(cbo_ParentOrg.SelectedValue, 0)); dtOrg = NMS.QueryDataTable(PubUtils.uContext, strSql); if (dtOrg.Rows.Count > 0) { new PubUtils().ShowNoteNGMsg("节点名称已存在", 2, grade.RepeatedError); return; } isSuccess = BLL_SysdatOrg.InsertOrg(Org); } else { isSuccess = BLL_SysdatOrg.UpdateOrg(Org); } if (isSuccess) { new PubUtils().ShowNoteOKMsg("保存成功"); this.DialogResult = DialogResult.OK; this.Close(); } }
/// <summary> /// 修改用户表和用户组织表 /// </summary> /// <param name="user"></param> /// <param name="Org"></param> /// <returns></returns> public static bool UpdateUserOrg(SysDatUser user, SysdatOrg Org) { string strSql = string.Format(@"update SysDatUser set UserName='******' where UserID='{1}' update MdcDatOrgUserMap set OrgID='{0}',updator='{3}',updateTime=getdate() where UserID='{1}'", Org.ID, user.UserID, user.UserName, PubUtils.uContext.UserID); return(NMS.ExecTransql(PubUtils.uContext, strSql)); }
/// <summary> /// 新增用户表和用户组织表 /// </summary> /// <param name="user"></param> /// <returns></returns> public static bool InsertUserOrg(SysDatUser user, SysdatOrg Org) { string strSql = string.Format(@"insert into SysDatUser(UserID,UserName,Creator,CreateTime,Password) Values('{0}','{1}','{2}',getdate(),'{4}') insert into MdcDatOrgUserMap(UserID,OrgID,Creator,CreateTime) Values('{0}','{3}','{2}',getdate())", user.UserID, user.UserName, PubUtils.uContext.UserID, Org.ID, Common.Helper.Encrypt_DES.Encryption("123456" + user.UserID)); return(NMS.ExecTransql(PubUtils.uContext, strSql)); }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_ok_Click(object sender, EventArgs e) { SysDatUser user = new SysDatUser(); //用户表对象 SysdatOrg Org = new SysdatOrg(); //用户部门表对象 if (txt_userID.Text == string.Empty) { new PubUtils().ShowNoteNGMsg("用户ID不能为空", 2, grade.RepeatedError); return; } if (txt_userName.Text == string.Empty) { new PubUtils().ShowNoteNGMsg("用户名不能为空", 2, grade.RepeatedError); return; } if (cbo_Org.Text == string.Empty) { new PubUtils().ShowNoteNGMsg("所属部门不能为空", 2, grade.RepeatedError); return; } bool isSuccess = false; user.UserID = txt_userID.Text.Trim(); //用户ID user.UserName = txt_userName.Text.Trim(); //用户名 Org.ID = Convert.ToInt32(cbo_Org.SelectedValue); //部门 if (operationType == OperationType.Add) { string strSql = string.Format("select * from SysDatUser where UserID='{0}'", txt_userID.Text.Trim()); dtUser = NMS.QueryDataTable(PubUtils.uContext, strSql); if (dtUser.Rows.Count > 0) { new PubUtils().ShowNoteNGMsg("用户ID不能重复", 2, grade.RepeatedError); return; } isSuccess = BLL_SysDatUser.InsertUserOrg(user, Org); } else { isSuccess = BLL_SysDatUser.UpdateUserOrg(user, Org); } if (isSuccess) { new PubUtils().ShowNoteOKMsg("保存成功"); this.DialogResult = DialogResult.OK; this.Close(); } }
/// <summary> /// 修改节点 /// </summary> /// <param name="Org"></param> /// <returns></returns> public static bool UpdateOrg(SysdatOrg Org) { string strSql = string.Format("update SysdatOrg set text='{0}' where ID='{1}' and ParentID='{2}'", Org.text, Org.ID, Org.ParentID); return(NMS.ExecTransql(PubUtils.uContext, strSql)); }
/// <summary> /// 新增节点 /// </summary> /// <param name="Org"></param> /// <returns></returns> public static bool InsertOrg(SysdatOrg Org) { string strSql = string.Format("insert into SysdatOrg(Guid, ParentID,text,Creator,CreateTime) Values(newid(), '{0}','{1}','{2}',getdate())", Org.ParentID, Org.text, PubUtils.uContext.UserID); return(NMS.ExecTransql(PubUtils.uContext, strSql)); }