public static int Add(LoaiSachDto loaiSach) { OleDbConnection cn; cn = DataProvider.ConnectionData(); string strSQL; strSQL = "Insert into LoaiSach(MLoaiSach,TenLoaiSach) values (?,?)"; OleDbCommand cmd = new OleDbCommand(strSQL, cn); cmd.Parameters.Add("@MLoaiSach", OleDbType.Integer); cmd.Parameters.Add("@TenLoaiSach", OleDbType.WChar); cmd.Parameters["@MLoaiSach"].Value = loaiSach.MLoaiSach; cmd.Parameters["@TenLoaiSach"].Value = loaiSach.TenLoaiSach; cmd.ExecuteNonQuery(); strSQL = "Select @@IDENTITY"; cmd = new OleDbCommand(strSQL, cn); loaiSach.MLoaiSach = (int)cmd.ExecuteScalar(); cn.Close(); return loaiSach.MLoaiSach; }
public static IList GetList() { ArrayList ds = new ArrayList(); OleDbConnection cn; cn = DataProvider.ConnectionData(); string strSQL; strSQL = "Select * From LoaiSach"; OleDbCommand cmd = new OleDbCommand(strSQL, cn); OleDbDataReader dr; dr = cmd.ExecuteReader(); while (dr.Read()) { LoaiSachDto loaiSach = new LoaiSachDto(); loaiSach.MLoaiSach = (int)dr["MLoaiSach"]; loaiSach.TenLoaiSach = (String)dr["TenLoaiSach"]; ds.Add(loaiSach); } dr.Close(); cn.Close(); return ds; }
public static LoaiSachDto Search(int maLoaiSach) { LoaiSachDto loaiSach = null; OleDbConnection cn; cn = DataProvider.ConnectionData(); string strSQL; strSQL = "Select * From LoaiSach Where MLoaiSach= ? "; OleDbCommand cmd = new OleDbCommand(strSQL, cn); cmd.Parameters.Add("@MLoaiSach", OleDbType.Integer); cmd.Parameters["@MLoaiSach"].Value = maLoaiSach; OleDbDataReader dr; dr = cmd.ExecuteReader(); while (dr.Read()) { loaiSach = new LoaiSachDto(); loaiSach.MLoaiSach = (int)dr["MLoaiSach"]; loaiSach.TenLoaiSach = (String)dr["TenLoaiSach"]; } dr.Close(); cn.Close(); return loaiSach; }
public static void Update(LoaiSachDto loaiSach) { OleDbConnection cn; cn = DataProvider.ConnectionData(); string strSQL; strSQL = "Update LoaiSach Set MLoaiSach = ? , TenLoaiSach = ? Where MLoaiSach = ?"; OleDbCommand cmd = new OleDbCommand(strSQL, cn); cmd.Parameters.Add("@MLoaiSach", OleDbType.Integer); cmd.Parameters.Add("@TenLoaiSach", OleDbType.WChar); cmd.Parameters["@MLoaiSach"].Value = loaiSach.MLoaiSach; cmd.Parameters["@TenLoaiSach"].Value = loaiSach.TenLoaiSach; cmd.ExecuteNonQuery(); cn.Close(); }
public static void Update(LoaiSachDto loaiSach) { LoaiSachDao.Update(loaiSach); }
public static int Add(LoaiSachDto loaiSach) { return LoaiSachDao.Add(loaiSach); }