public List <KhoaBDO> GetAllKhoa() { List <KhoaBDO> ListKhoa = new List <KhoaBDO>(); using (SqlConnection connection = new SqlConnection(ConnectionInformation.ConnectionString)) { using (SqlCommand command = new SqlCommand("spGetKhoa", connection)) { command.CommandType = CommandType.StoredProcedure; connection.Open(); SqlDataAdapter KhoaAdapter = new SqlDataAdapter(); DataTable KhoaTable = new DataTable(); KhoaAdapter.SelectCommand = command; KhoaAdapter.Fill(KhoaTable); if (KhoaTable.Rows.Count > 0) { for (int i = 0; i < KhoaTable.Rows.Count; i++) { KhoaBDO Khoa = new KhoaBDO(); Khoa.MaKhoa = (string)KhoaTable.Rows[i]["Makhoa"]; Khoa.TenKhoa = (string)KhoaTable.Rows[i]["Tenkhoa"]; ListKhoa.Add(Khoa); } } } } return(ListKhoa); }
public KhoaBDO GetKhoaByID(string MaKhoa) { KhoaBDO Khoa = new KhoaBDO(); using (SqlConnection connection = new SqlConnection(ConnectionInformation.ConnectionString)) { using (SqlCommand command = new SqlCommand("spGetKhoa", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@Makhoa", MaKhoa); connection.Open(); SqlDataAdapter KhoaAdapter = new SqlDataAdapter(); DataTable KhoaTable = new DataTable(); KhoaAdapter.SelectCommand = command; KhoaAdapter.Fill(KhoaTable); if (KhoaTable.Rows.Count > 0) { Khoa.MaKhoa = (string)KhoaTable.Rows[0]["Makhoa"]; Khoa.TenKhoa = (string)KhoaTable.Rows[0]["Tenkhoa"]; } } } return(Khoa); }
public bool Update(KhoaBDO khoa) { try { khoaBUS.Update(khoa); return(true); } catch (FaultException) { throw; } }
public bool Add(KhoaBDO khoa) { try { khoaBUS.Add(khoa); return(true); } catch (FaultException) { throw; } }
public bool Update(KhoaBDO khoa) { if (khoa != null) { if (khoa.MaKhoa != null && khoa.MaKhoa != String.Empty) { khoaDAL.Update(khoa); return(true); } } return(false); }
public int Add(KhoaBDO khoa) { using (SqlConnection connection = new SqlConnection(ConnectionInformation.ConnectionString)) { using (SqlCommand command = new SqlCommand("spEditKhoa", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@StatementType", ConnectionInformation.Insert); command.Parameters.AddWithValue("@Makhoa", khoa.MaKhoa); command.Parameters.AddWithValue("@Tenkhoa", khoa.TenKhoa); connection.Open(); return(command.ExecuteNonQuery()); } } }