Example #1
0
        protected void BtnWork_Click(object sender, EventArgs e)
        {
            ShowShop.Model.Admin.AdminInfo adminInfo = (ShowShop.Model.Admin.AdminInfo)ShowShop.Common.AdministrorManager.Get();
            ShowShop.BLL.Member.MemberAccount memberBll = new ShowShop.BLL.Member.MemberAccount();
            ShowShop.BLL.Member.UserInfoNote noteBll = new ShowShop.BLL.Member.UserInfoNote();
            ShowShop.Model.Member.UserInfoNote noteModel = new ShowShop.Model.Member.UserInfoNote();
            if (ViewState["Opreate"].ToString().Equals("add"))
            {
                noteModel.BuckleOrAdd = 0;  //添加
            }
            else
            {
                noteModel.BuckleOrAdd = 1;  //减
            }
            noteModel.NoteName = adminInfo.AdminName;
            noteModel.NoteType = 0;//点卷
            noteModel.NoteDate = Convert.ToDateTime(System.DateTime.Now);
            noteModel.Causation = this.txtWhy.Text.Trim().ToString();
            noteModel.BosomNote = this.txtLog.Text.Trim().ToString();
            //全部用户
            if (ViewState["M"].ToString() == "1")
            {
                List<ShowShop.Model.Member.MemberAccount> accountList = memberBll.GetAll("");
                foreach (ShowShop.Model.Member.MemberAccount item in accountList)
                {
                    switch (ViewState["Opreate"].ToString())
                    {
                        case "add":
                            item.Coupons = Convert.ToDecimal(item.Coupons) + Convert.ToDecimal(this.txtWrap.Text.Trim());
                            break;
                        case "allay":
                            if (Convert.ToDecimal(this.txtWrap.Text.Trim())<Convert.ToDecimal(item.Coupons) )
                            {
                                item.Coupons = Convert.ToDecimal(item.Coupons)-Convert.ToDecimal(this.txtWrap.Text.Trim());
                            }
                            else
                            {
                                this.ltlMsg.Text = "减少的点卷数量大于系统记录的数量!";
                                this.pnlMsg.Visible = true;
                                this.pnlMsg.CssClass = "actionErr";
                                return;
                            }
                            break;
                        default:
                            break;
                    }
                    memberBll.Update(item);
                    noteModel.UserID = Convert.ToInt32(item.UID);
                    noteModel.Username = item.UserId;
                    noteModel.TicketCount = Convert.ToDecimal(this.txtWrap.Text.Trim());
                    noteBll.Add(noteModel);
                }
            }
            //指定用户组
            if (ViewState["M"].ToString() == "2")
            {
                    //获取会员类型
                string typeId = this.cbxlMemberRank.SelectedValue;
                List<ShowShop.Model.Member.MemberAccount> accountList = merberBll.GetAll("UserGroup=" + typeId);
                foreach (ShowShop.Model.Member.MemberAccount item in accountList)
                {
                        switch (ViewState["Opreate"].ToString())
                        {
                                    case "add":
                                        item.Coupons = Convert.ToDecimal(item.Coupons) + Convert.ToDecimal(this.txtWrap.Text.Trim());
                                        break;
                                    case "allay":
                                        if (Convert.ToDecimal(this.txtWrap.Text.Trim()) < Convert.ToDecimal(item.Coupons))
                                        {
                                            item.Coupons = Convert.ToDecimal(item.Coupons) - Convert.ToDecimal(this.txtWrap.Text.Trim());
                                        }
                                        else
                                        {
                                            this.ltlMsg.Text = "减少的点卷数量大于系统记录的数量!";
                                            this.pnlMsg.Visible = true;
                                            this.pnlMsg.CssClass = "actionErr";
                                            return;
                                        }
                                        break;
                                    default:
                                        break;
                         }
                                memberBll.Update(item);
                                noteModel.UserID = Convert.ToInt32(item.UID);
                                noteModel.Username = item.UserId;
                                noteModel.TicketCount = Convert.ToDecimal(this.txtWrap.Text.Trim());
                                noteBll.Add(noteModel);
                 }

            }
            //指定用户
            if (ViewState["M"].ToString() == "3")
            {
                string assigner= this.txtName.Text.Trim();
                String[] name = assigner.Split(',');
                int con = name.Length;
                for (int i = 0; i < con; i++)
                {
                    string userName = name[i].ToString();
                    List<ShowShop.Model.Member.MemberAccount> accountList = memberBll.GetAll("UserId = '" + userName + "'");
                    foreach (ShowShop.Model.Member.MemberAccount item in accountList)
                    {
                         switch (ViewState["Opreate"].ToString())
                                {
                                    case "add":
                                        item.Coupons = Convert.ToDecimal(item.Coupons) + Convert.ToDecimal(this.txtWrap.Text.Trim());
                                        break;
                                    case "allay":
                                        if (Convert.ToDecimal(this.txtWrap.Text.Trim()) < Convert.ToDecimal(item.Coupons))
                                        {
                                            item.Coupons = Convert.ToDecimal(item.Coupons) - Convert.ToDecimal(this.txtWrap.Text.Trim());
                                        }
                                        else
                                        {
                                            this.ltlMsg.Text = "减少的点卷数量大于系统记录的数量!";
                                            this.pnlMsg.Visible = true;
                                            this.pnlMsg.CssClass = "actionErr";
                                            return;
                                        }
                                        break;
                                    default:
                                        break;
                                }
                                memberBll.Update(item);
                                noteModel.UserID = Convert.ToInt32(item.UID);
                                noteModel.Username = item.UserId;
                                noteModel.TicketCount = Convert.ToDecimal(this.txtWrap.Text.Trim());
                                noteBll.Add(noteModel);
                    }
                }
            }
            this.ltlMsg.Text = "编辑点卷成功!";
            this.pnlMsg.Visible = true;
            this.pnlMsg.CssClass = "actionOk";
        }
Example #2
0
        //批量事件(添加与减少)
        protected void BtnWork_Click(object sender, EventArgs e)
        {
            ShowShop.Model.Admin.AdminInfo adminInfo = (ShowShop.Model.Admin.AdminInfo)ShowShop.Common.AdministrorManager.Get();
            ShowShop.BLL.Member.MemberAccount memberBll = new ShowShop.BLL.Member.MemberAccount();
            ShowShop.BLL.Member.UserInfoNote noteBll = new ShowShop.BLL.Member.UserInfoNote();
            ShowShop.Model.Member.UserInfoNote noteModel = new ShowShop.Model.Member.UserInfoNote();
            if (ViewState["Opreate"].ToString().Equals("add"))
            {
                noteModel.BuckleOrAdd = 0;  //添加
            }
            else
            {
                noteModel.BuckleOrAdd = 1;  //减少
            }
            noteModel.NoteName = adminInfo.AdminName;
            noteModel.NoteType = 2;
            noteModel.NoteDate = Convert.ToDateTime(System.DateTime.Now.ToShortDateString());
            noteModel.Causation = this.txtWhy.Text.Trim().ToString();
            noteModel.BosomNote = this.txtLog.Text.Trim().ToString();
            //所有会员
            if (ViewState["M"].ToString() == "1")
            {
                List <ShowShop.Model.Member.MemberAccount> accountList= memberBll.GetAll("");
                foreach (ShowShop.Model.Member.MemberAccount item in accountList)
                {
                    TimeSpan oldtime = new TimeSpan(Convert.ToDateTime(item.PeriodOfValidity).Ticks);
                    if (ViewState["time"].ToString() == "4")
                    {
                        switch (ViewState["Opreate"].ToString())
                        {
                            case "add":
                                if (Convert.ToDateTime(this.txtManageTime.Text) > Convert.ToDateTime(item.PeriodOfValidity))
                                {
                                    item.PeriodOfValidity = Convert.ToDateTime(this.txtManageTime.Text);
                                }
                                else
                                {
                                    this.ltlMsg.Text = "添加的有效期小于系统记录的有效期!";
                                    this.pnlMsg.Visible = true;
                                    this.pnlMsg.CssClass = "actionErr";
                                    return;
                                }
                                break;
                            case "allay":
                                if (Convert.ToDateTime(this.txtManageTime.Text) < Convert.ToDateTime(item.PeriodOfValidity))
                                {
                                    item.PeriodOfValidity = Convert.ToDateTime(this.txtManageTime.Text);
                                }
                                else
                                {
                                    this.ltlMsg.Text = "减少的有效期大于系统记录的有效期!";
                                    this.pnlMsg.Visible = true;
                                    this.pnlMsg.CssClass = "actionErr";
                                    return;
                                }
                                break;
                            default:
                                break;
                        }

                    }
                    else
                    {   //归0
                        item.PeriodOfValidity = Convert.ToDateTime(System.DateTime.Now.ToShortDateString());
                    }
                    memberBll.Update(item);
                    TimeSpan newtime=new TimeSpan(Convert.ToDateTime(this.txtManageTime.Text).Ticks);
                    TimeSpan gap=oldtime.Subtract(newtime).Duration();
                    noteModel.TicketCount=Convert.ToDecimal(gap.Days);
                    noteModel.UserID = Convert.ToInt32(item.UID);
                    noteModel.Username = item.UserId;
                    noteBll.Add(noteModel);
                }

            }
            //指定会员组
            if (ViewState["M"].ToString() == "2")
            {   //获取会员类型
                string typeId = this.cbxlMemberRank.SelectedValue;
                List<ShowShop.Model.Member.MemberAccount> accountList = merberBll.GetAll("UserGroup="+typeId);
                foreach (ShowShop.Model.Member.MemberAccount item in accountList)
                {
                                TimeSpan oldtime = new TimeSpan(Convert.ToDateTime(item.PeriodOfValidity).Ticks);
                                if (ViewState["time"].ToString() == "4")
                                {

                                    switch (ViewState["Opreate"].ToString())
                                    {
                                        case "add":
                                            if (Convert.ToDateTime(this.txtManageTime.Text) > Convert.ToDateTime(item.PeriodOfValidity))
                                            {
                                                item.PeriodOfValidity = Convert.ToDateTime(this.txtManageTime.Text);
                                            }
                                            else
                                            {
                                                this.ltlMsg.Text = "添加的有效期小于系统记录的有效期!";
                                                this.pnlMsg.Visible = true;
                                                this.pnlMsg.CssClass = "actionErr";
                                                return;
                                            }
                                            break;
                                        case "allay":
                                            if (Convert.ToDateTime(this.txtManageTime.Text) < Convert.ToDateTime(item.PeriodOfValidity))
                                            {
                                                item.PeriodOfValidity = Convert.ToDateTime(this.txtManageTime.Text);
                                            }
                                            else
                                            {
                                                this.ltlMsg.Text = "减少的有效期大于系统记录的有效期!";
                                                this.pnlMsg.Visible = true;
                                                this.pnlMsg.CssClass = "actionErr";
                                                return;
                                            }
                                            break;
                                        default:
                                            break;
                                    }
                                }
                                else
                                {   //归0
                                    item.PeriodOfValidity = Convert.ToDateTime(System.DateTime.Now.ToShortDateString());
                                }
                                memberBll.Update(item);
                                TimeSpan newtime = new TimeSpan(Convert.ToDateTime(this.txtManageTime.Text).Ticks);
                                TimeSpan gap = oldtime.Subtract(newtime).Duration();
                                noteModel.TicketCount = Convert.ToDecimal(gap.Days);
                                noteModel.UserID = Convert.ToInt32(item.UID);
                                noteModel.Username = item.UserId;
                                noteBll.Add(noteModel);
                 }
            }
            //指定用户
            if(ViewState["M"].ToString() =="3")
            {
                string assigner= this.txtName.Text.Trim();
                String[] name = assigner.Split(',');
                int con = name.Length;
                for (int i = 0; i < con; i++)
                {
                    string userName = name[i].ToString();
                    List<ShowShop.Model.Member.MemberAccount> accountList = memberBll.GetAll("UserId = '" + userName + "'");
                    foreach (ShowShop.Model.Member.MemberAccount item in accountList)
                    {
                        TimeSpan oldtime = new TimeSpan(Convert.ToDateTime(item.PeriodOfValidity).Ticks);
                        if (ViewState["time"].ToString() == "4")
                        {
                            switch (ViewState["Opreate"].ToString())
                            {
                                case "add":
                                    if (Convert.ToDateTime(this.txtManageTime.Text) > Convert.ToDateTime(item.PeriodOfValidity))
                                    {
                                        item.PeriodOfValidity = Convert.ToDateTime(this.txtManageTime.Text);
                                    }
                                    else
                                    {
                                        this.ltlMsg.Text = "添加的有效期小于系统记录的有效期!";
                                        this.pnlMsg.Visible = true;
                                        this.pnlMsg.CssClass = "actionErr";
                                        return;
                                    }
                                    break;
                                case "allay":
                                    if (Convert.ToDateTime(this.txtManageTime.Text) < Convert.ToDateTime(item.PeriodOfValidity))
                                    {
                                        item.PeriodOfValidity = Convert.ToDateTime(this.txtManageTime.Text);
                                    }
                                    else
                                    {
                                        this.ltlMsg.Text = "减少的有效期大于系统记录的有效期!";
                                        this.pnlMsg.Visible = true;
                                        this.pnlMsg.CssClass = "actionErr";
                                        return;
                                    }
                                    break;
                                default:
                                    break;
                            }
                        }
                        else
                        {   //归0
                            item.PeriodOfValidity = Convert.ToDateTime(System.DateTime.Now.ToShortDateString());
                        }
                        memberBll.Update(item);
                        TimeSpan newtime = new TimeSpan(Convert.ToDateTime(this.txtManageTime.Text).Ticks);
                        TimeSpan gap = oldtime.Subtract(newtime).Duration();
                        noteModel.TicketCount = Convert.ToDecimal(gap.Days);
                        noteModel.UserID = Convert.ToInt32(item.UID);
                        noteModel.Username = item.UserId;
                        noteBll.Add(noteModel);
                    }
                }
            }
            this.ltlMsg.Text = "编辑有效期成功!";
            this.pnlMsg.Visible = true;
            this.pnlMsg.CssClass = "actionOk";
        }
Example #3
0
        private void SaveAccount()
        {
            ShowShop.BLL.Member.MemberAccount bll = new ShowShop.BLL.Member.MemberAccount();
            ShowShop.Model.Member.MemberAccount model = new ShowShop.Model.Member.MemberAccount();

            model.UserGroup = ChangeHope.Common.StringHelper.StringToInt(this.ddlUserGroup.SelectedValue);
            model.UserId = this.txtUserId.Text;
            model.UserType = ChangeHope.Common.StringHelper.StringToInt(this.ddlUserType.SelectedValue);
            model.State = this.ckbState.Checked ? 1 : 0;
            model.Signed = this.txtSigned.Text;
            model.Question = this.txtQuestion.Text;
            model.PassWord = this.txtPassword.Text;
            model.Answer = txtAnswer.Text;
            model.Email = txtEmail.Text;

            if (ViewState["uid"] != null)
            {
                model.UID = Convert.ToInt32(ViewState["uid"].ToString());
                model.RegisterDate = Convert.ToDateTime(ViewState["RegisterDate"].ToString());
                model.RegisterIP = ViewState["RegisterIP"].ToString();
                model.LastLoginDate = Convert.ToDateTime(ViewState["LastLoginDate"].ToString());
                model.LastLoginIP = ViewState["LastLoginIP"].ToString();
                model.LoginTimes = Convert.ToInt32(ViewState["LoginTimes"].ToString());
                model.Capital = Convert.ToDecimal(ViewState["Capital"].ToString());
                model.Coupons = Convert.ToDecimal(ViewState["Coupons"].ToString());
                model.Points = Convert.ToDecimal(ViewState["Points"].ToString());
                model.PeriodOfValidity = Convert.ToDateTime(ViewState["PeriodOfValidity"].ToString());
                bll.Update(model);
            }
            else
            {
                model.RegisterDate = DateTime.Now;
                model.RegisterIP = Request.UserHostAddress;
                model.LastLoginDate = DateTime.Now;
                model.LastLoginIP = Request.UserHostAddress;
                model.LoginTimes = 0;
                model.Capital = 0;
                model.Coupons = 0;
                model.Points = 0;
                model.PeriodOfValidity = DateTime.Now;
                bll.Add(model);
            }
        }