示例#1
0
    protected void Button8_Click(object sender, EventArgs e)
    {
        if (Button8.Text == "添加")
        {
            M_CateDetail temp = new M_CateDetail();
            temp.CateDetailName= TextBox1.Text;
            temp.CateID = Convert.ToInt32(Session["cateid"]);
            if (B_CateDetail.Add(temp))
            {

                this.Bind();

            }

        }
        if (Button8.Text == "更新")
        {
            Button8.Text = "添加";
            M_CateDetail temp = new M_CateDetail();
            temp.CateID =Convert.ToInt32( Session["CateID"]);
            temp.CateDetailName = TextBox1.Text;
            temp.CateDetailID = Convert.ToInt32(Session["catedetailid"]);
            B_CateDetail.Update(temp);
             this.Bind();

        }
    }
示例#2
0
 public bool Update(M_CateDetail catedetail)
 {
     string sqlStr = "UPDATE ZL_CateDetail SET CateDetailName=@CateDetailName where CateDetailID=@CateDetailID";
     SqlParameter[] cmdParams = GetParameters(catedetail);
        int temp=SqlHelper.ExecuteNonQuery(CommandType.Text,sqlStr, cmdParams);
        if (temp == 1)
        return true;
        else
        return false;
 }
示例#3
0
 public bool Add(M_CateDetail catedetail)
 {
     string sqlStr = "INSERT INTO ZL_CateDetail(CateDetailName,CateID) VALUES(@CateDetailName,@CateID)";
     SqlParameter[] parameter = new SqlParameter[2];
     parameter[0] = new SqlParameter("@CateDetailName", SqlDbType.NVarChar, 50);
     parameter[0].Value = catedetail.CateDetailName;
     parameter[1]=new SqlParameter("@CateID",SqlDbType.Int);
     parameter[1].Value=catedetail.CateID;
     return SqlHelper.ExecuteSql(sqlStr, parameter);
 }
示例#4
0
        public M_CateDetail GetcatedetailById(int catedetailid)
        {
            M_CateDetail tempCateDetail=new M_CateDetail();
            string sqlstr = "select CateDetailid,catedetailname from zl_catedetail where catedetailid=@catedetailid";
            SqlParameter[] parameter = new SqlParameter[1];
            parameter[0] = new SqlParameter("@catedetailid", DbType.Int32);
            parameter[0].Value = catedetailid;

            DataTable dt=SqlHelper.ExecuteTable(CommandType.Text, sqlstr,parameter);
            if (dt.Rows.Count != 1) return null;
            else
            {
                tempCateDetail.CateDetailName = (dt.Rows[0]["catedetailname"]).ToString();
                tempCateDetail.CateDetailID = Convert.ToInt32(dt.Rows[0]["catedetailid"]);
            }

            return tempCateDetail;
        }
示例#5
0
 public static bool Update(M_CateDetail catedetailInfo)
 {
     return catedetail.Update(catedetailInfo);
 }
示例#6
0
 public static bool Add(M_CateDetail catedetailInfo)
 {
     return catedetail.Add(catedetailInfo);
 }
示例#7
0
 private static SqlParameter[] GetParameters(M_CateDetail catedetail)
 {
     SqlParameter[] parameter = new SqlParameter[2];
     parameter[0] = new SqlParameter("@CateDetailName", SqlDbType.NVarChar,50);
     parameter[0].Value = catedetail.CateDetailName;
     parameter[1] = new SqlParameter("@CateDetailID", SqlDbType.Int);
     parameter[1].Value = catedetail.CateDetailID;
     return parameter;
 }