private string GetDataRight() { string retStr = ""; Entities.UserDataRigth model = BLL.UserDataRigth.Instance.GetUserDataRigth(int.Parse(UserID)); if (model != null) { retStr = model.RightType.ToString(); } return(retStr); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(Entities.UserDataRigth model) { SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int, 4), new SqlParameter("@RightType", SqlDbType.Int), new SqlParameter("@CreateUserID", SqlDbType.Int, 4) }; parameters[0].Value = model.UserID; parameters[1].Value = model.RightType; parameters[2].Value = model.CreateUserID; return(SqlHelper.ExecuteNonQuery(CONNECTIONSTRINGS, CommandType.StoredProcedure, P_USERDATARIGTH_UPDATE, parameters)); }
/// <summary> /// 增加一条数据 /// </summary> public void Insert(Entities.UserDataRigth model) { SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int, 4), new SqlParameter("@RightType", SqlDbType.Int, 4), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@CreateUserID", SqlDbType.Int, 4) }; parameters[0].Value = model.UserID; parameters[1].Value = model.RightType; parameters[2].Value = model.CreateTime; parameters[3].Value = model.CreateUserID; SqlHelper.ExecuteNonQuery(CONNECTIONSTRINGS, CommandType.StoredProcedure, P_USERDATARIGTH_INSERT, parameters); }
//数据权限 插日志 private void userDataRigthInsertLog(Entities.UserDataRigth oldModel, Entities.UserDataRigth newModel) { string userLogStr = string.Empty; string logStr = string.Empty; Hashtable ht_FieldName = new Hashtable(); ht_FieldName.Add("UserID", "员工姓名"); ht_FieldName.Add("RightType", "数据权限"); ht_FieldName.Add("CreateTime", "编辑时间"); ht_FieldName.Add("CreateUserID", "编辑人"); BLL.GetLogDesc.ht_FieldName = ht_FieldName; Hashtable ht_FieldType = new Hashtable(); Hashtable ht_RightType = new Hashtable(); ht_FieldName.Add("1", "非全部"); ht_FieldName.Add("2", "全部"); ht_FieldType.Add("UserID", "UserID"); ht_FieldType.Add("RightType", ht_FieldName); ht_FieldType.Add("CreateUserID", "UserID"); BLL.GetLogDesc.ht_FieldType = ht_FieldType; if (oldModel == null)//为空,则是新增 { //插入日志 BLL.GetLogDesc.getAddLogInfo(newModel, out userLogStr); logStr = "数据权限表新增:" + userLogStr; } else //不为空,则是编辑 { //插入日志 BLL.GetLogDesc.getCompareLogInfo(oldModel, newModel, out userLogStr); logStr = "数据权限表编辑:" + userLogStr; } if (userLogStr != string.Empty) { BLL.Util.InsertUserLog(logStr); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Entities.UserDataRigth GetUserDataRigth(int UserID) { QueryUserDataRigth query = new QueryUserDataRigth(); query.UserID = UserID; DataTable dt = new DataTable(); int count = 0; dt = GetUserDataRigth(query, string.Empty, 1, 1, out count); if (count > 0) { return(LoadSingleUserDataRigth(dt.Rows[0])); } else { Entities.UserDataRigth model = new Entities.UserDataRigth(); model.RightType = 0; return(model); } }
private Entities.UserDataRigth LoadSingleUserDataRigth(DataRow row) { Entities.UserDataRigth model = new Entities.UserDataRigth(); if (row["UserID"].ToString() != "") { model.UserID = int.Parse(row["UserID"].ToString()); } if (row["RightType"].ToString() != "") { model.RightType = int.Parse(row["RightType"].ToString()); } if (row["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(row["CreateTime"].ToString()); } if (row["CreateUserID"].ToString() != "") { model.CreateUserID = int.Parse(row["CreateUserID"].ToString()); } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(Entities.UserDataRigth model) { return(Dal.UserDataRigth.Instance.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public void Insert(Entities.UserDataRigth model) { Dal.UserDataRigth.Instance.Insert(model); }
/// <summary> /// 当时单个修改时,保存工号和数据权限 /// </summary> private void ModifyOther() { int retNum = 0; #region 修改工号 Entities.EmployeeAgent model = new Entities.EmployeeAgent(); Entities.EmployeeAgent oldModel = null; Entities.QueryEmployeeAgent query = new Entities.QueryEmployeeAgent(); query.UserID = int.Parse(UserIDs); int totalCount = 0; DataTable dt = BLL.EmployeeAgent.Instance.GetEmployeeAgent(query, "", 1, 10, out totalCount); oldModel = BLL.EmployeeAgent.Instance.GetEmployeeAgentByUserID(int.Parse(UserIDs)); //*add by qizq 2013-7-16 如果工号已存在,删除工号员工对应关系(程序走到这步说明用户已经选择要替换已有工号对应员工) if (!string.IsNullOrEmpty(AgentNum)) { Entities.QueryEmployeeAgent queryHave = new Entities.QueryEmployeeAgent(); queryHave.AgentNum = AgentNum; int total = 0; DataTable dtHave = BLL.EmployeeAgent.Instance.GetEmployeeAgent(queryHave, "", 1, 10, out total); if (total != 0) { if (dtHave.Rows[0]["UserID"].ToString() != UserIDs) { BLL.EmployeeAgent.Instance.Delete(int.Parse(dtHave.Rows[0]["RecID"].ToString())); string logStr = "删除用户工号:把" + BLL.Util.GetNameInHRLimitEID(Convert.ToInt32(dtHave.Rows[0]["UserID"].ToString())) + "的工号" + AgentNum + "删除"; BLL.Util.InsertUserLog(logStr); } } } //* if (dt == null || dt.Rows.Count == 0) { model.UserID = int.Parse(UserIDs); model.AgentNum = AgentNum; model.CreateTime = DateTime.Now; model.CreateUserID = BLL.Util.GetLoginUserID(); //如果没有,则插入 if (model.AgentNum != "") { retNum = BLL.EmployeeAgent.Instance.Insert(model); model.RecID = retNum; employeeAgentInsertLog(null, model); } } else { //如果有,则修改 if (dt.Rows[0]["AgentNum"].ToString() != AgentNum) { //有变动,要修改 model = BLL.EmployeeAgent.Instance.GetEmployeeAgent(int.Parse(dt.Rows[0]["RecID"].ToString())); model.AgentNum = AgentNum; if (model.AgentNum != "") { retNum = BLL.EmployeeAgent.Instance.Update(model); employeeAgentInsertLog(oldModel, model); } //*add by qizq2013-7-16如果工号为空,删除人员坐席对应关系。 else { retNum = BLL.EmployeeAgent.Instance.Delete(model.RecID); string logStr = "删除用户工号:把" + BLL.Util.GetNameInHRLimitEID(Convert.ToInt32(oldModel.UserID)) + "的工号" + oldModel.AgentNum + "删除"; BLL.Util.InsertUserLog(logStr); } //* } } #endregion #region 修改数据权限 Entities.UserDataRigth modeldata = new Entities.UserDataRigth(); Entities.UserDataRigth oldModel_UserData = null; Entities.QueryUserDataRigth dataQuery = new Entities.QueryUserDataRigth(); dataQuery.UserID = int.Parse(UserIDs); DataTable datadt = BLL.UserDataRigth.Instance.GetUserDataRigth(dataQuery, "", 1, 10, out totalCount); oldModel_UserData = BLL.UserDataRigth.Instance.GetUserDataRigth(int.Parse(UserIDs)); if (datadt == null || datadt.Rows.Count == 0) { modeldata.UserID = int.Parse(UserIDs); modeldata.RightType = int.Parse(RightType); modeldata.CreateTime = DateTime.Now; modeldata.CreateUserID = BLL.Util.GetLoginUserID(); //如果没有,则插入 BLL.UserDataRigth.Instance.Insert(modeldata); userDataRigthInsertLog(null, modeldata); } else { //如果有,则修改 if (datadt.Rows[0]["RightType"].ToString() != RightType) { //如果数据权限有变动,则更新 modeldata = BLL.UserDataRigth.Instance.GetUserDataRigth(int.Parse(datadt.Rows[0]["UserID"].ToString())); modeldata.RightType = int.Parse(RightType); retNum = BLL.UserDataRigth.Instance.Update(modeldata); userDataRigthInsertLog(oldModel_UserData, modeldata); } } #endregion #region 分组设置 if (!string.IsNullOrEmpty(GroupRightStr)) { //先删除用户的分组 BLL.UserGroupDataRigth.Instance.DeleteByUserID(int.Parse(UserIDs)); BLL.Util.InsertUserLog("删除用户ID为:" + UserIDs + ",姓名为:" + BLL.Util.GetNameInHRLimitEID(int.Parse(UserIDs)) + " 下面的所属业务组"); int userId = BLL.Util.GetLoginUserID(); string[] groupRightArry = GroupRightStr.Split(';'); foreach (string groupRight in groupRightArry) { string[] arry = groupRight.Split('|'); Entities.UserGroupDataRigth groupDataRigthModel = new Entities.UserGroupDataRigth(); groupDataRigthModel.CreateTime = DateTime.Now; groupDataRigthModel.CreateUserID = userId; groupDataRigthModel.RightType = int.Parse(arry[1]); groupDataRigthModel.UserID = int.Parse(UserIDs); groupDataRigthModel.BGID = int.Parse(arry[0]); int returnRecID = BLL.UserGroupDataRigth.Instance.Insert(groupDataRigthModel); groupDataRigthModel.RecID = returnRecID; userGroupDataRigthInsertLog(null, groupDataRigthModel); } } #endregion }