protected void Page_Load(object sender, EventArgs e)
        {
            RegisterOEMSkins("form.css");
            RegisterOEMSkins("page.css");

            if (!IsPostBack)
            {
                title.InnerText = "添加商品";
                txtTime.Text    = DateTime.Today.AddMonths(3).ToString("yyyy-MM-dd");
                if (Request.QueryString["id"] != null)
                {
                    CommodityView view = CommodityServer.GetCommodity(Guid.Parse(Request.QueryString["id"]));
                    if (view != null)
                    {
                        btnAdd.Text          = "修改";
                        OldImgUrlDiv.Visible = true;
                        OldImgUrl.Text       = FileWeb + view.CoverImgUrl;
                        OldImgUrl.Style.Add(HtmlTextWriterStyle.Display, "none");
                        title.InnerText        = "修改商品";
                        txtTime.Text           = view.ValidityTime.ToString("yyyy-MM-dd");
                        txtCoommodityName.Text = view.CommodityName;
                        txtNeedIntegral.Text   = view.NeedIntegral + "";
                        txtRemark.Text         = view.Remark;
                        txtSort.Text           = view.SortNum + "";
                        ddlType.SelectedValue  = ((int)view.Type).ToString();
                        txtNum.Text            = view.ExchangSmsNumber.ToString();
                        lblName.Text           = view.CommodityName;
                        hidName.Value          = view.CommodityName;
                    }
                }
            }
        }
Beispiel #2
0
        protected void btnOk_Click(object sender, EventArgs e)
        {
            string msg = "下架";

            try
            {
                if (selOption.SelectedIndex == 0)
                {
                    msg = "上架";
                    CommodityServer.UpdateShelvesNum(Guid.Parse(hidId.Value), int.Parse(txtNum.Text), this.CurrentUser.UserName);
                }
                else
                {
                    CommodityServer.UpdateShelvesNum(Guid.Parse(hidId.Value), 0 - int.Parse(txtNum.Text), this.CurrentUser.UserName);
                }
            }
            catch (Exception ex)
            {
                ShowExceptionMessage(ex, msg);
            }
            selOption.SelectedIndex = 0;
            txtNum.Text             = "";
            hidId.Value             = "";
            hidNum.Value            = "";
            NewMethod(grv_commodity.PageIndex + 1);
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (!IsVaild())
            {
                return;
            }
            string msg = "添加";

            try
            {
                string        path = fileImg.HasFile ? Service.FileService.Upload(fileImg, "Commodity", "(jpg)|(gif)|(png)|(jpeg)", int.MaxValue) : OldImgUrl.Text.Replace(FileWeb, "");
                CommodityView view = new CommodityView
                {
                    ID               = Guid.NewGuid(),
                    CommodityName    = ddlType.SelectedValue == "1" ? txtCoommodityName.Text : hidName.Value,
                    NeedIntegral     = int.Parse(txtNeedIntegral.Text),
                    SortNum          = int.Parse(txtSort.Text),
                    ExchangeNumber   = 0,
                    State            = radEnable.Checked,
                    StockNumber      = 0,
                    SurplusNumber    = 0,
                    ValidityTime     = DateTime.Parse(txtTime.Text),
                    Remark           = txtRemark.Text,
                    ExchangSmsNumber = ddlType.SelectedValue == "2" ? int.Parse(txtNum.Text) : 0,
                    Type             = (CommodityType)int.Parse(ddlType.SelectedValue)
                };
                if (Request.QueryString["id"] != null)
                {
                    CommodityView views = CommodityServer.GetCommodity(Guid.Parse(Request.QueryString["id"]));
                    view.ExchangeNumber = views.ExchangeNumber;
                    view.StockNumber    = views.StockNumber;
                    view.SurplusNumber  = views.SurplusNumber;
                    msg              = "修改";
                    view.ID          = Guid.Parse((Request.QueryString["id"]));
                    view.CoverImgUrl = path;
                    CommodityServer.UpdateCommodity(view, CurrentUser.UserName);
                }
                else
                {
                    view.CoverImgUrl = path;
                    CommodityServer.InsertCommodity(view, this.CurrentUser.UserName);
                }
                RegisterScript(Page, "alert('" + msg + "成功');window.location.href='./CommodityList.aspx';");
            }
            catch (Exception ex)
            {
                ShowExceptionMessage(ex, msg);
            }
        }
Beispiel #4
0
 public bool ExChangreCommosity(Guid id, int exChangeNum)
 {
     try
     {
         OEMInfo oem = BasePage.SuperiorOEM;
         CommodityServer.ExChangeCommodity(id, exChangeNum, CurrentCompany, CurrentUser, oem == null ? OEMCommodityState.Success : OEMCommodityState.Processing, oem == null ? "B3B交易平台" : oem.SiteName, oem == null ? (Guid?)null : oem.Id);
         return(true);
     }
     catch (System.Data.Common.DbException ex)
     {
         Service.LogService.SaveExceptionLog(ex);
         throw new Exception("兑换商品发生未知错误,请稍后再试");
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #5
0
 protected void grv_commodity_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "disable")
         {
             CommodityServer.UpdateState(Guid.Parse(e.CommandArgument.ToString()), false, this.CurrentUser.UserName);
         }
         if (e.CommandName == "enable")
         {
             CommodityServer.UpdateState(Guid.Parse(e.CommandArgument.ToString()), true, this.CurrentUser.UserName);
         }
         NewMethod(grv_commodity.PageIndex + 1);
     }
     catch (Exception ex)
     {
         ShowExceptionMessage(ex, "修改");
     }
 }
Beispiel #6
0
 private void Query(Pagination pagination)
 {
     try
     {
         var query_list = CommodityServer.GetCommodityList(false, pagination);
         var list       = from item in query_list
                          select new
         {
             item.ID,
             item.Num,
             item.StockNumber,
             item.SurplusNumber,
             item.CommodityName,
             item.NeedIntegral,
             item.ExchangeNumber,
             State       = item.State ? "正常" : "禁用",
             StateInfo   = item.State ? "禁用" : "启用",
             ShelvesInfo = "<a href='javascript:ShangJia(\"" + item.ID + "\",\"" + item.SurplusNumber + "\");'>上下架</a>",
             StateCmd    = item.State ? "disable" : "enable"
         };
         this.grv_commodity.DataSource = list;
         this.grv_commodity.DataBind();
         if (query_list.Any())
         {
             this.pager.Visible = true;
             if (pagination.GetRowCount)
             {
                 this.pager.RowCount = pagination.RowCount;
             }
             grv_commodity.HeaderRow.TableSection = TableRowSection.TableHeader;
         }
         else
         {
             this.pager.Visible = false;
             showempty.Visible  = true;
         }
     }
     catch (Exception ex)
     {
         ShowExceptionMessage(ex, "查询");
     }
 }