Esempio n. 1
0
        private void GetList()
        {
            #region where
            string where = "";
            string name  = Request["name"];
            string State = Request["State"];
            if (!string.IsNullOrEmpty(name))
            {
                this.TextBox_name.Text = name;
                where += " and name like '%" + name.Replace("'", "''").Replace("%", "") + "%' ";
            }
            if (!string.IsNullOrEmpty(State))
            {
                this.DropDownList_State.SelectedValue = State;
                where += " and State = '" + State.Replace("'", "''") + "' ";
            }
            #endregion

            SOSOshop.BLL.Integral.MemberIntegralGift bll = new SOSOshop.BLL.Integral.MemberIntegralGift();
            int    pageindex = 1; int.TryParse(Request["current"], out pageindex);
            int    pagesize  = 15;
            string sort      = Request["sort"];//排序
            if (string.IsNullOrEmpty(sort) || (sort.Contains("asc") == false && sort.Contains("desc") == false))
            {
                sort = "id DESC";
            }
            Repeater1.DataSource = bll.GetList(where, sort, pageindex, pagesize);
            Repeater1.DataBind();
            int recordcount = bll.GetListCount(where);
            page(recordcount, pageindex, pagesize);//分页
        }
Esempio n. 2
0
        private void Save()
        {
            SOSOshop.BLL.Integral.MemberIntegralGift bll = new SOSOshop.BLL.Integral.MemberIntegralGift();

            string Name = this.txtName.Text.Trim();

            if (!string.IsNullOrEmpty(Name))
            {
                if (Name.Length < 2)
                {
                    this.ltlMsg.Text     = "保存失败!礼品名称必须大于等于2个字!";
                    this.pnlMsg.CssClass = "actionErr";
                    pnlMsg.Visible       = true;
                    return;
                }
                DataTable dt = bll.GetList("and Name='" + Name.Replace("'", "''") + "'");
                if (dt.Rows.Count > 1)
                {
                    this.ltlMsg.Text     = "保存失败!已经有相同的礼品名称!";
                    this.pnlMsg.CssClass = "actionErr";
                    pnlMsg.Visible       = true;
                    return;
                }
            }
            else
            {
                this.ltlMsg.Text     = "保存失败!请填写礼品名称!";
                this.pnlMsg.CssClass = "actionErr";
                return;
            }

            string Detail = this.txtDetail.Text.Trim();

            if (!string.IsNullOrEmpty(Detail))
            {
                if (Detail.Length < 2)
                {
                    this.ltlMsg.Text     = "保存失败!礼品说明必须大于等于2个字!";
                    this.pnlMsg.CssClass = "actionErr";
                    pnlMsg.Visible       = true;
                    return;
                }
            }
            else
            {
                this.ltlMsg.Text     = "保存失败!请填写礼品名称!";
                this.pnlMsg.CssClass = "actionErr";
                return;
            }

            decimal Integral = 0; decimal.TryParse(this.txtIntegral.Text.Trim(), out Integral);

            if (Integral <= 0)
            {
                this.ltlMsg.Text     = "保存失败!请填写兑换积分!";
                this.pnlMsg.CssClass = "actionErr";
                return;
            }
            decimal Number = 0; decimal.TryParse(this.txtNumber.Text.Trim(), out Number);

            if (Number <= 0)
            {
                this.ltlMsg.Text     = "保存失败!请填写可兑换数量!";
                this.pnlMsg.CssClass = "actionErr";
                return;
            }

            string Member_Class = ",";

            foreach (ListItem item in this.ckbMember_Class.Items)
            {
                if (item.Selected)
                {
                    Member_Class += item.Value + ",";
                }
            }
            if (Member_Class.Length <= 1)
            {
                this.ltlMsg.Text     = "保存失败!请至少选择一个可兑换客户类型!";
                this.pnlMsg.CssClass = "actionErr";
                return;
            }

            SOSOshop.Model.Integral.MemberIntegralGift model = new SOSOshop.Model.Integral.MemberIntegralGift()
            {
                id           = int.Parse(this.txtId.Value),
                name         = Name,
                detail       = Detail,
                Integral     = Integral,
                Number       = Number,
                Member_Class = Member_Class,
                State        = 1
            };

            try
            {
                bool ok = bll.Edit(model);
                if (ViewState["TempFilePath"] != null)
                {
                    string item     = ViewState["TempFilePath"].ToString();
                    string fileName = Server.MapPath("/JFimages/" + model.id + ".jpg");
                    System.IO.File.Copy(item, fileName, true);
                }
                if (!ok)
                {
                    this.ltlMsg.Text     = "保存失败!";
                    this.pnlMsg.CssClass = "actionErr";
                }
                else
                {
                    this.ltlMsg.Text     = "保存成功!";
                    this.pnlMsg.CssClass = "actionOk";

                    #region 后台用户操作日志记录
                    SOSOshop.Model.AdminInfo adminInfo = SOSOshop.BLL.AdministrorManager.Get();
                    SOSOshop.BLL.Logs.Log.LogAdminAdd("添加积分礼品", (adminInfo == null ? 0 : adminInfo.AdminId), (adminInfo == null ? "" : adminInfo.AdminName), 1);
                    #endregion
                }
                if (ok)
                {
                    this.ltlMsg.Text    += "<script>setTimeout(function(){window.location='" + this.ReturnUrl.Value + "';},2000);</script>";
                    this.formtbl.Visible = false;
                    this.button1.Visible = false;
                    this.button2.Visible = false;
                }
            }
            catch (Exception ex)
            {
                this.ltlMsg.Text     = "保存失败:<br/>" + ex.ToString();
                this.pnlMsg.CssClass = "actionErr";
            }
            finally
            {
                this.pnlMsg.Visible = true;
                bll   = null;
                model = null;
            }
        }