Exemple #1
0
        /// <summary>
        /// Creates a new instance of the PHIEU_NHAP_XE class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private PHIEUNHAPXE_DTO MakePHIEUNHAPXE_DTO(SqlDataReader dataReader)
        {
            PHIEUNHAPXE_DTO PhieuNhapXe = new PHIEUNHAPXE_DTO();

            PhieuNhapXe.Ma           = SqlClientUtility.GetInt32(dataReader, "MA", 0);
            PhieuNhapXe.MaDonDatHang = SqlClientUtility.GetInt32(dataReader, "MA_DON_DAT_HANG", 0);
            PhieuNhapXe.NgayNhap     = SqlClientUtility.GetDateTime(dataReader, "NGAY_NHAP", DateTime.Now);
            PhieuNhapXe.TongSoLuong  = SqlClientUtility.GetInt32(dataReader, "TONG_SO_LUONG", 0);

            return(PhieuNhapXe);
        }
Exemple #2
0
        /// <summary>
        /// Saves a record to the PHIEU_NHAP_XE table.
        /// </summary>
        public void Insert(PHIEUNHAPXE_DTO PhieuNhapXe)
        {
            ValidationUtility.ValidateArgument("PhieuNhapXe", PhieuNhapXe);

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@MA_DON_DAT_HANG", PhieuNhapXe.MaDonDatHang),
                new SqlParameter("@NGAY_NHAP", PhieuNhapXe.NgayNhap),
                new SqlParameter("@TONG_SO_LUONG", PhieuNhapXe.TongSoLuong)
            };

            PhieuNhapXe.Ma = (int)SqlClientUtility.ExecuteScalar(m_ConnectionString, CommandType.StoredProcedure, "PROC_PhieuNhapXe_Insert", parameters);
        }
Exemple #3
0
        /// <summary>
        /// Selects all records from the PHIEU_NHAP_XE table.
        /// </summary>
        public List <PHIEUNHAPXE_DTO> SelectAll()
        {
            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(m_ConnectionString, CommandType.StoredProcedure, "PROC_PhieuNhapXe_SelectAll"))
            {
                List <PHIEUNHAPXE_DTO> PhieuNhapXeList = new List <PHIEUNHAPXE_DTO>();
                while (dataReader.Read())
                {
                    PHIEUNHAPXE_DTO PhieuNhapXe = MakePHIEUNHAPXE_DTO(dataReader);
                    PhieuNhapXeList.Add(PhieuNhapXe);
                }

                return(PhieuNhapXeList);
            }
        }
Exemple #4
0
        /// <summary>
        /// Selects all records from the PHIEU_NHAP_XE table by a foreign key.
        /// </summary>
        public List <PHIEUNHAPXE_DTO> SelectAllByMaDonDatHang(int MaDonDatHang)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@MA_DON_DAT_HANG", MaDonDatHang)
            };

            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(m_ConnectionString, CommandType.StoredProcedure, "PROC_PhieuNhapXeSelectAllByMaDonDatHang", parameters))
            {
                List <PHIEUNHAPXE_DTO> PhieuNhapXeList = new List <PHIEUNHAPXE_DTO>();
                while (dataReader.Read())
                {
                    PHIEUNHAPXE_DTO PhieuNhapXe = MakePHIEUNHAPXE_DTO(dataReader);
                    PhieuNhapXeList.Add(PhieuNhapXe);
                }

                return(PhieuNhapXeList);
            }
        }
Exemple #5
0
        private void btn_LapPhieu_Click(object sender, EventArgs e)
        {
            PHIEUNHAPXE_DTO PhieuNhapXeDto = new PHIEUNHAPXE_DTO();

            PhieuNhapXeDto.MaDonDatHang = int.Parse(txt_MaDDH.Text.Trim());
            PhieuNhapXeDto.NgayNhap     = DateTime.Parse(txt_NgayNhap.Text.Trim());
            PhieuNhapXeDto.TongSoLuong  = int.Parse(txt_TongSoLuong.Text.Trim());
            PHIEUNHAPXE_BUS PhieuNhapBus = new PHIEUNHAPXE_BUS();

            PhieuNhapBus.Insert(PhieuNhapXeDto);

            CTPHIEUNHAPXE_BUS CTPhieuNhapBus = new CTPHIEUNHAPXE_BUS();

            for (int i = 0; i < CTPhieuNhapDto_List.Count; i++)
            {
                CTPhieuNhapDto_List[i].MaPhieuNhapXe = PhieuNhapXeDto.Ma;
                CTPhieuNhapBus.Insert(CTPhieuNhapDto_List[i]);
            }
            MessageBox.Show("Đã lập xong phiếu nhập xe", "", MessageBoxButtons.OK);
        }
 /// <summary>
 /// Updates a record in the PHIEU_NHAP_XE table.
 /// </summary>
 public void Update(PHIEUNHAPXE_DTO PhieuNhapXe)
 {
     ValidationUtility.ValidateArgument("PhieuNhapXe", PhieuNhapXe);
     new PHIEUNHAPXE_DAO().Update(PhieuNhapXe);
 }