コード例 #1
0
            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);
            }
コード例 #2
0
            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);
            }
コード例 #3
0
 public bool Update(KhoaBDO khoa)
 {
     try
     {
         khoaBUS.Update(khoa);
         return(true);
     }
     catch (FaultException)
     {
         throw;
     }
 }
コード例 #4
0
 public bool Add(KhoaBDO khoa)
 {
     try
     {
         khoaBUS.Add(khoa);
         return(true);
     }
     catch (FaultException)
     {
         throw;
     }
 }
コード例 #5
0
 public bool Update(KhoaBDO khoa)
 {
     if (khoa != null)
     {
         if (khoa.MaKhoa != null && khoa.MaKhoa != String.Empty)
         {
             khoaDAL.Update(khoa);
             return(true);
         }
     }
     return(false);
 }
コード例 #6
0
 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());
         }
     }
 }