コード例 #1
0
        public List <qlbhDTO> GetNhanVien(string sql)
        {
            List <qlbhDTO> list = new List <qlbhDTO>();


            int    maLoaiSp;
            string tenLoaiSp;

            dp.Connect();
            try
            {
                SqlDataReader dr = dp.executeReader(sql);
                while (dr.Read())
                {
                    maLoaiSp  = dr.GetInt32(0);
                    tenLoaiSp = dr.GetString(1);

                    qlbhDTO ql = new qlbhDTO(maLoaiSp, tenLoaiSp);//-> gọi DTO, DTO lấy dữ liệu từ Data
                    list.Add(ql);
                }
                dr.Close();
                return(list);// trả về List đã có dữ liệu
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                dp.DisConnect();
            }
        }
コード例 #2
0
 public int add(qlbhDTO ql)
 {
     try
     {
         return(new qlbhDAL().add(ql));
     }
     catch (SqlException ex)
     {
         throw ex;
     }
 }
コード例 #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int    maLoaiSp;
            string tenLoaiSp;

            maLoaiSp  = Convert.ToInt32(txtMaSp.Text);
            tenLoaiSp = Convert.ToString(txtTenSp.Text);

            qlbhDTO ql = new qlbhDTO(maLoaiSp, tenLoaiSp);
            int     i  = new qlbhBUS().add(ql);

            dvgQLBH.DataSource = GetNhanVien();
        }
コード例 #4
0
        //public List<qlbhDTO> GetNhanVien(string sql);

        public int add(qlbhDTO ql)
        {
            List <SqlParameter> paras = new List <SqlParameter>();

            paras.Add(new SqlParameter("@MaSp", ql.MaLoaiSp));
            paras.Add(new SqlParameter("@TenLoaiSp", ql.TenLoaiSp));

            try
            {
                return(dp.executeNonQuery("addSP", System.Data.CommandType.StoredProcedure, paras));
            }
            catch (SqlException ex)
            {
                throw ex;
            }
        }