protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CheckAdminPower("ReadDistributorGrade", PowerCheckType.Single); BindControl(DistributorGradeBLL.ReadList(), RecordList); } }
public UserController() { uid = RequestHelper.GetForm <int>("uid"); if (uid <= 0) { uid = RequestHelper.GetQueryString <int>("uid"); } user = UserBLL.ReadUserMore(uid); if (user != null && user.Id > 0) { userGradeInfo = UserGradeBLL.ReadByMoney(user.MoneyUsed); userGrade = userGradeInfo.Id; } user.UserName = System.Web.HttpUtility.UrlDecode(user.UserName, System.Text.Encoding.UTF8); //分销商等级标题 user.Distributor_Grade_Title = (DistributorGradeBLL.ReadList().FirstOrDefault(d => user.Total_Commission >= d.Min_Amount && user.Total_Commission < d.Max_Amount) ?? new DistributorGradeInfo()).Title; }
protected void SubmitButton_Click(object sender, EventArgs e) { DistributorGradeInfo dis_grade = new DistributorGradeInfo(); dis_grade.Id = RequestHelper.GetQueryString <int>("ID"); dis_grade.Title = Title.Text.Trim(); dis_grade.Min_Amount = Convert.ToDecimal(Min_Amount.Text); dis_grade.Max_Amount = Convert.ToDecimal(Max_Amount.Text); dis_grade.Discount = Convert.ToDecimal(Discount.Text); if (dis_grade.Min_Amount >= dis_grade.Max_Amount) { ScriptHelper.Alert("等级上限必须大于下限"); } #region 判断等级范围是否重叠 var gradeList = DistributorGradeBLL.ReadList().Where(k => k.Id != dis_grade.Id).ToList(); if (gradeList.Any(k => (k.Min_Amount >= dis_grade.Min_Amount && k.Max_Amount <= dis_grade.Max_Amount) || (k.Min_Amount <= dis_grade.Min_Amount && k.Max_Amount >= dis_grade.Max_Amount) || (k.Min_Amount < dis_grade.Min_Amount && k.Max_Amount > dis_grade.Min_Amount && k.Max_Amount < dis_grade.Max_Amount) || (k.Min_Amount > dis_grade.Min_Amount && k.Min_Amount < dis_grade.Max_Amount && k.Max_Amount > dis_grade.Max_Amount))) { ScriptHelper.Alert("等级范围重叠,请重新输入"); } #endregion string alertMessage = ShopLanguage.ReadLanguage("AddOK"); if (dis_grade.Id <= 0) { CheckAdminPower("AddDistributorGrade", PowerCheckType.Single); int id = DistributorGradeBLL.Add(dis_grade); AdminLogBLL.Add(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("DistributorGrade"), id); } else { CheckAdminPower("UpdateDistributorGrade", PowerCheckType.Single); DistributorGradeBLL.Update(dis_grade); AdminLogBLL.Add(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("DistributorGrade"), dis_grade.Id); alertMessage = ShopLanguage.ReadLanguage("UpdateOK"); } ScriptHelper.Alert(alertMessage, "DistributorGrade.aspx"); }
//public Distributor() //{ // if (all_users == null) // { // all_users = UserBLL.ReadList(); // } //} protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CheckAdminPower("ReadDistributor", PowerCheckType.Single); TaskFactory tFactory = Task.Factory; List <Task> taskList = new List <Task>(); taskList.Add(tFactory.StartNew(() => { if (all_users == null) { all_users = UserBLL.ReadList(); } })); //Task t1 =new Task(()=> { // if (all_users == null) // { // all_users = UserBLL.ReadList(); // } //}) ; //t1.Start(); string action = RequestHelper.GetQueryString <string>("Action"); int id = RequestHelper.GetQueryString <int>("Id"); if (id > 0) { switch (action) { default: break; } } UserSearchInfo userSearch = new UserSearchInfo(); userSearch.UserName = HttpUtility.UrlEncode(RequestHelper.GetQueryString <string>("UserName"), System.Text.Encoding.UTF8); userSearch.Mobile = RequestHelper.GetQueryString <string>("Mobile"); userSearch.UserType = RequestHelper.GetQueryString <int>("usertype") == int.MinValue ? 3 : RequestHelper.GetQueryString <int>("usertype"); //分销商状态,默认1--正常 userSearch.Distributor_Status = RequestHelper.GetQueryString <int>("distributor_Status") == int.MinValue?1: RequestHelper.GetQueryString <int>("distributor_Status"); userSearch.StartRegisterDate = RequestHelper.GetQueryString <DateTime>("StartRegisterDate"); userSearch.EndRegisterDate = ShopCommon.SearchEndDate(RequestHelper.GetQueryString <DateTime>("EndRegisterDate")); UserName.Text = HttpUtility.UrlDecode(userSearch.UserName, System.Text.Encoding.UTF8); Mobile.Text = userSearch.Mobile; StartRegisterDate.Text = RequestHelper.GetQueryString <string>("StartRegisterDate"); EndRegisterDate.Text = RequestHelper.GetQueryString <string>("EndRegisterDate"); usertype = userSearch.UserType; distributor_Status = userSearch.Distributor_Status; PageSize = Session["AdminPageSize"] == null ? 20 : Convert.ToInt32(Session["AdminPageSize"]); userList = UserBLL.SearchList(CurrentPage, PageSize, userSearch, ref Count); //while (all_users == null) //{ // Thread.Sleep(100); // continue; //} //等待任务完成 Task.WaitAll(taskList.ToArray()); //推荐人用户名 userList.ForEach(k => k.Recommend_UserName = (all_users.FirstOrDefault(a => a.Id == k.Recommend_UserId) ?? new UserInfo()).UserName); userList.ForEach(k => k.Recommend_UserName = HttpUtility.UrlDecode(k.Recommend_UserName, System.Text.Encoding.UTF8)); userList.ForEach(k => k.Recommend_UserName = !string.IsNullOrWhiteSpace(k.Recommend_UserName) ? k.Recommend_UserName : "******"); AdminPageSize.Text = Session["AdminPageSize"] == null ? "20" : Session["AdminPageSize"].ToString(); userList.ForEach(k => k.UserName = HttpUtility.UrlDecode(k.UserName, System.Text.Encoding.UTF8)); var distributorGradeList = DistributorGradeBLL.ReadList(); userList.ForEach(k => k.Distributor_Grade_Title = (distributorGradeList.Where(d => k.Total_Commission >= d.Min_Amount && k.Total_Commission < d.Max_Amount).FirstOrDefault() ?? new DistributorGradeInfo()).Title); BindControl(userList, RecordList, MyPager); } }