Пример #1
0
        /// <summary>
        /// Creates a new instance of the PHIEU_XUAT_XE class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private PHIEUXUATXE_DTO MakePHIEUXUATXE_DTO(SqlDataReader dataReader)
        {
            PHIEUXUATXE_DTO PhieuXuatXe = new PHIEUXUATXE_DTO();

            PhieuXuatXe.Ma          = SqlClientUtility.GetInt32(dataReader, "MA", 0);
            PhieuXuatXe.NgayXuat    = SqlClientUtility.GetDateTime(dataReader, "NGAY_XUAT", DateTime.Now);
            PhieuXuatXe.MaNhanVien  = SqlClientUtility.GetInt32(dataReader, "MA_NHAN_VIEN", 0);
            PhieuXuatXe.TongSoLuong = SqlClientUtility.GetInt32(dataReader, "TONG_SO_LUONG", 0);

            return(PhieuXuatXe);
        }
Пример #2
0
        /// <summary>
        /// Saves a record to the PHIEU_XUAT_XE table.
        /// </summary>
        public void Insert(PHIEUXUATXE_DTO PhieuXuatXe)
        {
            ValidationUtility.ValidateArgument("PhieuXuatXe", PhieuXuatXe);

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@NGAY_XUAT", PhieuXuatXe.NgayXuat),
                new SqlParameter("@MA_NHAN_VIEN", PhieuXuatXe.MaNhanVien),
                new SqlParameter("@TONG_SO_LUONG", PhieuXuatXe.TongSoLuong)
            };

            PhieuXuatXe.Ma = (int)SqlClientUtility.ExecuteScalar(m_ConnectionString, CommandType.StoredProcedure, "PROC_PhieuXuatXe_Insert", parameters);
        }
Пример #3
0
        /// <summary>
        /// Selects all records from the PHIEU_XUAT_XE table.
        /// </summary>
        public List <PHIEUXUATXE_DTO> SelectAll()
        {
            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(m_ConnectionString, CommandType.StoredProcedure, "PROC_PhieuXuatXe_SelectAll"))
            {
                List <PHIEUXUATXE_DTO> PhieuXuatXeList = new List <PHIEUXUATXE_DTO>();
                while (dataReader.Read())
                {
                    PHIEUXUATXE_DTO PhieuXuatXe = MakePHIEUXUATXE_DTO(dataReader);
                    PhieuXuatXeList.Add(PhieuXuatXe);
                }

                return(PhieuXuatXeList);
            }
        }
Пример #4
0
        /// <summary>
        /// Selects all records from the PHIEU_XUAT_XE table by a foreign key.
        /// </summary>
        public List <PHIEUXUATXE_DTO> SelectAllByMaNhanVien(int MaNhanVien)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@MA_NHAN_VIEN", MaNhanVien)
            };

            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(m_ConnectionString, CommandType.StoredProcedure, "PROC_PhieuXuatXeSelectAllByMaNhanVien", parameters))
            {
                List <PHIEUXUATXE_DTO> PhieuXuatXeList = new List <PHIEUXUATXE_DTO>();
                while (dataReader.Read())
                {
                    PHIEUXUATXE_DTO PhieuXuatXe = MakePHIEUXUATXE_DTO(dataReader);
                    PhieuXuatXeList.Add(PhieuXuatXe);
                }

                return(PhieuXuatXeList);
            }
        }
        private void btn_LapPhieu_Click(object sender, EventArgs e)
        {
            PHIEUXUATXE_DTO PhieuXuatDto = new PHIEUXUATXE_DTO();

            PhieuXuatDto.MaNhanVien  = int.Parse(txt_MaNhanVien.Text.Trim());
            PhieuXuatDto.NgayXuat    = DateTime.Parse(txt_NgayXuat.Text.Trim());
            PhieuXuatDto.TongSoLuong = 0;

            //Tao cac chi tiet phieu xuat
            List <CHITIETPHIEUXUATXE_DTO> CTPhieuXuatDto_List = new List <CHITIETPHIEUXUATXE_DTO>();

            for (int i = 0; i < grid_ChiTietPhieuXuat.Rows.Count; i++)
            {
                CheckBox chk_box = (CheckBox)grid_ChiTietPhieuXuat.Rows[i].Cells["Check"].Value;
                if (chk_box.Checked)
                {
                    CHITIETPHIEUXUATXE_DTO CTPhieuXuatDto = new CHITIETPHIEUXUATXE_DTO();
                    CTPhieuXuatDto.MaXe    = int.Parse(grid_ChiTietPhieuXuat.Rows[i].Cells["Ma"].Value.ToString());
                    CTPhieuXuatDto.MaMau   = grid_ChiTietPhieuXuat.Rows[i].Cells["MaMau"].Value.ToString();
                    CTPhieuXuatDto.SoLuong = int.Parse(grid_ChiTietPhieuXuat.Rows[i].Cells["SoLuongXuat"].Value.ToString());

                    CTPhieuXuatDto_List.Add(CTPhieuXuatDto);
                    PhieuXuatDto.TongSoLuong += CTPhieuXuatDto.SoLuong;
                }
            }

            txt_TongSoLuong.Text = PhieuXuatDto.TongSoLuong.ToString();

            //them 1 phieu xuat moi vao CSDL
            PHIEUXUATXE_BUS PhieuXuatBus = new PHIEUXUATXE_BUS();

            PhieuXuatBus.Insert(PhieuXuatDto);
            txt_MaPhieuXuat.Text = PhieuXuatDto.Ma.ToString();

            //Cap nhat lai thong tin ma phieu xuat xe vao chi tiet phieu xuat xe, va them chi tiet phieu xe vao CSDL
            CHITIETPHIEUXUATXE_BUS CTPhieuXuatBus = new CHITIETPHIEUXUATXE_BUS();

            for (int i = 0; i < CTPhieuXuatDto_List.Count; i++)
            {
                CTPhieuXuatDto_List[i].MaPhieuXuatXe = PhieuXuatDto.Ma;
                CTPhieuXuatBus.Insert(CTPhieuXuatDto_List[i]);
            }
        }
Пример #6
0
 /// <summary>
 /// Updates a record in the PHIEU_XUAT_XE table.
 /// </summary>
 public void Update(PHIEUXUATXE_DTO PhieuXuatXe)
 {
     ValidationUtility.ValidateArgument("PhieuXuatXe", PhieuXuatXe);
     new PHIEUXUATXE_DAO().Update(PhieuXuatXe);
 }