private void GetAgentInfoByAgeNum(out string msg) { msg = ""; if (AgentNum != "") { Entities.QueryEmployeeAgent query = new Entities.QueryEmployeeAgent(); query.AgentNum = AgentNum; int total = 0; DataTable dt = BLL.EmployeeAgent.Instance.GetEmployeeAgent(query, "", 1, 10, out total); if (dt != null && dt.Rows.Count > 0) { msg = "{\"UserID\":\"" + dt.Rows[0]["UserID"] + "\",\"AgentNum\":\"" + dt.Rows[0]["AgentNum"] + "\",\"BGID\":\"" + dt.Rows[0]["BGID"] + "\"}"; } } }
private string GetAgentNum() { string retStr = ""; Entities.QueryEmployeeAgent query = new Entities.QueryEmployeeAgent(); query.UserID = int.Parse(UserID); int totalCount = 0; DataTable dt = BLL.EmployeeAgent.Instance.GetEmployeeAgent(query, "", 1, 10, out totalCount); if (dt != null && dt.Rows.Count > 0) { retStr = dt.Rows[0]["AgentNum"].ToString(); } return(retStr); }
private void SaveEmpleeInfo() { #region 判断工号是否已被使用,如果已经被使用,把别人的设置为空 Entities.EmployeeAgent model = new Entities.EmployeeAgent(); Entities.QueryEmployeeAgent query = new Entities.QueryEmployeeAgent(); query.AgentNum = AgentNum; int total = 0; DataTable dt = BLL.EmployeeAgent.Instance.GetEmployeeAgent(query, "", 1, 10, out total); if (dt.Rows.Count > 0 && dt.Rows[0]["UserID"].ToString() != UserID) { //与别人的工号有重复,把别人的置为空 model = BLL.EmployeeAgent.Instance.GetEmployeeAgentByUserID(int.Parse(dt.Rows[0]["UserID"].ToString())); if (model != null) { model.AgentNum = ""; BLL.EmployeeAgent.Instance.Update(model); } } #endregion model = BLL.EmployeeAgent.Instance.GetEmployeeAgentByUserID(int.Parse(UserID)); if (model != null) { //存在,更新 model.AgentNum = AgentNum; model.BGID = int.Parse(AtGroupID); model.RegionID = int.Parse(AreaID); BLL.EmployeeAgent.Instance.Update(model); } else { //不存在,插入 model = new Entities.EmployeeAgent(); model.AgentNum = AgentNum; model.BGID = int.Parse(AtGroupID); model.CreateTime = DateTime.Now; model.CreateUserID = BLL.Util.GetLoginUserID(); model.UserID = int.Parse(UserID); model.RegionID = int.Parse(AreaID); BLL.EmployeeAgent.Instance.Insert(model); } }
/// <summary> /// 判断工号是否被其他员工占用 /// </summary> /// <param name="UserIDs"></param> /// <param name="AgentNum"></param> /// <returns></returns> public bool IsExistsAgentNum(string UserIDs, string AgentNum) { #region 判断工号是否重复 bool flag = false; //判断是否重复 Entities.QueryEmployeeAgent query = new Entities.QueryEmployeeAgent(); query.AgentNum = AgentNum; int total = 0; DataTable dt = BLL.EmployeeAgent.Instance.GetEmployeeAgent(query, "", 1, 10, out total); if (total != 0) { if (dt.Rows[0]["UserID"].ToString() != UserIDs) { //与别人的工号有重复 flag = true; } } return(flag); #endregion }
private void CheckedPar(out string errMsg) { errMsg = ""; #region 检测用户ID if (UserIDs == string.Empty || UserIDs.Split(',').Length == 0) { errMsg = "noUserPar"; return; } #endregion #region 检测角色ID string[] UserIDsList = UserIDs.Split(','); int intVal = 0; foreach (string item in UserIDsList) { if (!int.TryParse(item, out intVal)) { errMsg = "useridFormatErr"; //用户ID格式错误 break; } } if (errMsg != "") { return; } #endregion #region 是单个修改时,判断 if (IsModfiySingle == "true") { #region 判断数据权限 if (int.TryParse(RightType, out intVal)) { if (intVal != 1 && intVal != 2) { errMsg = "rightTypeErr"; return; } } else { errMsg = "rightTypeErr"; return; } #endregion #region 判断用户名 if (UserIDs.Split(',').Length > 1) { errMsg = "noUserPar"; return; } #endregion //#region 判断工号是否重复,如果IsContinute= "1"则不验证 if (IsContinute != "1") { //判断是否重复 Entities.QueryEmployeeAgent query = new Entities.QueryEmployeeAgent(); query.AgentNum = AgentNum; int total = 0; DataTable dt = BLL.EmployeeAgent.Instance.GetEmployeeAgent(query, "", 1, 10, out total); if (total != 0) { if (dt.Rows[0]["UserID"].ToString() != UserIDs) { //与别人的工号有重复 errMsg = "repeated"; return; } } } //#endregion } #endregion }
/// <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 }