public int Update(CustomerInfo entity) { int result = 0; CustomerInfo entityold = GetCustomerByID(entity.ID); if (entity.CustomerStatus != entityold.CustomerStatus || entity.OwnerID != entityold.OwnerID) { CustomerMoveRecordInfo minfo = new CustomerMoveRecordInfo() { CustomerID = entity.ID, CustomerStatus = entity.CustomerStatus, CustomerStatusSource = entityold.CustomerStatus, OwnerID = entity.OwnerID, Owner = entity.Owner, LastUpdateUserID = entity.LastUpdateUserID, LastUpdateUser = entity.LastUpdateUser, CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm") }; if (entity.CustomerStatus == (int)CustomerStatus.潜客_战败) { minfo.SystemMsg = DateTime.Today.ToString("yyyy年MM月dd日") + "战败"; } else if (entity.CustomerStatus == (int)CustomerStatus.潜客_转出) { minfo.SystemMsg = DateTime.Today.ToString("yyyy年MM月dd日") + "由" + entityold.CustomerStatusName + "转出"; } else if (entity.CustomerStatus != entityold.CustomerStatus) { minfo.SystemMsg = DateTime.Today.ToString("yyyy年MM月dd日") + "由" + entityold.CustomerStatusName + "转入"; } else if (entity.OwnerID != entityold.OwnerID) { minfo.SystemMsg = DateTime.Today.ToString("yyyy年MM月dd日") + "变更线索所有人"; } CustomerMoveRecords.Instance.Add(minfo); if (entity.CustomerStatus != (int)CustomerStatus.潜客_战败 && entity.CustomerStatus != (int)CustomerStatus.潜客_转出) { entity.SystemRemark = minfo.SystemMsg; } if (entity.OwnerID != entityold.OwnerID) { AdminInfo owner = Admins.Instance.GetAdmin(entity.OwnerID); entity.OwnerPowerGroupID = owner.PowerGroupID; } } result = CommonDataProvider.Instance().UpdateCustomer(entity); if (result > 0) { RefreshCustomerCache(entity); } return(result); }
protected void btnSubmit_Click(object sender, EventArgs e) { AdminInfo entity = new AdminInfo(); int id = GetInt("id"); if (id > 0) entity = Admins.Instance.GetAdmin(id); FillData(entity); if (id > 0) Admins.Instance.UpdateAdmin(entity); else Admins.Instance.AddAdmin(entity); Response.Redirect(string.IsNullOrEmpty(FromUrl) ? "adminmg.aspx" : FromUrl); }
private void FillData(AdminInfo entity) { entity.UserName = txtUserName.Value; entity.UserRole = UserRoleType.系统管理员; entity.Password = EncryptString.MD5(txtPassword.Value); entity.PasswordText = txtPassword.Value; entity.Realname = txtRealname.Value; entity.Mobile = txtMobile.Value; entity.QQ = txtQQ.Value; entity.Sex = DataConvert.SafeInt(rblSex.SelectedValue); entity.LastLoginIP = string.Empty; if (!entity.Administrator) { entity.CorporationID = DataConvert.SafeInt(ddlCorp.SelectedValue); entity.Corporation = ddlCorp.SelectedItem.Text; } entity.State = rblState.SelectedValue; }
protected void btnSubmit_Click(object sender, EventArgs e) { AdminInfo entity = new AdminInfo() { UserRole = UserRoleType.普通用户 }; int id = GetInt("id"); if (id > 0) entity = Admins.Instance.GetAdmin(id); FillData(entity); if (id > 0) Admins.Instance.UpdateAdmin(entity); else { Admins.Instance.AddAdmin(entity); PowerGroups.Instance.ReloadPowerGroupListCache(); } Response.Redirect(string.IsNullOrEmpty(FromUrl) ? "adminmg.aspx" : FromUrl); }
/// <summary> /// 添加管理员 /// </summary> /// <param name="model">后台用户实体类</param> /// <returns>添加成功返回ID</returns> public override int AddAdmin(AdminInfo model) { SerializerData data = model.GetSerializerData(); string sql = @" INSERT INTO ComOpp_AdminUser(UserName,Password,Administrator,LastLoginIP,LastLoginTime,[PropertyNames],[PropertyValues],[UserRole],[PowerGroupID]) VALUES (@UserName,@Password,@Administrator,@LastLoginIP,@LastLoginTime,@PropertyNames,@PropertyValues,@UserRole,@PowerGroupID) ;SELECT @@IDENTITY"; SqlParameter[] p = { new SqlParameter("@UserName",model.UserName), new SqlParameter("@Password",model.Password), new SqlParameter("@Administrator",model.Administrator), new SqlParameter("@LastLoginIP",model.LastLoginIP), new SqlParameter("@LastLoginTime",model.LastLoginTime), new SqlParameter("@UserRole",model.UserRole), new SqlParameter("@PowerGroupID",model.PowerGroupID), new SqlParameter("@PropertyNames",data.Keys), new SqlParameter("@PropertyValues",data.Values) }; model.ID = DataConvert.SafeInt(SqlHelper.ExecuteScalar(_con, CommandType.Text, sql, p)); return model.ID; }
/// <summary> /// 填充后台用户实体类 /// </summary> /// <param name="reader">记录集</param> /// <returns>实体类</returns> protected AdminInfo PopulateAdmin(IDataReader reader) { AdminInfo admin = new AdminInfo(); admin.ID = (int)reader["ID"]; admin.Administrator = DataConvert.SafeBool(reader["Administrator"]); admin.LastLoginIP = reader["LastLoginIP"] as string; admin.LastLoginTime = reader["LastLoginTime"] as DateTime?; admin.Password = reader["Password"] as string; admin.UserName = reader["UserName"] as string; admin.UserRole = (UserRoleType)(Int16)reader["UserRole"]; admin.PowerGroupID = DataConvert.SafeInt(reader["PowerGroupID"]); admin.PowerGroupName = reader["PowerGroupName"] as string; admin.GroupPower = reader["GroupPower"] as string; SerializerData data = new SerializerData(); data.Keys = reader["PropertyNames"] as string; data.Values = reader["PropertyValues"] as string; admin.SetSerializerData(data); return(admin); }
/// <summary> /// 添加管理员 /// </summary> /// <param name="model">后台用户实体类</param> /// <returns>添加成功返回ID</returns> public abstract int AddAdmin(AdminInfo model);
/// <summary> /// 更新管理员 /// </summary> /// <param name="model">后台用户实体类</param> /// <returns>修改是否成功</returns> public bool UpdateAdmin(AdminInfo model) { return(CommonDataProvider.Instance().UpdateAdmin(model)); }
/// <summary> /// 添加管理员 /// </summary> /// <param name="model">后台用户实体类</param> /// <returns>添加成功返回ID</returns> public int AddAdmin(AdminInfo model) { return(CommonDataProvider.Instance().AddAdmin(model)); }
/// <summary> /// 更新管理员 /// </summary> /// <param name="model">后台用户实体类</param> /// <returns>修改是否成功</returns> public abstract bool UpdateAdmin(AdminInfo model);
/// <summary> /// 添加管理员 /// </summary> /// <param name="model">后台用户实体类</param> /// <returns>添加成功返回ID</returns> public int AddAdmin(AdminInfo model) { return CommonDataProvider.Instance().AddAdmin(model); }
/// <summary> /// 更新管理员 /// </summary> /// <param name="model">后台用户实体类</param> /// <returns>修改是否成功</returns> public bool UpdateAdmin(AdminInfo model) { return CommonDataProvider.Instance().UpdateAdmin(model); }
private void FillData(AdminInfo entity) { entity.UserName = txtUserName.Value; entity.Password = EncryptString.MD5(txtPassword.Value); entity.PasswordText = txtPassword.Value; entity.Realname = txtRealname.Value; entity.Mobile = txtMobile.Value; entity.QQ = txtQQ.Value; entity.Sex = DataConvert.SafeInt(rblSex.SelectedValue); entity.LastLoginIP = string.Empty; entity.State = rblState.SelectedValue; if (entity.UserRole == UserRoleType.普通用户) entity.PowerGroupID = DataConvert.SafeInt(hdnPowerGroup.Value); if (Admin.Administrator) { entity.CorporationID = DataConvert.SafeInt(ddlCorporation.SelectedValue); entity.Corporation = ddlCorporation.SelectedItem.Text; } else { entity.CorporationID = Admin.CorporationID; entity.Corporation = Admin.Corporation; } }
private void LoadData() { int id = GetInt("id"); if (id > 0) { CurrentAdmin = Admins.Instance.GetAdmin(id); if (CurrentAdmin == null) WriteMessage("/message.aspx", "系统提示", "无效账户!", "", "/index.aspx"); else { if (!Admin.Administrator && Admin.CorporationID != CurrentAdmin.CorporationID) WriteMessage("/message.aspx", "系统提示", "没有权限!", "", "/index.aspx"); txtUserName.Value = CurrentAdmin.UserName; txtUserName.Attributes["readonly"] = "true"; txtPassword.Value = CurrentAdmin.PasswordText; txtRealname.Value = CurrentAdmin.Realname; txtMobile.Value = CurrentAdmin.Mobile; txtQQ.Value = CurrentAdmin.QQ; SetSelectedByValue(rblSex, CurrentAdmin.Sex.ToString()); SetSelectedByValue(rblState, CurrentAdmin.State); if (Admin.Administrator) { SetSelectedByValue(ddlCorporation, CurrentAdmin.CorporationID.ToString()); CorporationChanged(DataConvert.SafeInt(ddlCorporation.SelectedValue)); } else { CorporationChanged(DataConvert.SafeInt(Admin.CorporationID)); } SetSelectedByValue(ddlPowerGroupEdit, CurrentAdmin.PowerGroupID.ToString()); hdnPowerGroup.Value = CurrentAdmin.PowerGroupID.ToString(); } } else { if (!Admin.Administrator) CorporationChanged(DataConvert.SafeInt(Admin.CorporationID)); else CorporationChanged(DataConvert.SafeInt(ddlCorporation.SelectedValue)); hdnPowerGroup.Value = ddlPowerGroupEdit.SelectedValue; } }
/// <summary> /// 更新管理员 /// </summary> /// <param name="model">后台用户实体类</param> /// <returns>修改是否成功</returns> public override bool UpdateAdmin(AdminInfo model) { SerializerData data = model.GetSerializerData(); string sql = @"UPDATE ComOpp_AdminUser SET UserName = @UserName ,Password = @Password ,Administrator = @Administrator ,LastLoginIP = @LastLoginIP ,LastLoginTime = @LastLoginTime ,UserRole = @UserRole ,PowerGroupID = @PowerGroupID ,[PropertyNames] = @PropertyNames ,[PropertyValues] = @PropertyValues WHERE ID = @ID "; SqlParameter[] p = { new SqlParameter("@UserName",model.UserName), new SqlParameter("@Password",model.Password), new SqlParameter("@Administrator",model.Administrator), new SqlParameter("@LastLoginIP",model.LastLoginIP), new SqlParameter("@LastLoginTime",model.LastLoginTime), new SqlParameter("@UserRole",(int)model.UserRole), new SqlParameter("@PowerGroupID",model.PowerGroupID), new SqlParameter("@PropertyNames",data.Keys), new SqlParameter("@PropertyValues",data.Values), new SqlParameter("@ID",model.ID) }; int result = SqlHelper.ExecuteNonQuery(_con, CommandType.Text, sql, p); if (result > 0) { return true; } return false; }
private void LoadData() { int id = GetInt("id"); if (id > 0) { CurrentAdmin = Admins.Instance.GetAdmin(id); txtUserName.Value = CurrentAdmin.UserName; txtUserName.Attributes["readonly"] = "true"; txtPassword.Value = CurrentAdmin.PasswordText; txtRealname.Value = CurrentAdmin.Realname; txtMobile.Value = CurrentAdmin.Mobile; txtQQ.Value = CurrentAdmin.QQ; SetSelectedByValue(rblSex,CurrentAdmin.Sex.ToString()); SetSelectedByValue(rblState, CurrentAdmin.State); SetSelectedByValue(ddlCorp, CurrentAdmin.CorporationID.ToString()); } }
/// <summary> /// 填充后台用户实体类 /// </summary> /// <param name="reader">记录集</param> /// <returns>实体类</returns> protected AdminInfo PopulateAdmin(IDataReader reader) { AdminInfo admin = new AdminInfo(); admin.ID = (int)reader["ID"]; admin.Administrator = DataConvert.SafeBool(reader["Administrator"]); admin.LastLoginIP = reader["LastLoginIP"] as string; admin.LastLoginTime = reader["LastLoginTime"] as DateTime?; admin.Password = reader["Password"] as string; admin.UserName = reader["UserName"] as string; admin.UserRole = (UserRoleType)(Int16)reader["UserRole"]; admin.PowerGroupID = DataConvert.SafeInt(reader["PowerGroupID"]); admin.PowerGroupName = reader["PowerGroupName"] as string; admin.GroupPower = reader["GroupPower"] as string; SerializerData data = new SerializerData(); data.Keys = reader["PropertyNames"] as string; data.Values = reader["PropertyValues"] as string; admin.SetSerializerData(data); return admin; }