Exemple #1
0
        /// <summary>
        /// 取得要编辑的积分礼品
        /// </summary>
        private void GetMode()
        {
            int id = 0; int.TryParse(Request["id"], out id);

            SOSOshop.BLL.Integral.MemberIntegralGift   bll   = new SOSOshop.BLL.Integral.MemberIntegralGift();
            SOSOshop.Model.Integral.MemberIntegralGift model = null;
            if (id <= 0 || (model = bll.GetModel(id)) == null || model.State == 0)
            {
                this.ltlMsg.Text    += "<script>setTimeout(function(){alert('请选择要编辑的积分礼品');window.location='" + this.ReturnUrl.Value + "';},2000);</script>";
                this.formtbl.Visible = false;
                this.button1.Visible = false;
                this.button2.Visible = false;
                return;
            }
            this.txtId.Value      = model.id.ToString();
            this.txtName.Text     = model.name;
            this.txtDetail.Text   = model.detail;
            this.txtIntegral.Text = model.Integral.ToString();
            this.txtNumber.Text   = model.Number.ToString();
            foreach (ListItem item in this.ckbMember_Class.Items)
            {
                item.Selected = model.Member_Class.Contains("," + item.Value + ",");
            }
        }
Exemple #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;
            }
        }
        private void Save()
        {
            SOSOshop.BLL.Integral.MemberIntegralGiftExchange   bll1   = new SOSOshop.BLL.Integral.MemberIntegralGiftExchange();
            SOSOshop.Model.Integral.MemberIntegralGiftExchange model1 = null;
            SOSOshop.BLL.Integral.MemberIntegralGift           bll2   = new SOSOshop.BLL.Integral.MemberIntegralGift();
            SOSOshop.Model.Integral.MemberIntegralGift         model2 = null;
            //处理状态修改
            int State = int.Parse(this.ddlState.SelectedValue);

            try
            {
                bool   ok  = true;
                string err = "";
                model1 = bll1.GetModel(int.Parse(this.txtId.Value));
                if ((model2 = bll2.GetModel(model1.Gift_ID)) == null || model2.State == 0)
                {
                    err = "无法处理兑换礼品申请,不存在此礼品";
                }
                else if (model2.State == 2)
                {
                    err = "无法处理兑换礼品申请,此礼品已下架";
                }
                //已预扣数量,不用判断
                //else if (model2.Number < model1.Gift_Number)
                //{
                //    err = "无法处理兑换礼品申请,此礼品可兑换数量小于兑换数量";
                //}
                else
                {
                    if (model1.State != State)
                    {
                        if (model1.State == 0)
                        {
                            var db = bll1._db;
                            using (var conn = db.CreateConnection())
                            {
                                conn.Open();
                                var tran = conn.BeginTransaction();
                                try
                                {
                                    SOSOshop.Model.AdminInfo adminInfo = SOSOshop.BLL.AdministrorManager.Get();
                                    string s         = string.Format(@"if exists(select * from MemberIntegralGiftExchange where [State]=0 and [id]={0}) begin 
update MemberIntegralGiftExchange set ontime=getdate(),Editer={1},[State]={2} 
where [State]=0 and [id]={0} 
declare @uid int,@Gift_ID int,@Gift_Number decimal,@Integral decimal  
select @uid = uid, @Gift_ID = Gift_ID, @Gift_Number = Gift_Number from MemberIntegralGiftExchange where [id]={0}
select @Integral = Integral * @Gift_Number from MemberIntegralGift where [id]=@Gift_ID 
update MemberIntegralGift set Number = Number - @Gift_Number where [id]=@Gift_ID
update MemberIntegral set realityIntegral = realityIntegral - @Integral where [uid]=@uid 
end", model1.id, adminInfo == null ? 0 : adminInfo.AdminId, State);
                                    var    dbCommand = db.GetSqlStringCommand(s);
                                    db.ExecuteScalar(dbCommand, tran);
                                    tran.Commit();
                                }
                                catch (Exception e)
                                {
                                    tran.Rollback();
                                    err = e.Message;
                                    ok  = false;
                                }
                            }
                        }
                        else
                        {
                            if (State == 0)
                            {
                                ok = QuXiao(model1.id);
                            }
                            if (State == 1)
                            {
                                ok = DaiChuli(model1.id);
                            }
                            if (State == 2)
                            {
                                ok = YiChuli(model1.id);
                            }
                            if (State == 3)
                            {
                                ok = YiYouji(model1.id);
                            }
                            if (ok && !string.IsNullOrEmpty(this.txtRemark.Text.Trim()))
                            {
                                var db = bll1._db;
                                using (var conn = db.CreateConnection())
                                {
                                    conn.Open();
                                    try
                                    {
                                        SOSOshop.Model.AdminInfo adminInfo = SOSOshop.BLL.AdministrorManager.Get();
                                        string s         = "update MemberIntegralGiftExchange set remark=@remark where [id]=" + model1.id;
                                        var    dbCommand = db.GetSqlStringCommand(s);
                                        db.AddInParameter(dbCommand, "remark", DbType.AnsiString, this.txtRemark.Text.Trim());
                                        db.ExecuteNonQuery(dbCommand);
                                    }
                                    catch (Exception e)
                                    {
                                        err = e.Message;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        this.pnlMsg.Visible  = true;
                        this.ltlMsg.Text     = "未进行任何处理!";
                        this.pnlMsg.CssClass = "actionErr";
                        this.ltlMsg.Text    += "<script>setTimeout(function(){window.location='" + this.ReturnUrl.Value + "';},2000);</script>";
                        this.button1.Visible = false;
                        this.button2.Visible = false;
                        return;
                    }
                }

                this.pnlMsg.Visible = true;
                if (!ok)
                {
                    this.ltlMsg.Text     = "保存失败!" + err;
                    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("处理兑换礼品申请[id:" + model1.id + ",状态改变:" + State + "]", (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.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;
            }
        }
        /// <summary>
        /// 取得要兑换的积分礼品
        /// </summary>
        private void GetMode()
        {
            int id = 0; int.TryParse(Request["id"], out id);

            SOSOshop.BLL.Integral.MemberIntegralGiftExchange   bll1   = new SOSOshop.BLL.Integral.MemberIntegralGiftExchange();
            SOSOshop.Model.Integral.MemberIntegralGiftExchange model1 = null;
            SOSOshop.BLL.Integral.MemberIntegralGift           bll2   = new SOSOshop.BLL.Integral.MemberIntegralGift();
            SOSOshop.Model.Integral.MemberIntegralGift         model2 = null;
            string err = "";

            if (id <= 0 || (model1 = bll1.GetModel(id)) == null)
            {
                err = "请选择要处理的兑换礼品申请";
            }
            else
            {
                if ((model2 = bll2.GetModel(model1.Gift_ID)) == null || model2.State == 0)
                {
                    err = "无法处理兑换礼品申请,不存在此礼品";
                }
                else if (model2.State == 2)
                {
                    err = "无法处理兑换礼品申请,此礼品已下架";
                }
                //已经预扣了数量,这里就不用判断数量了
                //else if (model2.Number < model1.Gift_Number)
                //{
                //    err = "无法处理兑换礼品申请,此礼品可兑换数量小于兑换数量";
                //}
            }
            if (err != "")
            {
                this.pnlMsg.Visible  = true;
                this.ltlMsg.Text    += "<script>setTimeout(function(){alert('" + err + "');window.location='" + this.ReturnUrl.Value + "';},2000);</script>";
                this.button1.Visible = false;
                this.button2.Visible = false;
                return;
            }

            this.txtId.Value              = model1.id.ToString();
            this.txtUID.Value             = model1.uid.ToString();
            this.txtTruename.Text         = model1.truename;
            this.txtPhone.Text            = model1.phone;
            this.txtCompanyName.Text      = model1.CompanyName;
            this.txtGift_Number.Text      = Convert.ToInt32(model1.Gift_Number).ToString();
            this.txtConsigneeAddress.Text = model1.ConsigneeAddress;
            this.txtConsigneeName.Text    = model1.ConsigneeName;
            this.txtConsigneePhone.Text   = model1.ConsigneePhone;
            this.ddlState.SelectedValue   = model1.State.ToString();
            this.txtRemark.Text           = model1.Remark;

            this.txtGId.Value     = model2.id.ToString();
            this.txtName.Text     = model2.name;
            this.txtDetail.Text   = model2.detail;
            this.txtIntegral.Text = model2.Integral.ToString();
            this.txtNumber.Text   = Convert.ToInt32(model2.Number).ToString();
            string mc = ""; foreach (ListItem item in this.ckbMember_Class.Items)

            {
                if (model2.Member_Class.Contains("," + item.Value + ","))
                {
                    mc += item.Text + ",";
                }
            }

            this.txtMember_Class.Text = mc.TrimEnd(',');
        }