public List <GroupM> GetAllGroup(string GroupName) { List <GroupM> result = new List <GroupM>(); GroupDA groupDA = null; try { groupDA = new GroupDA(); var dt = groupDA.GetGroupsForName(GroupName, Operation); if (dt != null) { foreach (DataRow item in dt.Rows) { result.Add(new GroupM() { GroupID = item["GroupID"].ToString(), GroupName = item["GroupName"].ToString() }); } } } finally { if (groupDA != null) { groupDA.CloseConnection(); } } return(result); }
public ResultModel Delete(string groupID) { ResultModel result = new ResultModel(); Dictionary <string, object> saveData = new Dictionary <string, object>(); saveData.Add("IsDeleted", 1); saveData.Add("DeletedBy", UserID); saveData.Add("DeletedTime", DateTime.Now); GroupDA groupDA = null; try { groupDA = new GroupDA(); result.Affected = groupDA.EditGroup(saveData, groupID); } catch (Exception ex) { result.IsSuccess = false; result.Exception = ex.Message; } finally { if (groupDA != null) { groupDA.CloseConnection(); } } return(result); }
public GroupM GetGroup(string groupID) { GroupDA groupDA = null; DataRow dr; var g = new GroupM { }; try { groupDA = new GroupDA(); dr = groupDA.GetGroups(groupID, Operation).Rows[0]; g = new GroupM { GroupID = dr["GroupID"].ToString(), GroupName = dr["GroupName"].ToString(), Description = dr["Description"].ToString(), IsDeleted = Convert.ToByte(dr["IsDeleted"]), }; } finally { if (groupDA != null) { groupDA.CloseConnection(); } } return(g); }
/// <summary> /// Get all goup info /// </summary> /// <param name="groupID"></param> /// <param name="selectedGroupID"></param> /// <param name="selectedGroupName"></param> /// <returns></returns> private List <GroupM> GetAllGroup(string groupID, out string selectedGroupID, out string selectedGroupName) { selectedGroupID = ""; selectedGroupName = ""; bool getGroupFisrstElement = false; if (groupID == null) { getGroupFisrstElement = true; } List <GroupM> groupList = new List <GroupM>(); GroupDA groupDA = null; DataTable dt = new DataTable(); try { groupDA = new GroupDA(); dt = groupDA.GetAllGroup(Operation); for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; GroupM group = new GroupM(); group.GroupID = CommUtil.ConvertObjectToString(dr["GroupID"]); group.GroupName = CommUtil.ConvertObjectToString(dr["GroupName"]); groupList.Add(group); if (i == 0 && getGroupFisrstElement) { selectedGroupID = group.GroupID; selectedGroupName = group.GroupName; } if (group.GroupID.Equals(groupID)) { selectedGroupID = group.GroupID; selectedGroupName = group.GroupName; } } } finally { if (groupDA != null) { groupDA.CloseConnection(); } } return(groupList); }
public ResultModel DelUserGroup(string groupID, string UserUIDs) { ResultModel result = new ResultModel(); Dictionary <string, object> DelData; GroupDA groupDA = null; try { groupDA = new GroupDA(); foreach (var item in UserUIDs.Split(',').Where(z => z.Length > 0)) { DelData = new Dictionary <string, object>(); DelData.Add("GroupID", groupID); DelData.Add("UserUID", item); result.Affected = groupDA.DelUserGroup(DelData); } var UserGroups = groupDA.GetUserGroups(groupID); int count = UserGroups == null ? 0 : UserGroups.Rows.Count; DelData = new Dictionary <string, object>(); DelData.Add("NumOfUsers", count); groupDA.EditGroup(DelData, groupID); } catch (Exception ex) { result.IsSuccess = false; result.Exception = ex.Message; } finally { if (groupDA != null) { groupDA.CloseConnection(); } } return(result); }
public ResultModel New(GroupM model) { ResultModel result = new ResultModel(); DateTime dt = DateTime.Now; Dictionary <string, object> paramValues = new Dictionary <string, object>(); paramValues.Add("GroupName", model.GroupName.Trim()); paramValues.Add("Operation", Operation); paramValues.Add("SystemID", "S0001"); paramValues.Add("Description", model.Description); paramValues.Add("CreatedBy", UserID); paramValues.Add("CreatedTime", dt); paramValues.Add("LastModifiedBy", UserID); paramValues.Add("LastModifiedTime", dt); paramValues.Add("NumOfUsers", 0); paramValues.Add("IsDeleted", 0); GroupDA groupDA = null; try { groupDA = new GroupDA(); result.Affected = groupDA.NewGroup(paramValues); } catch (Exception ex) { result.IsSuccess = false; result.Exception = ex.Message; } finally { if (groupDA != null) { groupDA.CloseConnection(); } } return(result); }
public ResultModel Edit(GroupM model) { ResultModel result = new ResultModel(); Dictionary <string, object> saveData = new Dictionary <string, object>(); saveData.Add("GroupName", model.GroupName.Trim()); saveData.Add("Description", model.Description); saveData.Add("LastModifiedBy", UserID); saveData.Add("LastModifiedTime", DateTime.Now); if (model.IsDeleted == 1) { saveData.Add("IsDeleted", model.IsDeleted); saveData.Add("DeletedBy", UserID); saveData.Add("DeletedTime", DateTime.Now); } GroupDA groupDA = null; try { groupDA = new GroupDA(); result.Affected = groupDA.EditGroup(saveData, model.GroupID); } catch (Exception ex) { result.IsSuccess = false; result.Exception = ex.Message; } finally { if (groupDA != null) { groupDA.CloseConnection(); } } return(result); }
public PagingModel List(string groupID, string groupName, string description, int pageSize, int pageIndex) { GroupDA groupDA = null; PagingModel dt = new PagingModel(); try { groupDA = new GroupDA(); dt = groupDA.GetGroupByPage(groupID, groupName, description, Operation, new PagingModel() { PageIndex = pageIndex, PageSize = pageSize }); } finally { if (groupDA != null) { groupDA.CloseConnection(); } } return(dt); }