新增 刪除 資料繫結 登入 修改的實現

2021-06-19 11:22:40 字數 2209 閱讀 2671

新增、刪除、資料繫結、登入、修改是乙個系統中最常見,最基本的操作。

這裡用產品資訊這個栗子(簡單三層結構沒有使用dbhlper)來分析新增、刪除、資料繫結、修改操作。

用學生考試系統的學生登入栗子(簡單三層機構使用了dbhlper)分析登入操作

一、新增

前台:

後台:

protected void adbutton_click(object sender, eventargs e)

資料層**

public bool productadd(model.productinfo model)

finally

return num > 0;

#endregion

}

二、資料繫結、刪除、修改商品操作頁面

商品修改

後台**(商品操作頁面和商品修改的後台**):

namespace productinfor

}/// /// 資料刪除按鈕事件

///

/// /// protected void prorepeater_itemcommand(object source, repeatercommandeventargs e) //commandargument獲取命令的引數即在頁面中繫結的*****infoid

else

}private void bindlistdata()

protected void addbutton_click1(object sender, eventargs e)

}}namespace productinfor

model.productinfo model = new bll.productbll().getinfo(int.parse(request.querystring["id"])); //呼叫getinfo方法

if (model == null)

else}}

protected void cfbutton_click(object sender, eventargs e)

#endregion}}

資料層**:

public model.productinfo getinfo(int id)

reader.close();

return model;

}finally

#endregion

}public bool productmodify(model.productinfo model)

finally

#endregion

}public datatable productlist()

return null;

}finally

#endregion

}public bool productdel(int id)

finally

#endregion

}

三、登入操作

後台**:

public void btnlogin_click(object sender, eventargs e)

else

else

}#endregion

}

資料層**:

public stsmodel.studentmodel getinfo(string stuname)

// dr.close();

return model;

#endregion

}

mysql 修改新增刪除資料庫

新建資料庫表 create table mytablename id bigint 20 not null auto increment comment 記錄id columnname1 char 1 default null comment 使用者角色 0 普通使用者 1 vip使用者 colum...

新增查詢刪除資料

package demo1 leo description 暫無 date created in 2020 11 27 18 03 public class mylist public mylist object element get set方法 public object getelement ...

新增,更新和刪除資料

為表中所有字段新增資料 通常情況下,向資料表中新增的新記錄應該包含表所有字段,即為該表中的所有字段新增資料,為表中所有字段新增資料的insert語句有兩種。1 insert語句中指定所有欄位名 執行成功後,會在表stu中新增一條資料。為了驗證資料是否新增成功,使用select語句檢視student表...