public static bool ThemLop(Entities.Lop lop) { DataTable dt = LopDAL.ThemLop(lop); foreach (DataRow row in dt.Rows) { if (row.ItemArray[0].ToString().Trim() == "0") { return(true); } } return(false); }
private void ThemLop() { maLop = LopBLL.AutoMaLop(); Entities.Lop lop = new Entities.Lop(maLop, cboLoaiLop.SelectedValue.ToString(), txtTaoLop.Text, Int32.Parse(txtNam.Text), cboGVCN.SelectedValue.ToString(), Int32.Parse(txtSS.Text)); if (!LopBLL.ThemLop(lop)) { MessageBox.Show("Thêm lớp thất bại"); } }
public static DataTable ThemLop(Entities.Lop lop) { DataAccessHelper db = new DataAccessHelper(); SqlCommand cmd = db.Command("THEMLOP"); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@MaLop", lop.MaLop); cmd.Parameters.AddWithValue("@MaLoaiLop", lop.MaLoaiLop); cmd.Parameters.AddWithValue("@NamHoc", lop.NamHoc); cmd.Parameters.AddWithValue("@MaGV", lop.MaGV); cmd.Parameters.AddWithValue("@SiSo", lop.SiSo); cmd.Parameters.AddWithValue("@TenLop", lop.TenLop); SqlDataAdapter da = new SqlDataAdapter(cmd); db.dt = new DataTable(); da.Fill(db.dt); return(db.dt); }