protected void btnDeleteSelect_Click(object sender, EventArgs e)
 {
     if (!Communal.CheckQx("ProductTypeDelete.aspx"))
     {
         Response.Redirect("RightsWarn.aspx");
     }
     else
     {
         string DeleteTitle = "";
         foreach (GridViewRow gr in this.GridView1.Rows)
         {
             CheckBox cb = (CheckBox)gr.Cells[1].FindControl("Select");
             if (cb.Checked)
             {
                 //删除数据库信息
                 Label ll = (Label)gr.Cells[1].FindControl("lblTypeID");
                 int TypeID = Convert.ToInt32(ll.Text);
                 WebProject.BLL.BaseData.ZT_COM_ProductType bll_ProductType = new WebProject.BLL.BaseData.ZT_COM_ProductType();
                 DeleteTitle += bll_ProductType.GetModel(TypeID).TypeName + ",";
                 bll_ProductType.Delete(TypeID);
             }
         }
         LogManage.WriteLog(Request.UserHostAddress, "产品管理", "删除产品分类", "成功", "分类名称:" + DeleteTitle.TrimEnd(',') + ", 操作人:" + SessionUtil.GetAdminSession().AdminNo);
         ShowData();
     }
 }
 public void dlkan()
 {
     WebProject.BLL.BaseData.ZT_COM_ProductType bll_ProductType = new WebProject.BLL.BaseData.ZT_COM_ProductType();
     DataSet ds = bll_ProductType.GetList("1=1");
     if (ds.Tables[0].Rows.Count > 0)
     {
         this.DLProductType.DataSource = ds;
         this.DLProductType.DataBind();
     }
 }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (Session["ZT_ADMIN"] == null)
        {
            Response.Redirect("Login.aspx");
        }
        else
        {
            WebProject.BLL.BaseData.ZT_COM_ProductType bll_ProductType = new WebProject.BLL.BaseData.ZT_COM_ProductType();
            if (this.txtTypeName.Text.Trim() == "")
            {
                MessageBox.Show(this, "类型名称不能为空!");
                return;
            }
            if (this.txtTypeNo.Text.Trim() == "")
            {
                MessageBox.Show(this, "类型编号不能为空!");
                return;
            }
            int TypeOrder;
            if (this.txtTypeOrder.Text.Trim() == "")
            {
                TypeOrder = 1000;
            }
            else
            {
                double u;
                if (!double.TryParse(this.txtTypeOrder.Text.Trim(), out u))
                {
                    MessageBox.Show(this, "排序必须为数字!");
                    return;
                }
                else
                {
                    TypeOrder = Convert.ToInt32(this.txtTypeOrder.Text.Trim());
                }
            }

            WebProject.Model.BaseData.ZT_COM_ProductType model_ProductType = new WebProject.Model.BaseData.ZT_COM_ProductType();
            model_ProductType.TypeName = this.txtTypeName.Text.Trim();
            model_ProductType.TypeNo = this.txtTypeNo.Text.Trim();
            model_ProductType.TypeOrder = TypeOrder;
            model_ProductType.CreateBy = SessionUtil.GetAdminSession().AdminNo;
            model_ProductType.CreateDate = DateTime.Now;
            bll_ProductType.Add(model_ProductType);
            LogManage.WriteLog(Request.UserHostAddress, "产品管理", "添加产品分类", "成功", "分类名称:" + model_ProductType.TypeName + ", 创建人:" + SessionUtil.GetAdminSession().AdminNo);
            MessageBox.ShowAndRedirect(this, "添加产品分类成功!", "ProductTypeList.aspx");
        }
    }
 public void ShowData()
 {
     WebProject.BLL.BaseData.ZT_COM_ProductType bll_ProductType = new WebProject.BLL.BaseData.ZT_COM_ProductType();
     DataSet ds = bll_ProductType.GetList("");
     if (ds.Tables[0].Rows.Count > 0)
     {
         this.lblMessage.Visible = false;
         this.btnDeleteSelect.Visible = true;
         this.GridView1.Visible = true;
         this.GridView1.DataSource = ds;
         this.GridView1.DataBind();
     }
     else
     {
         this.lblMessage.Visible = true;
         this.btnDeleteSelect.Visible = false;
         this.GridView1.Visible = false;
     }
 }
 public void ShowData()
 {
     if (Request["TypeID"] + "" == "")
     {
         Response.Redirect("RightsWarn.aspx");
     }
     else
     {
         try
         {
             WebProject.BLL.BaseData.ZT_COM_ProductType bll_ProductType = new WebProject.BLL.BaseData.ZT_COM_ProductType();
             WebProject.Model.BaseData.ZT_COM_ProductType model_ProductType = bll_ProductType.GetModel(Int32.Parse(Request["TypeID"].ToString()));
             this.txtTypeName.Text = model_ProductType.TypeName.ToString();
             this.txtTypeNo.Text = model_ProductType.TypeNo.ToString();
             this.txtTypeOrder.Text = model_ProductType.TypeOrder.ToString();
         }
         catch
         {
             Response.Redirect("RightsWarn.aspx");
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     string url = Request.Url.ToString();
     if (CheckString.CheckSqlKeyWord(url) == true)
     {
         MessageBox.ShowAndRedirect(this, "你的IP地址为:" + Page.Request.UserHostAddress + ",请不要输入非法字段!", "Login.aspx");
     }
     else
     {
         if (!IsPostBack)
         {
             if (Session["ZT_ADMIN"] == null)
             {
                 Response.Redirect("Login.aspx");
             }
             else
             {
                 if (!Communal.CheckQx("ProductEdit.aspx"))
                 {
                     Response.Redirect("RightsWarn.aspx");
                 }
                 else
                 {
                     WebProject.BLL.BaseData.ZT_COM_ProductType bll_ProductType = new WebProject.BLL.BaseData.ZT_COM_ProductType();
                     DataSet ds = bll_ProductType.GetList(" 1=1 ");
                     BindData.BindDropDownList("TypeName", "TypeNo", ds, txtProductType);
                     this.txtProductOrder.Attributes.Add("onpaste", "return false"); //屏蔽粘贴
                     ShowData();
                 }
             }
         }
     }
 }
    public void ProductView()
    {
        if (Request["TypeID"] + "" == "")
        {
            Response.Redirect("ErrorPage.aspx");
        }
        else
        {
            try
            {
                int TypeID = Convert.ToInt32(Request.QueryString["TypeID"].ToString());
                WebProject.BLL.BaseData.ZT_COM_ProductType bll_ProductType = new WebProject.BLL.BaseData.ZT_COM_ProductType();
                WebProject.Model.BaseData.ZT_COM_ProductType model_ProductType = bll_ProductType.GetModel(TypeID);
                int currentPage = Convert.ToInt32(this.dang.Text);  //当前页
                WebProject.BLL.BaseData.ZT_COM_Product bll_Product = new WebProject.BLL.BaseData.ZT_COM_Product();
                DataSet ds = bll_Product.GetList(" TypeNo='" + model_ProductType.TypeNo + "'");
                this.count.Text = ds.Tables[0].Rows.Count.ToString();
                if (ds.Tables[0].Rows.Count >= 0)
                {
                    System.Web.UI.WebControls.PagedDataSource pds = new PagedDataSource();
                    pds.DataSource = ds.Tables[0].DefaultView;
                    pds.AllowPaging = true;
                    pds.PageSize = 6;
                    pds.CurrentPageIndex = currentPage - 1; //当前页面索引,索引号从0开始
                    this.countpage.Text = pds.PageCount.ToString();//总页数

                    if (currentPage == 1)
                    {
                        this.shou.Enabled = false;
                        this.shang.Enabled = false;

                    }
                    else
                    {
                        this.shou.Enabled = true;
                        this.shang.Enabled = true;

                    }
                    if (currentPage == pds.PageCount)
                    {
                        this.xia.Enabled = false;
                        this.last.Enabled = false;

                    }
                    else
                    {
                        this.xia.Enabled = true;
                        this.last.Enabled = true;

                    }

                    this.DataList1.DataSource = pds;
                    this.DataList1.DataBind();
                }

                else
                {
                    this.lblMessage.Visible = true;
                    this.countpage.Text = this.dang.Text;
                    this.shou.Enabled = false;
                    this.shang.Enabled = false;
                    this.xia.Enabled = false;
                    this.last.Enabled = false;

                }
            }
            catch
            {
                Response.Redirect("ErrorPage.aspx");
            }
        }
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        if (!Communal.CheckQx("ProductTypeDelete.aspx"))
        {
            Response.Redirect("RightsWarn.aspx");
        }
        else
        {
            //删除数据库的信息
            Label ll = (Label)this.GridView1.Rows[e.RowIndex].Cells[1].FindControl("lblTypeID");
            int TypeID = Convert.ToInt32(ll.Text);
            WebProject.BLL.BaseData.ZT_COM_ProductType bll_ProductType = new WebProject.BLL.BaseData.ZT_COM_ProductType();
            LogManage.WriteLog(Request.UserHostAddress, "产品管理", "删除产品分类", "成功", "产品分类名称:" + bll_ProductType.GetModel(TypeID).TypeName + ", 删除人:" + SessionUtil.GetAdminSession().AdminNo);
            bll_ProductType.Delete(TypeID);

            //重新加载信息
            ShowData();
        }
    }