public DataTable Xem(Lop x) { Open(); string sql = "select * from Lop where MaLop=@MaLop"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("MaLop", x.MaLop); DataTable dt = new DataTable(); SqlDataReader dr = cmd.ExecuteReader(); dt.Load(dr); return(dt); }
public void suaLop(Lop l) { string sqlUpdate = "update Lop set tenLop = @tenLop ,nienKhoa=@nienKhoa,siSo= @siSo,maCBGV= @maCBGV where maLop =@maLop "; KetNoiCSDL.moKetNoi(); SqlCommand cmd = new SqlCommand(sqlUpdate, KetNoiCSDL.connect); cmd.Parameters.AddWithValue("maLop", l.MaLop); cmd.Parameters.AddWithValue("tenLop", l.TenLop); cmd.Parameters.AddWithValue("nienKhoa", l.NienKhoa); cmd.Parameters.AddWithValue("siSo", l.SiSo); cmd.Parameters.AddWithValue("maCBGV", l.MaCBGV); cmd.ExecuteNonQuery(); KetNoiCSDL.dongKetNoi(); }
public void themLop(Lop l) { string sqlSelect = "insert into Lop values(@maLop ,@tenLop ,@nienKhoa, @siSo, @maCBGV)"; KetNoiCSDL.moKetNoi(); SqlCommand cmd = new SqlCommand(sqlSelect, KetNoiCSDL.connect); cmd.Parameters.AddWithValue("maLop", l.MaLop); cmd.Parameters.AddWithValue("tenLop", l.TenLop); cmd.Parameters.AddWithValue("nienKhoa", l.NienKhoa); cmd.Parameters.AddWithValue("siSo", l.SiSo); cmd.Parameters.AddWithValue("maCBGV", l.MaCBGV); cmd.ExecuteNonQuery(); KetNoiCSDL.dongKetNoi(); }
public List <Lop> layLop() { List <Lop> arr = new List <Lop>(); KetNoiCSDL.moKetNoi(); string get = "select * from Lop"; SqlCommand cmd = new SqlCommand(get, KetNoiCSDL.connect); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { Lop x = new Lop(dr["maLop"] + "", dr["tenLop"] + "", dr["nienKhoa"] + "", int.Parse(dr["siSo"] + ""), dr["maCBGV"] + ""); arr.Add(x); } KetNoiCSDL.dongKetNoi(); return(arr); }
public int Sua(Lop x) { int n = 5; string[] name = new string[n]; object[] value = new object[n]; name[0] = "@MaLop"; name[1] = "@TenLop"; name[2] = "@NienKhoa"; name[3] = "@SiSo"; name[4] = "@GVCN"; value[0] = x.MaLop; value[1] = x.TenLop; value[2] = x.NienKhoa; value[3] = x.SiSo; value[4] = x.GiaoVienChuNhiem; string sql = "update Lop set TenLop=@TenLop, NienKhoa=@NienKhoa, SiSo=@SiSo, GiaoVienChuNhiem=@GVCN where MaLop=@MaLop"; return(Update(sql, name, value, n)); }
public int Them(Lop x) { int n = 5; string[] name = new string[n]; object[] value = new object[n]; name[0] = "@MaLop"; name[1] = "@TenLop"; name[2] = "@NienKhoa"; name[3] = "@SiSo"; name[4] = "@GVCN"; value[0] = x.MaLop; value[1] = x.TenLop; value[2] = x.NienKhoa; value[3] = x.SiSo; value[4] = x.GiaoVienChuNhiem; string sql = "insert into Lop values(@MaLop,@TenLop,@NienKhoa,@SiSo,@GVCN)"; return(Update(sql, name, value, n)); }
public bool Insert(Lop lop) { try { string query = "SELECT * FROM Lop"; SqlDataAdapter dataAdapter = new SqlDataAdapter(query, connection); table = GetData(); DataRow row = table.NewRow(); row["tenLop"] = lop.TenLop; row["DonViId"] = lop.DonViId; table.Rows.Add(row); SqlCommandBuilder sqlCommandBuilder = new SqlCommandBuilder(dataAdapter); dataAdapter.Update(table); return(true); } catch { return(false); } }
private void detach_Lops(Lop entity) { this.SendPropertyChanging(); entity.GiaoVien = null; }
private void attach_Lops(Lop entity) { this.SendPropertyChanging(); entity.GiaoVien = this; }
partial void DeleteLop(Lop instance);
partial void UpdateLop(Lop instance);
partial void InsertLop(Lop instance);