示例#1
0
    //添加
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Button1.Text == "添加分类")
        {
            Button1.Text = "更新";
            M_Cate temp = new M_Cate();
            if (TextBox1.Text == "")
            {
                return;
            }
            temp.CateName = TextBox1.Text;
            if (B_Cate.Add(temp))
            {
                string str = " <script>alert('Add success'); </script>";
                Response.Write(str);
            }
            Bind();
        }
        if (Button1.Text == "更新")
        {
            Button1.Text = "添加分类";
            M_Cate temp = new M_Cate();
            temp.CateName = TextBox1.Text;

            B_Cate.Update(temp);
            Bind();
        }
    }
示例#2
0
 private static SqlParameter[] GetParameterss(M_Cate cate)
 {
     SqlParameter[] parameter = new SqlParameter[1];
     parameter[0]       = new SqlParameter("@CateID", SqlDbType.Int);
     parameter[0].Value = cate.CateID;
     return(parameter);
 }
示例#3
0
    //全选



    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "mydelete")
        {
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                CheckBox IdCheck;
                IdCheck = (CheckBox)GridView1.Rows[i].FindControl("nameCheckBox");
                if (IdCheck.Checked)
                {
                    B_Cate.DeleteByID(Convert.ToInt32(e.CommandArgument.ToString()));
                    Bind();
                }
            }
        }
        if (e.CommandName == "myupdate")
        {
            Session.Add("cateid", e.CommandArgument);
            M_Cate tempcate = new M_Cate();
            tempcate      = B_Cate.GetCateByid(Convert.ToInt32(e.CommandArgument.ToString()));
            TextBox1.Text = tempcate.CateName;
            Button1.Text  = "更新";
        }
        if (e.CommandName == "mylink")
        {
            Response.Redirect("datamanage.aspx?cateid=" + e.CommandArgument);
            Response.End();
        }
    }
示例#4
0
        public bool Update(M_Cate cate)
        {
            string sqlStr = "UPDATE ZL_Cate SET CateName=@CateName where CateID=@CateID";

            SqlParameter[] cmdParams = GetParameters(cate);

            return(SqlHelper.ExecuteSql(sqlStr, cmdParams));
        }
示例#5
0
 private static SqlParameter[] GetParameters(M_Cate cate)
 {
     SqlParameter[] parameter = new SqlParameter[2];
     parameter[0]       = new SqlParameter("@CateName", SqlDbType.NVarChar, 50);
     parameter[0].Value = cate.CateName;
     parameter[1]       = new SqlParameter("@CateID", SqlDbType.Int);
     parameter[1].Value = cate.CateID;
     return(parameter);
 }
示例#6
0
        public bool Add(M_Cate cate)
        {
            string sqlStr = "INSERT INTO ZL_Cate(CateName) VALUES(@CateName)";

            SqlParameter[] parameter = new SqlParameter[1];
            parameter[0]       = new SqlParameter("@CateName", SqlDbType.NVarChar, 50);
            parameter[0].Value = cate.CateName;
            return(SqlHelper.ExecuteSql(sqlStr, parameter));
        }
示例#7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        M_Cate temp   = new M_Cate();
        int    CateID = Convert.ToInt32(Request.QueryString["cateid"]);

        Session.Add("CateId", CateID);
        temp             = B_Cate.GetCateByid(CateID);
        this.Label2.Text = temp.CateName;
        if (!Page.IsPostBack)
        {
            Bind();
        }
    }
示例#8
0
        public M_Cate GetCateByid(int cateId)
        {
            string sqlStr = "select * from ZL_Cate where cateid=" + cateId;

            DataSet ds   = SqlHelper.ExecuteDataSet(CommandType.Text, sqlStr, null);
            M_Cate  temp = new M_Cate();

            if (ds.Tables[0].Rows.Count == 0)
            {
                return(null);
            }
            temp.CateID   = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            temp.CateName = Convert.ToString(ds.Tables[0].Rows[0][1]);
            return(temp);
        }
示例#9
0
文件: B_Cate.cs 项目: zwt-zf/cms
 public static bool Update(M_Cate cateInfo)
 {
     return(cate.Update(cateInfo));
 }
示例#10
0
文件: B_Cate.cs 项目: zwt-zf/cms
 public static bool Add(M_Cate cateInfo)
 {
     return(cate.Add(cateInfo));
 }