Пример #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     base.CheckLogin();
     if (!Page.IsPostBack)
     {
         //  DataSet ds = new BLL.eb_category().GetAllList();
         List <Model.eb_category> categoryList = new BLL.eb_category().GetModelList("");
         this.rp_category.DataSource = categoryList.OrderBy(g => g.cid).Take(10);
         this.rp_category.DataBind();
         this.lbPageIndex.Text = "1";
         this.lbSumPage.Text   = Math.Ceiling(Convert.ToDouble(categoryList.Count) / Convert.ToDouble(10)).ToString();
     }
 }
Пример #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     base.CheckLogin();
     //判断网页是否是第一次加载
     if (!Page.IsPostBack)
     {
         //绑定我们的下拉框
         List <Model.eb_category> categoryList = new BLL.eb_category().GetModelList("");
         this.Dropcategory.DataSource     = categoryList;
         this.Dropcategory.DataTextField  = "cname";
         this.Dropcategory.DataValueField = "cid";
         this.Dropcategory.DataBind();
     }
 }
Пример #3
0
        //修改的时候,初始化数据
        private void InitData()
        {
            //拿到了商品分类的id

            int cid = int.Parse(this.hiddenCid.Value.ToString());

            Model.eb_category model = new BLL.eb_category().GetModel(cid);
            if (model != null)
            {
                //表示数据还存在
                this.cname.Text   = model.cname;
                this.summary.Text = model.summary;
            }
            else
            {
                Maticsoft.Common.MessageBox.ShowAndRedirect(this.Page, "数据不存在", "CategoryList.aspx");
            }
        }
Пример #4
0
        //上一页
        protected void LbuttonPrePage_Click(object sender, EventArgs e)
        {
            int pageIndex = int.Parse(this.hiddenPageIndex.Value);

            pageIndex--;
            if (pageIndex <= 0)
            {
                pageIndex = 1;
            }
            double  sumCount = new BLL.eb_category().GetRecordCount(""); //拿到总记录数
            double  pageSize = 10;                                       //页容量
            double  sumPage  = Math.Ceiling(sumCount / pageSize);        //计算总页数
            DataSet ds       = new BLL.eb_category().GetListByPage("", "cid", Convert.ToInt32((pageIndex - 1) * pageSize) + 1, Convert.ToInt32(pageIndex * pageSize));

            this.rp_category.DataSource = ds.Tables[0];
            this.rp_category.DataBind();
            this.lbPageIndex.Text = pageIndex.ToString();
            this.lbSumPage.Text   = sumPage.ToString();
        }
Пример #5
0
        //新增按钮  或 修改按钮
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            //在点击保存的时候,怎么样去判断这个操作是新增还是修改呢
            Model.eb_category model = new Model.eb_category();
            model.cname   = this.cname.Text.Trim();
            model.summary = this.summary.Text.Trim();

            if (!string.IsNullOrEmpty(this.hiddenCid.Value))
            {
                //修改
                model.cid = int.Parse(this.hiddenCid.Value);
                bool flag = new BLL.eb_category().Update(model);
                if (flag)
                {
                    //修改成功
                    Maticsoft.Common.MessageBox.ShowAndRedirect(this.Page, "修改成功", "CategoryList.aspx");
                }
                else
                {
                    //修改失败
                    Maticsoft.Common.MessageBox.ShowAndRedirect(this.Page, "修改失败,请重试或联系管理员", "CategoryList.aspx");
                }
            }
            else
            {
                //新增
                int cid = new BLL.eb_category().Add(model);
                if (cid > 0)
                {
                    Maticsoft.Common.MessageBox.ShowAndRedirect(this.Page, "添加成功", "CategoryList.aspx");
                }
                else
                {
                    Maticsoft.Common.MessageBox.Show(this.Page, "添加失败,请重试或联系管理员");
                }
            }
        }