/// <summary> /// 更新记录 /// </summary> /// <param name="model">MyCreek.Data.Model.WorkGroup实体类</param> public int Update(MyCreek.Data.Model.WorkGroup model) { string sql = @"UPDATE WorkGroup SET Name=:Name,Members=:Members,Note=:Note WHERE ID=:ID" ; OracleParameter[] parameters = new OracleParameter[] { new OracleParameter(":Name", OracleDbType.NVarchar2, 1000) { Value = model.Name }, new OracleParameter(":Members", OracleDbType.Clob) { Value = model.Members }, model.Note == null ? new OracleParameter(":Note", OracleDbType.NVarchar2) { Value = DBNull.Value } : new OracleParameter(":Note", OracleDbType.NVarchar2) { Value = model.Note }, new OracleParameter(":ID", OracleDbType.Varchar2, 40) { Value = model.ID } }; return(dbHelper.Execute(sql, parameters)); }
protected void Page_Load(object sender, EventArgs e) { MyCreek.Platform.WorkGroup bwg = new MyCreek.Platform.WorkGroup(); string name = string.Empty; string members = string.Empty; string note = string.Empty; if (IsPostBack) { name = Request.Form["Name"]; members = Request.Form["Members"]; note = Request.Form["Note"]; MyCreek.Data.Model.WorkGroup wg = new MyCreek.Data.Model.WorkGroup(); wg.ID = Guid.NewGuid(); wg.Name = name.Trim(); wg.Members = members; if (!note.IsNullOrEmpty()) { wg.Note = note; } bwg.Add(wg); string query = Request.Url.Query; MyCreek.Platform.Log.Add("添加了工作组", wg.Serialize(), MyCreek.Platform.Log.Types.组织机构); Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "parent.frames[0].treecng('1');alert('添加成功!');window.location = 'WorkGroup.aspx' + '" + query + "';", true); } }
private void addWorkGroupUsers(List <MyCreek.Data.Model.Users> userList, MyCreek.Data.Model.WorkGroup wg) { if (wg == null || wg.Members.IsNullOrEmpty()) { return; } string[] idArray = wg.Members.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); Users busers = new Users(); WorkGroup bwg = new WorkGroup(); foreach (var id in idArray) { if (id.StartsWith(Users.PREFIX))//人员 { userList.Add(busers.Get(Users.RemovePrefix(id).ToGuid())); } else if (id.IsGuid())//机构 { userList.AddRange(GetAllUsers(id.ToGuid())); } else if (id.StartsWith(WorkGroup.PREFIX))//工作组 { addWorkGroupUsers(userList, bwg.Get(WorkGroup.RemovePrefix(id).ToGuid())); } } }
/// <summary> /// 添加记录 /// </summary> /// <param name="model">MyCreek.Data.Model.WorkGroup实体类</param> /// <returns>操作所影响的行数</returns> public int Add(MyCreek.Data.Model.WorkGroup model) { string sql = @"INSERT INTO WorkGroup (ID,Name,Members,Note) VALUES(@ID,@Name,@Members,@Note)" ; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@ID", SqlDbType.UniqueIdentifier, -1) { Value = model.ID }, new SqlParameter("@Name", SqlDbType.NVarChar, 1000) { Value = model.Name }, new SqlParameter("@Members", SqlDbType.VarChar, -1) { Value = model.Members }, model.Note == null ? new SqlParameter("@Note", SqlDbType.NVarChar, -1) { Value = DBNull.Value } : new SqlParameter("@Note", SqlDbType.NVarChar, -1) { Value = model.Note } }; return(dbHelper.Execute(sql, parameters)); }
/// <summary> /// 添加记录 /// </summary> /// <param name="model">MyCreek.Data.Model.WorkGroup实体类</param> /// <returns>操作所影响的行数</returns> public int Add(MyCreek.Data.Model.WorkGroup model) { string sql = @"INSERT INTO WorkGroup (ID,Name,Members,Note) VALUES(:ID,:Name,:Members,:Note)" ; OracleParameter[] parameters = new OracleParameter[] { new OracleParameter(":ID", OracleDbType.Varchar2, 40) { Value = model.ID }, new OracleParameter(":Name", OracleDbType.NVarchar2, 1000) { Value = model.Name }, new OracleParameter(":Members", OracleDbType.Clob) { Value = model.Members }, model.Note == null ? new OracleParameter(":Note", OracleDbType.NVarchar2) { Value = DBNull.Value } : new OracleParameter(":Note", OracleDbType.NVarchar2) { Value = model.Note } }; return(dbHelper.Execute(sql, parameters)); }
/// <summary> /// 更新记录 /// </summary> /// <param name="model">MyCreek.Data.Model.WorkGroup实体类</param> public int Update(MyCreek.Data.Model.WorkGroup model) { string sql = @"UPDATE WorkGroup SET Name=@Name,Members=@Members,Note=@Note WHERE ID=@ID" ; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@Name", SqlDbType.NVarChar, 1000) { Value = model.Name }, new SqlParameter("@Members", SqlDbType.VarChar, -1) { Value = model.Members }, model.Note == null ? new SqlParameter("@Note", SqlDbType.NVarChar, -1) { Value = DBNull.Value } : new SqlParameter("@Note", SqlDbType.NVarChar, -1) { Value = model.Note }, new SqlParameter("@ID", SqlDbType.UniqueIdentifier, -1) { Value = model.ID } }; return(dbHelper.Execute(sql, parameters)); }
public ActionResult WorkGroupAdd(FormCollection collection) { MyCreek.Platform.WorkGroup bwg = new MyCreek.Platform.WorkGroup(); string name = string.Empty; string members = string.Empty; string note = string.Empty; if (collection != null) { name = Request.Form["Name"]; members = Request.Form["Members"]; note = Request.Form["Note"]; MyCreek.Data.Model.WorkGroup wg = new MyCreek.Data.Model.WorkGroup(); wg.ID = Guid.NewGuid(); wg.Name = name.Trim(); wg.Members = members; if (!note.IsNullOrEmpty()) { wg.Note = note; } bwg.Add(wg); string query = Request.Url.Query; MyCreek.Platform.Log.Add("添加了工作组", wg.Serialize(), MyCreek.Platform.Log.Types.组织机构); ViewBag.Script = "parent.frames[0].treecng('1');alert('添加成功!');window.location = 'WorkGroup' + '" + query + "';"; } return(View()); }
/// <summary> /// 得到工作组下的人员名称字符串 /// </summary> /// <param name="wg">工作组实体</param> /// <param name="split"></param> /// <returns></returns> public string GetUsersNames(MyCreek.Data.Model.WorkGroup wg, char split = ',') { if (wg == null || wg.Members.IsNullOrEmpty()) { return(""); } return(GetUsersNames(wg.Members, split)); }
public ActionResult WorkGroup(FormCollection collection) { string id = Request.QueryString["id"]; Guid wid; MyCreek.Platform.WorkGroup bwg = new MyCreek.Platform.WorkGroup(); MyCreek.Data.Model.WorkGroup wg = null; string name = string.Empty; string members = string.Empty; string note = string.Empty; string users = string.Empty; if (!id.IsGuid(out wid) || wid == Guid.Empty) { Response.End(); } wg = bwg.Get(wid); if (wg != null) { name = wg.Name; members = wg.Members; note = wg.Note; users = bwg.GetUsersNames(wg.Members, '、'); } if (!Request.Form["Save"].IsNullOrEmpty() && collection != null && wg != null) { string oldxml = wg.Serialize(); name = Request.Form["Name"]; members = Request.Form["Members"]; note = Request.Form["Note"]; wg.Name = name.Trim(); wg.Members = members; if (!note.IsNullOrEmpty()) { wg.Note = note; } bwg.Update(wg); users = bwg.GetUsersNames(wg.Members, '、'); string query = Request.Url.Query; MyCreek.Platform.Log.Add("修改了工作组", "修改了工作组", MyCreek.Platform.Log.Types.组织机构, oldxml, wg.Serialize()); ViewBag.Script = "alert('保存成功!');"; } //删除 if (!Request.Form["DeleteBut"].IsNullOrEmpty() && collection != null && wg != null) { string oldxml = wg.Serialize(); bwg.Delete(wg.ID); string query = Request.Url.Query; MyCreek.Platform.Log.Add("删除了工作组", oldxml, MyCreek.Platform.Log.Types.组织机构); ViewBag.Script = "parent.frames[0].treecng('1');alert('删除成功!');window.location = 'Empty' + '" + query + "';"; } return(View(wg)); }
protected void Page_Load(object sender, EventArgs e) { string id = Request.QueryString["id"]; Guid wid; MyCreek.Data.Model.WorkGroup wg = null; name = string.Empty; members = string.Empty; note = string.Empty; users = string.Empty; if (!id.IsGuid(out wid) || wid == Guid.Empty) { Response.End(); } wg = bwg.Get(wid); if (wg != null) { name = wg.Name; members = wg.Members; note = wg.Note; users = bwg.GetUsersNames(wg.Members, '、'); } if (!Request.Form["Save"].IsNullOrEmpty() && IsPostBack && wg != null) { string oldxml = wg.Serialize(); name = Request.Form["Name"]; members = Request.Form["Members"]; note = Request.Form["Note"]; wg.Name = name.Trim(); wg.Members = members; if (!note.IsNullOrEmpty()) { wg.Note = note; } bwg.Update(wg); users = bwg.GetUsersNames(wg.Members, '、'); string query = Request.Url.Query; MyCreek.Platform.Log.Add("修改了工作组", "修改了工作组", MyCreek.Platform.Log.Types.组织机构, oldxml, wg.Serialize()); Page.ClientScript.RegisterStartupScript(Page.GetType(), "OK", "alert('保存成功!');", true); } //删除 if (!Request.Form["DeleteBut"].IsNullOrEmpty() && IsPostBack && wg != null) { string oldxml = wg.Serialize(); bwg.Delete(wg.ID); string query = Request.Url.Query; MyCreek.Platform.Log.Add("删除了工作组", oldxml, MyCreek.Platform.Log.Types.组织机构); Page.ClientScript.RegisterStartupScript(Page.GetType(), "OK", "parent.frames[0].treecng('1');alert('删除成功!');window.location = 'Empty.aspx' + '" + query + "';", true); } }
/// <summary> /// 将DataRedar转换为List /// </summary> private List <MyCreek.Data.Model.WorkGroup> DataReaderToList(OracleDataReader dataReader) { List <MyCreek.Data.Model.WorkGroup> List = new List <MyCreek.Data.Model.WorkGroup>(); MyCreek.Data.Model.WorkGroup model = null; while (dataReader.Read()) { model = new MyCreek.Data.Model.WorkGroup(); model.ID = dataReader.GetString(0).ToGuid(); model.Name = dataReader.GetString(1); model.Members = dataReader.GetString(2); if (!dataReader.IsDBNull(3)) { model.Note = dataReader.GetString(3); } List.Add(model); } return(List); }
/// <summary> /// 更新 /// </summary> public int Update(MyCreek.Data.Model.WorkGroup model) { return(dataWorkGroup.Update(model)); }
/// <summary> /// 新增 /// </summary> public int Add(MyCreek.Data.Model.WorkGroup model) { return(dataWorkGroup.Add(model)); }