Esempio n. 1
0
        /// <summary>
        /// Creates a new instance of the CHI_TIET_PHIEU_XUAT_XE class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private CHITIETPHIEUXUATXE_DTO MakeCHITIETPHIEUXUATXE_DTO(SqlDataReader dataReader)
        {
            CHITIETPHIEUXUATXE_DTO ChiTietPhieuXuatXe = new CHITIETPHIEUXUATXE_DTO();

            ChiTietPhieuXuatXe.MaPhieuXuatXe = SqlClientUtility.GetInt32(dataReader, "MA_PHIEU_XUAT_XE", 0);
            ChiTietPhieuXuatXe.MaXe          = SqlClientUtility.GetInt32(dataReader, "MA_XE", 0);
            ChiTietPhieuXuatXe.MaMau         = SqlClientUtility.GetString(dataReader, "MA_MAU", String.Empty);
            ChiTietPhieuXuatXe.SoLuong       = SqlClientUtility.GetInt32(dataReader, "SO_LUONG", 0);

            return(ChiTietPhieuXuatXe);
        }
Esempio n. 2
0
        /// <summary>
        /// Updates a record in the CHI_TIET_PHIEU_XUAT_XE table.
        /// </summary>
        public void Update(CHITIETPHIEUXUATXE_DTO ChiTietPhieuXuatXe)
        {
            ValidationUtility.ValidateArgument("ChiTietPhieuXuatXe", ChiTietPhieuXuatXe);

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@MA_PHIEU_XUAT_XE", ChiTietPhieuXuatXe.MaPhieuXuatXe),
                new SqlParameter("@MA_XE", ChiTietPhieuXuatXe.MaXe),
                new SqlParameter("@MA_MAU", ChiTietPhieuXuatXe.MaMau),
                new SqlParameter("@SO_LUONG", ChiTietPhieuXuatXe.SoLuong)
            };

            SqlClientUtility.ExecuteNonQuery(m_ConnectionString, CommandType.StoredProcedure, "PROC_ChiTietPhieuXuatXe_Update", parameters);
        }
Esempio n. 3
0
        /// <summary>
        /// Selects all records from the CHI_TIET_PHIEU_XUAT_XE table.
        /// </summary>
        public List <CHITIETPHIEUXUATXE_DTO> SelectAll()
        {
            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(m_ConnectionString, CommandType.StoredProcedure, "PROC_ChiTietPhieuXuatXe_SelectAll"))
            {
                List <CHITIETPHIEUXUATXE_DTO> ChiTietPhieuXuatXeList = new List <CHITIETPHIEUXUATXE_DTO>();
                while (dataReader.Read())
                {
                    CHITIETPHIEUXUATXE_DTO ChiTietPhieuXuatXe = MakeCHITIETPHIEUXUATXE_DTO(dataReader);
                    ChiTietPhieuXuatXeList.Add(ChiTietPhieuXuatXe);
                }

                return(ChiTietPhieuXuatXeList);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Selects all records from the CHI_TIET_PHIEU_XUAT_XE table by a foreign key.
        /// </summary>
        public List <CHITIETPHIEUXUATXE_DTO> SelectAllByMaXe(int MaXe)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@MA_XE", MaXe)
            };

            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(m_ConnectionString, CommandType.StoredProcedure, "PROC_ChiTietPhieuXuatXeSelectAllByMaXe", parameters))
            {
                List <CHITIETPHIEUXUATXE_DTO> ChiTietPhieuXuatXeList = new List <CHITIETPHIEUXUATXE_DTO>();
                while (dataReader.Read())
                {
                    CHITIETPHIEUXUATXE_DTO ChiTietPhieuXuatXe = MakeCHITIETPHIEUXUATXE_DTO(dataReader);
                    ChiTietPhieuXuatXeList.Add(ChiTietPhieuXuatXe);
                }

                return(ChiTietPhieuXuatXeList);
            }
        }
        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]);
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Updates a record in the CHI_TIET_PHIEU_XUAT_XE table.
 /// </summary>
 public void Update(CHITIETPHIEUXUATXE_DTO ChiTietPhieuXuatXe)
 {
     ValidationUtility.ValidateArgument("ChiTietPhieuXuatXe", ChiTietPhieuXuatXe);
     new CHITIETPHIEUXUATXE_DAO().Update(ChiTietPhieuXuatXe);
 }