//批量删除
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("_ybd_goods_spec_item", EnumCollection.ActionEnum.Delete.ToString()); //检查权限
            int sucCount   = 0;
            int errorCount = 0;

            BLL.goods_spec_item bll = new BLL.goods_spec_item();
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int      id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    if (bll.Delete(id))
                    {
                        sucCount += 1;
                    }
                    else
                    {
                        errorCount += 1;
                    }
                }
            }
            AddAdminLog(EnumCollection.ActionEnum.Delete.ToString(), "删除商品规格项" + sucCount + "条,失败" + errorCount + "条"); //记录日志
            JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("Manage.aspx", "keywords={0}", this.keywords));
        }
        private void BindData()
        {
            #region 组装查询条件
            string whereStr  = " 1 = 1 ";
            string _keywords = keywords.Replace("'", "");

            if (!string.IsNullOrEmpty(_keywords))
            {
                if (Utils.IsSafeSqlString(_keywords))
                {
                    whereStr += " and (Title like  '%" + _keywords + "%')";
                }
                else
                {
                    JscriptMsg("搜索关键词中包含危险字符,检索终止!", Utils.CombUrlTxt("Manage.aspx", "keywords={0}", ""));
                    return;
                }
            }
            #endregion

            this.page        = RequestHelper.GetQueryInt("page", 1);
            txtKeywords.Text = this.keywords;
            BLL.goods_spec_item bll = new BLL.goods_spec_item();
            this.rptList.DataSource = bll.GetListByPage(whereStr, "ID DESC", this.page, this.pageSize);
            this.rptList.DataBind();

            this.totalCount = bll.GetRecordCount(whereStr);
            //绑定页码
            txtPageNum.Text = this.pageSize.ToString();
            string pageUrl = Utils.CombUrlTxt("Manage.aspx", "keywords={0}&page={1}", this.keywords, "__id__");
            PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
        }
        private void ShowInfo(int _id)
        {
            BLL.goods_spec_item   bll   = new BLL.goods_spec_item();
            Model.goods_spec_item model = bll.GetModel(_id);

            txtSort.Text  = model.sort.ToString();
            txtTitle.Text = model.name;
        }
Beispiel #4
0
        //数据绑定
        private void RptBind()
        {
            BLL.goods_spec_item bll = new BLL.goods_spec_item();
            DataTable           dt  = bll.GetListNew(this.goods_id.ToString());

            this.rptList.DataSource = dt;
            this.rptList.DataBind();

            if (new BLL.goods_spec_item().GetRecordCount(" parent_id=0 and goods_id=" + this.goods_id) >= 1)
            {
                this.is_show = "1";
            }
        }
Beispiel #5
0
 private void BindInfo()
 {
     BLL.goods_spec_item   bll   = new BLL.goods_spec_item();
     Model.goods_spec_item model = bll.GetModel(this.id);
     if (model == null)
     {
         JscriptMsg("信息不存在或已被删除!", "back");
         return;
     }
     txtgoods_id.Text  = model.goods_id + "";
     txtname.Text      = model.name + "";
     txtparent_id.Text = model.parent_id + "";
     txtsort.Text      = model.sort + "";
 }
Beispiel #6
0
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("_ybd_goods_spec_item", EnumCollection.ActionEnum.Add.ToString()); //检查权限

            #region
            string strError = string.Empty;
            if (txtgoods_id.Text.Trim() == "" || txtgoods_id.Text.Trim().Length > 4)
            {
                strError += "商品id为空或超出长度![br]";
            }
            if (txtname.Text.Trim() == "" || txtname.Text.Trim().Length > 50)
            {
                strError += "规格名称为空或超出长度![br]";
            }
            if (txtparent_id.Text.Trim() == "" || txtparent_id.Text.Trim().Length > 4)
            {
                strError += "父级规格为空或超出长度![br]";
            }
            if (txtsort.Text.Trim() == "" || txtsort.Text.Trim().Length > 4)
            {
                strError += "排序为空或超出长度![br]";
            }

            if (strError != string.Empty)
            {
                JscriptMsg(strError, "", "Error");
                return;
            }
            #endregion

            Model.goods_spec_item model = new Model.goods_spec_item();
            BLL.goods_spec_item   bll   = new BLL.goods_spec_item();

            model.goods_id  = Convert.ToInt32(txtgoods_id.Text);
            model.name      = Convert.ToString(txtname.Text);
            model.parent_id = Convert.ToInt32(txtparent_id.Text);
            model.sort      = Convert.ToInt32(txtsort.Text);

            int id = bll.Add(model);
            if (id > 0)
            {
                AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加商品规格项信息,主键:" + id); //记录日志
                JscriptMsg("添加商品规格项信息成功!", "Manage.aspx", "");
            }
            else
            {
                JscriptMsg("保存过程中发生错误!", "");
            }
        }
 /// <summary>
 /// 批量删除数据
 /// </summary>
 public bool DeleteNew(int id)
 {
     Model.goods_spec_item item_model = new BLL.goods_spec_item().GetModel(id);
     if (item_model != null)
     {
         if (item_model.parent_id == 0)
         {
             DataTable dt = new BLL.goods_spec_item().GetList("parent_id=" + item_model.id.ToString());
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 dal.DeleteNew(Utils.StrToInt(dt.Rows[i]["id"].ToString(), 0));
             }
         }
     }
     return(dal.DeleteNew(id));
 }
        //修改
        #region 修改操作=================================
        private bool DoModify(int _id)
        {
            bool result = false;

            BLL.goods_spec_item   bll   = new BLL.goods_spec_item();
            Model.goods_spec_item model = bll.GetModel(_id);

            model.name    = txtTitle.Text.Trim();
            model.sort    = Utils.StrToInt(txtSort.Text.Trim(), 0);
            this.goods_id = model.goods_id;

            if (bll.Update(model))
            {
                return(true);
            }
            return(result);
        }
Beispiel #9
0
 //保存排序
 protected void btnSave_Click(object sender, EventArgs e)
 {
     ChkAdminLevel("_goods_list", EnumCollection.ActionEnum.Modify.ToString()); //检查权限
     BLL.goods_spec_item bll = new BLL.goods_spec_item();
     for (int i = 0; i < rptList.Items.Count; i++)
     {
         int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
         int sortId;
         if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtsort")).Text.Trim(), out sortId))
         {
             sortId = 1;
         }
         bll.UpdateField(id, "sort=" + sortId.ToString());
     }
     AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "保存商品规格排序"); //记录日志
     JscriptMsg("保存排序成功!", "goods_spec.aspx?page=" + this.page + "&goods_id=" + this.goods_id);
 }
        private bool DoAdd()
        {
            Model.goods_spec_item model = new Model.goods_spec_item();
            BLL.goods_spec_item   bll   = new BLL.goods_spec_item();

            model.goods_id  = this.goods_id;
            model.name      = txtTitle.Text.Trim();
            model.sort      = Utils.StrToInt(txtSort.Text.Trim(), 0);
            model.parent_id = 0;
            if (this.id > 0)
            {
                Model.goods_spec_item main_mdoel = new BLL.goods_spec_item().GetModel(this.id);
                model.goods_id  = main_mdoel.goods_id;
                model.parent_id = this.id;
                this.goods_id   = model.goods_id;
            }

            int addId = bll.Add(model);

            if (addId > 0)
            {
                Model.goods_spec_type spec_type = new Model.goods_spec_type();
                Model.goods_goods     goods     = new BLL.goods_goods().GetModel(this.goods_id);
                if (goods != null)
                {
                    spec_type.goods_id = this.goods_id;
                    spec_type.price    = goods.price;
                    spec_type.spec     = addId;
                    spec_type.stock    = 100;
                }
                else
                {
                    spec_type.goods_id = this.goods_id;
                    spec_type.price    = 0;
                    spec_type.spec     = addId;
                    spec_type.stock    = 100;
                }
                new BLL.goods_spec_type().Add(spec_type);

                return(true);
            }
            return(false);
        }
Beispiel #11
0
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("_ybd_goods_spec_item", EnumCollection.ActionEnum.Modify.ToString()); //检查权限
            BLL.goods_spec_item   bll   = new BLL.goods_spec_item();
            Model.goods_spec_item model = bll.GetModel(this.id);

            model.goods_id  = Convert.ToInt32(txtgoods_id.Text);
            model.name      = Convert.ToString(txtname.Text);
            model.parent_id = Convert.ToInt32(txtparent_id.Text);
            model.sort      = Convert.ToInt32(txtsort.Text);

            if (bll.Update(model))
            {
                AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改商品规格项信息,主键:" + id); //记录日志
                JscriptMsg("修改商品规格项信息成功!", "Manage.aspx");
            }
            else
            {
                JscriptMsg("保存过程中发生错误!", "");
            }
        }
Beispiel #12
0
        //删除规格
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("_goods_list", EnumCollection.ActionEnum.Delete.ToString()); //检查权限
            BLL.goods_spec_item bll = new BLL.goods_spec_item();
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int      id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    DataTable old_dt  = new BLL.goods_spec_item().GetList("goods_id=" + goods_id + " and parent_id !=0 ");
                    int       old_sum = old_dt.AsEnumerable().GroupBy(a => a.Field <int>("parent_id")).Count();
                    if (bll.DeleteNew(id))
                    {
                        //更新规格信息
                        DataTable spec_dt = new BLL.goods_spec_item().GetList("goods_id=" + goods_id + " and parent_id !=0 ");

                        if (spec_dt.AsEnumerable().GroupBy(a => a.Field <int>("parent_id")).Count() == 1 && old_sum > 1)
                        {
                            for (int j = 0; j < spec_dt.Rows.Count; j++)
                            {
                                Model.goods_goods goods_model = new BLL.goods_goods().GetModel(Utils.StrToInt(spec_dt.Rows[j]["goods_id"].ToString(), 0));

                                if (goods_model != null)
                                {
                                    Model.goods_spec_type type_model = new Model.goods_spec_type();
                                    type_model.goods_id = goods_model.id;
                                    type_model.spec     = Utils.StrToInt(spec_dt.Rows[j]["id"].ToString(), 0);
                                    type_model.price    = goods_model.price;
                                    type_model.stock    = 100;
                                    new BLL.goods_spec_type().Add(type_model);
                                }
                            }
                        }
                    }
                }
            }
            AddAdminLog(EnumCollection.ActionEnum.Delete.ToString(), "删除规格"); //记录日志
            JscriptMsg("删除数据成功!", "goods_spec.aspx?page=" + this.page + "&goods_id=" + this.goods_id);
        }
        private bool DoAdd()
        {
            BLL.goods_goods   bll   = new BLL.goods_goods();
            Model.goods_goods model = new Model.goods_goods();

            model.ct_id       = 0;
            model.group_id    = Convert.ToInt32(rbtnGroup.SelectedValue);
            model.category_id = Convert.ToInt32(ddlCategory.SelectedValue);
            model.title       = Convert.ToString(txttitle.Text);
            model.subtitle    = Convert.ToString(txtsubtitle.Text);
            model.img_src     = Convert.ToString(txtimg_src.Text);
            model.oprice      = Convert.ToDecimal(txtoprice.Text);
            model.price       = Convert.ToDecimal(txtprice.Text);
            model.parameters  = Convert.ToString(txtparameters.Text);
            model.details     = Convert.ToString(txtdetails.Text);
            model.sales_num   = Convert.ToInt32(txtsales_num.Text);
            model.status      = Convert.ToInt32(rbtnStatus.SelectedValue);
            model.sj_time     = System.DateTime.Now;
            model.xj_time     = System.DateTime.Now;
            model.add_time    = System.DateTime.Now;

            int row = bll.Add(model);

            if (row > 0)
            {
                #region 添加轮播图
                string[] albumArr = Request.Form.GetValues("hid_photo_name");
                if (albumArr != null && albumArr.Length > 0)
                {
                    for (int i = 0; i < albumArr.Length; i++)
                    {
                        string[] imgArr = albumArr[i].Split('|');
                        if (imgArr.Length == 3)
                        {
                            Model.common_albums pic_model = new Model.common_albums();
                            pic_model = new Model.common_albums()
                            {
                                group_id = (int)EnumCollection.img_group.商品轮播图, rc_data_id = row, rc_type = 0, original_path = imgArr[1], thumb_path = imgArr[2], remark = "", add_time = DateTime.Now
                            };
                            new BLL.common_albums().Add(pic_model);
                        }
                    }
                }
                #endregion

                #region 添加默认规格
                BLL.goods_spec_item   specBll = new BLL.goods_spec_item();
                Model.goods_spec_item item    = new Model.goods_spec_item();
                item.name      = "规格";
                item.parent_id = 0;
                item.goods_id  = row;
                item.sort      = 1;

                int spec = specBll.Add(item);
                if (spec > 0)
                {
                    item           = new Model.goods_spec_item();
                    item.name      = "平装";
                    item.parent_id = spec;
                    item.goods_id  = row;
                    item.sort      = 1;

                    int subspec = specBll.Add(item);
                    if (subspec > 0)
                    {
                        Model.goods_spec_type type = new Model.goods_spec_type();
                        type.goods_id = row;
                        type.price    = model.price;
                        type.stock    = 100;
                        type.spec     = subspec;

                        if (new BLL.goods_spec_type().Add(type) <= 0)
                        {
                            specBll.DeleteList(spec + "," + subspec);
                        }
                    }
                    else
                    {
                        specBll.Delete(spec);
                    }
                }
                #endregion

                AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "添加商品信息,主键:" + row); //记录日志
                return(true);
            }
            return(false);
        }