public HinhThucKiemTra GetHinhThucKiemTra(string mahtkt)
        {
            OpenConnection();
            SqlCommand com = new SqlCommand();

            com.CommandType = CommandType.Text;
            com.CommandText = "Select * from HinhThucKiemTra where mahtkt=@ma";
            com.Parameters.Add("@ma", SqlDbType.VarChar).Value = mahtkt;
            com.Connection = conn;

            SqlDataReader   reader          = com.ExecuteReader();
            HinhThucKiemTra HinhThucKiemTra = null;

            while (reader.Read())
            {
                string ma   = reader.GetString(0);
                String ten  = reader.GetString(1);
                int    heSo = reader.GetInt32(2);

                HinhThucKiemTra = new HinhThucKiemTra(ma, ten, heSo);
            }

            reader.Close();
            CloseConnection();
            return(HinhThucKiemTra);
        }
        public List <HinhThucKiemTra> GetAllHinhThucKiemTra()
        {
            OpenConnection();
            SqlCommand com = new SqlCommand();

            com.CommandType = CommandType.Text;
            com.CommandText = "Select * from HinhThucKiemTra";
            com.Connection  = conn;

            SqlDataReader          reader = com.ExecuteReader();
            List <HinhThucKiemTra> listHinhThucKiemTra = new List <HinhThucKiemTra>();

            while (reader.Read())
            {
                string ma   = reader.GetString(0);
                String ten  = reader.GetString(1);
                int    heSo = reader.GetInt32(2);

                HinhThucKiemTra hinhThuc = new HinhThucKiemTra(ma, ten, heSo);
                listHinhThucKiemTra.Add(hinhThuc);
            }

            reader.Close();
            CloseConnection();
            return(listHinhThucKiemTra);
        }
Beispiel #3
0
        public ErrorType ThemHinhThucKiemTra(string ma, string ten, string heso)
        {
            HinhThucKiemTraAccess ac = new HinhThucKiemTraAccess();
            HinhThucKiemTra       ht = ac.GetHinhThucKiemTra(ma);

            if (string.IsNullOrEmpty(ma) || string.IsNullOrEmpty(ten) || string.IsNullOrEmpty(heso))
            {
                return(ErrorType.KI_TU_RONG);
            }
            if (ht != null)
            {
                return(ErrorType.DA_TON_TAI);
            }
            else
            {
                return(ac.ThemHTKT(ma, ten, Int32.Parse(heso)));
            }
        }