Exemplo n.º 1
0
    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDel_Click(object sender, EventArgs e)
    {
        List <int> l = new List <int>();

        foreach (RepeaterItem row in this.rptGoodsAreas.Items)
        {
            CheckBox cb = row.FindControl("CB_SelItem") as CheckBox;
            if (cb != null && cb.Checked)
            {
                HiddenField fld = row.FindControl("HF_Id") as HiddenField;
                if (fld != null)
                {
                    int id = Convert.ToInt32(fld.Value);
                    l.Add(id);
                    Hi.Model.BD_GoodsAreas model = new Hi.BLL.BD_GoodsAreas().GetModel(id);
                    if (model != null)
                    {
                        model.ts         = DateTime.Now;
                        model.modifyuser = this.UserID;
                        model.dr         = 1;
                        model.CompID     = this.CompID;
                        bool bol = new Hi.BLL.BD_GoodsAreas().Update(model);
                    }
                }
            }
        }
        Bind();
    }
Exemplo n.º 2
0
    /// <summary>
    /// 商品列表绑定
    /// </summary>
    public void Bind()
    {
        int    pageCount = 0;
        int    Counts    = 0;
        string strWhere  = " and ISNULL(dr,0)=0 and ComPid=" + this.CompID;

        if (ViewState["strWhere"] != null)
        {
            strWhere += ViewState["strWhere"].ToString();
        }
        //每页显示的数据设置
        if (this.txtPageSize.Value.ToString() != "")
        {
            if (this.txtPageSize.Value.Trim().Length >= 5)
            {
                Pager.PageSize         = 100;
                this.txtPageSize.Value = "100";
            }
            else
            {
                Pager.PageSize = this.txtPageSize.Value.Trim().ToInt(0);
            }
        }
        List <Hi.Model.BD_GoodsAreas> l = new Hi.BLL.BD_GoodsAreas().GetList(Pager.PageSize, Pager.CurrentPageIndex, "id", true, strWhere, out pageCount, out Counts);

        this.rptGoodsAreas.DataSource = l;
        this.rptGoodsAreas.DataBind();
        Pager.RecordCount = Counts;
        page = Pager.CurrentPageIndex.ToString();
    }
Exemplo n.º 3
0
    /// <summary>
    /// 保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        SqlTransaction Tran = null;

        try
        {
            Tran = DBUtility.SqlHelper.CreateStoreTranSaction();
            object disId   = Request["disId"];   //代理商id
            object goodsId = Request["goodsId"]; //商品Id
            if (disId != null && goodsId != null)
            {
                for (int i = 0; i < disId.ToString().Split(',').Length; i++)
                {
                    for (int z = 0; z < goodsId.ToString().Split(',').Length; z++)
                    {
                        List <Hi.Model.BD_GoodsAreas> l = new Hi.BLL.BD_GoodsAreas().GetList("", "isnull(dr,0)=0 and compId=" + this.CompID + " and disId=" + disId.ToString().Split(',')[i] + " and goodsId=" + goodsId.ToString().Split(',')[z], "", Tran);
                        if (l.Count == 0)
                        {
                            Hi.Model.BD_GoodsAreas  model  = new Hi.Model.BD_GoodsAreas();
                            Hi.Model.BD_Distributor model2 = new Hi.BLL.BD_Distributor().GetModel(Convert.ToInt32(disId.ToString().Split(',')[i]), Tran);
                            Hi.Model.BD_Goods       model3 = new Hi.BLL.BD_Goods().GetModel(Convert.ToInt32(goodsId.ToString().Split(',')[z]), Tran);
                            model.CompID     = this.CompID;
                            model.areaID     = model2.AreaID;
                            model.GoodsID    = Convert.ToInt32(goodsId.ToString().Split(',')[z]);
                            model.CategoryID = model3.CategoryID;
                            model.ts         = DateTime.Now;
                            model.dr         = 0;
                            model.modifyuser = this.UserID;
                            model.DisID      = Convert.ToInt32(disId.ToString().Split(',')[i]);
                            new Hi.BLL.BD_GoodsAreas().Add(model, Tran);
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
            }
            Tran.Commit();
            Response.Redirect("GoodsAreaList.aspx");
        }
        catch (Exception ex)
        {
            if (Tran != null)
            {
                if (Tran.Connection != null)
                {
                    Tran.Rollback();
                }
            }
            JScript.AlertMethod(this, "保存失败了", JScript.IconOption.错误, "function(){location.href='GoodsAreaList.aspx';}");
            return;
        }
        finally
        {
            DBUtility.SqlHelper.ConnectionClose();
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// 查询条件
    /// </summary>
    /// <returns></returns>
    private string Where()
    {
        int areaid = 0;

        if (!Util.IsEmpty(txtDisAreaBox.areaId))
        {
            areaid = Convert.ToInt32(txtDisAreaBox.areaId);
        }
        string strWhere = string.Empty;
        string goodsid  = string.Empty;
        List <Hi.Model.BD_GoodsAreas> lll = new Hi.BLL.BD_GoodsAreas().GetList("", "isnull(dr,0)=0 and compid=" + this.CompID + " and areaid=" + areaid, "");

        if (lll.Count > 0)
        {
            foreach (Hi.Model.BD_GoodsAreas item in lll)
            {
                goodsid += item.GoodsID + ",";
            }
        }
        if (!Util.IsEmpty(goodsid))
        {
            goodsid   = goodsid.Substring(0, goodsid.Length - 1);
            strWhere += " and id not in(" + goodsid + ")";
        }
        //赋值
        string goodsName = this.txtGoodsName.Value.Trim(); //商品名称
        string hideID    = this.txtCategory.treeId;        //类别id
        string idlist    = string.Empty;

        if (!Util.IsEmpty(goodsName))
        {
            //List<Hi.Model.BD_Goods> l = new Hi.BLL.BD_Goods().GetList("", "goodsname like '%" + goodsName + "%'  and isnull(dr,0)=0 and isenabled=1  and compid=" + this.CompID, "");
            //if (l.Count > 0)
            //{
            //    foreach (Hi.Model.BD_Goods item in l)
            //    {
            //        idlist += item.ID + ",";
            //    }
            //}
            //if (!Util.IsEmpty(idlist))
            //{
            //    strWhere += string.Format(" and id in( {0})", idlist.Substring(0, idlist.Length - 1));
            //}
            //else
            //{
            //    strWhere += string.Format(" and id = ''");
            //}
            strWhere += " and goodsName like'%" + goodsName + "%'";
        }
        if (!Util.IsEmpty(hideID))
        {
            string cateID = Common.CategoryId(Convert.ToInt32(hideID), this.CompID);//商品分类递归
            //List<Hi.Model.BD_Goods> ll = new Hi.BLL.BD_Goods().GetList("", "categoryID in(" + cateID + ") and isnull(dr,0)=0 and isenabled=1 and compId=" + this.CompID, "");
            //if (ll.Count > 0)
            //{
            //    foreach (Hi.Model.BD_Goods item in ll)
            //    {
            //        idlist += item.ID + ",";
            //    }
            //}
            //if (!Util.IsEmpty(idlist))
            //{
            //    strWhere += string.Format(" and id in( {0})", idlist.Substring(0, idlist.Length - 1));
            //}
            //else
            //{
            strWhere += " and categoryID in(" + cateID + ")";
            // }
        }
        return(strWhere);
    }