Beispiel #1
0
        public bool xoa(ChiTietPhieuXuatDTO ctpx)
        {
            string query = string.Empty;

            query += "DELETE FROM CHITIETPHIEUXUAT WHERE [MaChiTietPhieuXuat] = @MaChiTietPhieuXuat";
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = query;
                    cmd.Parameters.AddWithValue("@MaChiTietPhieuXuat", ctpx.Mactpx);
                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        con.Dispose();
                    }
                    catch (Exception ex)
                    {
                        con.Close();
                        return(false);
                    }
                }
            }
            return(true);
        }
        public static ChiTietPhieuXuatDTO SelectChiTietPhieuXuatById(string MaChiTietPhieuXuat)
        {
            List <SqlParameter> sqlParamas = new List <SqlParameter>();

            sqlParamas.Add(new SqlParameter("@MaChiTietPhieuXuat", MaChiTietPhieuXuat));
            DataTable           dataTable           = DataProvider.ExecuteReader("usp_SelectChiTietPhieuXuatById", sqlParamas);
            ChiTietPhieuXuatDTO chiTietPhieuXuatDTO = new ChiTietPhieuXuatDTO();

            if (dataTable.Rows.Count > 0)
            {
                DataRow dataRow = dataTable.Rows[0];
                chiTietPhieuXuatDTO.MaChiTietPhieuXuat = dataRow["MaChiTietPhieuXuat"].ToString();
                chiTietPhieuXuatDTO.MaPhieuXuat        = dataRow["MaPhieuXuat"].ToString();
                chiTietPhieuXuatDTO.MaSanPham          = dataRow["MaSanPham"].ToString();
                chiTietPhieuXuatDTO.CV      = Int32.Parse(dataRow["CV"].ToString());
                chiTietPhieuXuatDTO.DonGia  = Int32.Parse(dataRow["DonGia"].ToString());
                chiTietPhieuXuatDTO.SoLuong = Int32.Parse(dataRow["SoLuong"].ToString());
            }
            else
            {
                chiTietPhieuXuatDTO = null;
            }

            return(chiTietPhieuXuatDTO);
        }
        public static List <ChiTietPhieuXuatDTO> SelectChiTietPhieuXuatAll()
        {
            DataTable dataTable = DataProvider.ExecuteReader("usp_SelectChiTietPhieuXuatAll");
            List <ChiTietPhieuXuatDTO> listChiTietPhieuXuatDTO = new List <ChiTietPhieuXuatDTO>();

            if (dataTable.Rows.Count > 0)
            {
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    ChiTietPhieuXuatDTO chiTietPhieuXuatDTO = new ChiTietPhieuXuatDTO();
                    chiTietPhieuXuatDTO.MaChiTietPhieuXuat = dataRow["MaChiTietPhieuXuat"].ToString();
                    chiTietPhieuXuatDTO.MaPhieuXuat        = dataRow["MaPhieuXuat"].ToString();
                    chiTietPhieuXuatDTO.MaSanPham          = dataRow["MaSanPham"].ToString();
                    chiTietPhieuXuatDTO.CV        = Int32.Parse(dataRow["CV"].ToString());
                    chiTietPhieuXuatDTO.DonGia    = Int32.Parse(dataRow["DonGia"].ToString());
                    chiTietPhieuXuatDTO.SoLuong   = Int32.Parse(dataRow["SoLuong"].ToString());
                    chiTietPhieuXuatDTO.ThanhTien = Int32.Parse(dataRow["ThanhTien"].ToString());
                    listChiTietPhieuXuatDTO.Add(chiTietPhieuXuatDTO);
                }
            }
            else
            {
                listChiTietPhieuXuatDTO = null;
            }
            return(listChiTietPhieuXuatDTO);
        }
Beispiel #4
0
        private void bt_luu_Click(object sender, EventArgs e)
        {
            if (check_null())
            {
                ChiTietPhieuXuatDTO ctpx = new ChiTietPhieuXuatDTO();
                ctpx.Mactpx    = int.Parse(tb_machitiet.Text);
                ctpx.Mahs      = int.Parse(lb_mahs.Text);
                ctpx.Mavtpt    = int.Parse(cb_vattu.SelectedValue.ToString());
                ctpx.Nd        = tb_noidung.Text;
                ctpx.Soluong   = int.Parse(tb_soluong.Text);
                ctpx.Dongia    = int.Parse(tb_dongia.Text);
                ctpx.Maloaitc  = int.Parse(cb_tiencong.SelectedValue.ToString());
                ctpx.Tiencong  = int.Parse(tb_giatiencong.Text);
                ctpx.Thanhtien = ctpx.Tiencong + ctpx.Soluong * ctpx.Dongia;
                //ctpx.Thanhtien = int.Parse(tb_thanhtien.Text);
                ctpx.Bienso      = tb_bienso.Text;
                ctpx.Ngaysuachua = time_ngaysuachua.Value;

                //2. Kiểm tra data hợp lệ or not

                //3. Thêm vào DB
                bool kq = ctpxBus.them(ctpx);
                if (kq == false)
                {
                    MessageBox.Show("Thêm phiếu thất bại. Vui lòng kiểm tra lại dữ liệu");
                }
                else
                {
                    MessageBox.Show("Thêm phiếu thành công");
                    this.loadData_Vao_GridView();
                }
                CurrencyManager myCurrencyManager = (CurrencyManager)this.BindingContext[data_suachua.DataSource];
                myCurrencyManager.Refresh();
            }
        }
Beispiel #5
0
        private void bt_sua_Click(object sender, EventArgs e)
        {
            if (check_null())
            {
                ChiTietPhieuXuatDTO ctpx = new ChiTietPhieuXuatDTO();
                ctpx.Mactpx   = int.Parse(tb_machitiet.Text);
                ctpx.Mahs     = int.Parse(lb_mahs.Text);
                ctpx.Mavtpt   = int.Parse(cb_vattu.SelectedValue.ToString());
                ctpx.Nd       = tb_noidung.Text;
                ctpx.Soluong  = int.Parse(tb_soluong.Text);
                ctpx.Dongia   = int.Parse(tb_dongia.Text);
                ctpx.Maloaitc = int.Parse(cb_tiencong.SelectedValue.ToString());
                ctpx.Tiencong = int.Parse(tb_giatiencong.Text);
                //ctpx.Vtpt =
                ctpx.Thanhtien = ctpx.Tiencong + ctpx.Soluong * ctpx.Dongia;
                //tb_thanhtien.Text = ctpx.Thanhtien.ToString();
                ctpx.Bienso      = tb_bienso.Text;
                ctpx.Ngaysuachua = time_ngaysuachua.Value;

                bool kq = ctpxBus.sua(ctpx);
                if (kq == false)
                {
                    MessageBox.Show("Sửa phiếu thất bại. Vui lòng kiểm tra lại dữ liệu");
                }
                else
                {
                    this.loadData_Vao_GridView();
                    MessageBox.Show("Sửa phiếu thành công");
                }
            }
        }
        public static List <ChiTietPhieuXuatDTO> SelectChiTietPhieuXuatByMaPhieuXuat(string MaPhieuXuat)
        {
            List <SqlParameter> sqlParamas = new List <SqlParameter>();

            sqlParamas.Add(new SqlParameter("@MaPhieuXuat", MaPhieuXuat));
            DataTable dataTable = new DataTable();

            dataTable = DataProvider.ExecuteReader("usp_SelectChiTietPhieuXuatByMaPhieuXuat", sqlParamas);
            List <ChiTietPhieuXuatDTO> listChiTietPhieuXuatDTO = new List <ChiTietPhieuXuatDTO>();

            if (dataTable.Rows.Count > 0)
            {
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    ChiTietPhieuXuatDTO chiTietPhieuXuatDTO = new ChiTietPhieuXuatDTO();
                    chiTietPhieuXuatDTO.MaChiTietPhieuXuat = dataRow["MaChiTietPhieuXuat"].ToString();
                    chiTietPhieuXuatDTO.MaPhieuXuat        = dataRow["MaPhieuXuat"].ToString();
                    chiTietPhieuXuatDTO.MaSanPham          = dataRow["MaSanPham"].ToString();
                    chiTietPhieuXuatDTO.CV        = Int32.Parse(dataRow["CV"].ToString());
                    chiTietPhieuXuatDTO.DonGia    = Int32.Parse(dataRow["DonGia"].ToString());
                    chiTietPhieuXuatDTO.SoLuong   = Int32.Parse(dataRow["SoLuong"].ToString());
                    chiTietPhieuXuatDTO.ThanhTien = Int32.Parse(dataRow["ThanhTien"].ToString());
                    listChiTietPhieuXuatDTO.Add(chiTietPhieuXuatDTO);
                }
            }
            else
            {
                listChiTietPhieuXuatDTO = null;
            }
            return(listChiTietPhieuXuatDTO);
        }
        public static bool UpdateChiTietPhieuXuatById(ChiTietPhieuXuatDTO chiTietPhieuXuatDTO)
        {
            List <SqlParameter> sqlParams = new List <SqlParameter>();

            sqlParams.Add(new SqlParameter("@MaChiTietPhieuXuat", chiTietPhieuXuatDTO.MaChiTietPhieuXuat));
            sqlParams.Add(new SqlParameter("@MaPhieuXuat", chiTietPhieuXuatDTO.MaPhieuXuat));
            sqlParams.Add(new SqlParameter("@MaSanPham", chiTietPhieuXuatDTO.MaSanPham));
            sqlParams.Add(new SqlParameter("@CV", chiTietPhieuXuatDTO.CV));
            sqlParams.Add(new SqlParameter("@DonGia", chiTietPhieuXuatDTO.DonGia));
            sqlParams.Add(new SqlParameter("@SoLuong", chiTietPhieuXuatDTO.SoLuong));
            sqlParams.Add(new SqlParameter("@ThanhTien", chiTietPhieuXuatDTO.ThanhTien));
            return(DataProvider.ExecuteNoneQuery("usp_UpdateChiTietPhieuXuatById", sqlParams));
        }
Beispiel #8
0
        //sửa chi tiết phiếu xuất
        public int UpdateCTPX(ChiTietPhieuXuatDTO chiTietPhieuXuat)
        {
            int    result = 0;
            string Query  = "Update CTPhieuXuat set MaSP ='" + chiTietPhieuXuat.MaSP + "', SoLuong = '" + chiTietPhieuXuat.SoLuong + "', MaNV = '" + chiTietPhieuXuat.MaKH + "',GiaNhap = '" + chiTietPhieuXuat.GiamGia + "'";

            try
            {
                result = DBcon.ExecuteSPNoneQuery(Query);
            }
            catch (SqlException ex)
            {
            }
            return(result);
        }
Beispiel #9
0
        //Thêm CHI TIẾT PHIẾU xuất
        public int InsertCTPX(ChiTietPhieuXuatDTO chiTietPhieuXuat)
        {
            int    result = 0;
            string Query  = "Insert into CTPhieuXuat values('" + chiTietPhieuXuat.MaPX + "', '" + chiTietPhieuXuat.MaSP + "', '" + chiTietPhieuXuat.SoLuong + "', '" + chiTietPhieuXuat.MaKH + "','" + chiTietPhieuXuat.GiamGia + "')";

            try
            {
                result = DBcon.ExecuteSPNoneQuery(Query);
            }
            catch (SqlException ex)
            {
            }
            return(result);
        }
Beispiel #10
0
        private void bt_xoa_Click(object sender, EventArgs e)
        {
            ChiTietPhieuXuatDTO ctpx = new ChiTietPhieuXuatDTO();

            ctpx.Mactpx = int.Parse(tb_machitiet.Text);
            //2. Kiểm tra data hợp lệ or not

            //3. Thêm vào DB
            bool kq = ctpxBus.xoa(ctpx);

            if (kq == false)
            {
                MessageBox.Show("Xóa phiếu thất bại. Vui lòng kiểm tra lại dữ liệu");
            }
            else
            {
                this.loadData_Vao_GridView();
                MessageBox.Show("Xóa phiếu thành công");
            }
        }
Beispiel #11
0
        public bool them(ChiTietPhieuXuatDTO ctpx)
        {
            string query = string.Empty;

            query += "INSERT INTO [dbo].[CHITIETPHIEUXUAT]([MaChiTietPhieuXuat],[MaHoSo],[MaLoaiVatTu],[NoiDung],[SoLuong],[MaLoaiTienCong],[BienSo],[NgaySuaChua],[ThanhTien])";
            query += " VALUES (@MaChiTietPhieuXuat,@MaHoSo,@MaLoaiVatTu,@NoiDung,@SoLuong,@MaLoaiTienCong,@BienSo,@NgaySuaChua,@ThanhTien)";
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = query;
                    cmd.Parameters.AddWithValue("@MaChiTietPhieuXuat", ctpx.Mactpx);
                    cmd.Parameters.AddWithValue("@MaHoSo", ctpx.Mahs);
                    cmd.Parameters.AddWithValue("@MaLoaiVatTu", ctpx.Mavtpt);
                    cmd.Parameters.AddWithValue("@NoiDung", ctpx.Nd);
                    cmd.Parameters.AddWithValue("@SoLuong", ctpx.Soluong);
                    cmd.Parameters.AddWithValue("@MaLoaiTienCong", ctpx.Maloaitc);
                    cmd.Parameters.AddWithValue("@BienSo", ctpx.Bienso);
                    cmd.Parameters.AddWithValue("@NgaySuaChua", ctpx.Ngaysuachua);
                    cmd.Parameters.AddWithValue("@ThanhTien", ctpx.Thanhtien);
                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        con.Dispose();
                    }
                    catch (Exception ex)
                    {
                        con.Close();
                        return(false);
                    }
                }
            }
            return(true);
        }
Beispiel #12
0
        public bool sua(ChiTietPhieuXuatDTO ctpx)
        {
            string query = string.Empty;

            query += "UPDATE CHITIETPHIEUXUAT SET [MaLoaiVatTu] = @MaLoaiVatTu, [NoiDung] = @NoiDung,[SoLuong] = @SoLuong,[MaLoaiTienCong] = @MaLoaiTienCong,[BienSo] = @BienSo,[NgaySuaChua] = @NgaySuaChua,[ThanhTien]=@ThanhTien";
            query += " WHERE [MaChiTietPhieuXuat] = @MaChiTietPhieuXuat";
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = query;
                    cmd.Parameters.AddWithValue("@MaChiTietPhieuXuat", ctpx.Mactpx);
                    cmd.Parameters.AddWithValue("@MaLoaiVatTu", ctpx.Mavtpt);
                    cmd.Parameters.AddWithValue("@NoiDung", ctpx.Nd);
                    cmd.Parameters.AddWithValue("@SoLuong", ctpx.Soluong);
                    cmd.Parameters.AddWithValue("@MaLoaiTienCong", ctpx.Maloaitc);
                    cmd.Parameters.AddWithValue("@BienSo", ctpx.Bienso);
                    cmd.Parameters.AddWithValue("@NgaySuaChua", ctpx.Ngaysuachua);
                    cmd.Parameters.AddWithValue("@ThanhTien", ctpx.Thanhtien);
                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        con.Dispose();
                    }
                    catch (Exception ex)
                    {
                        con.Close();
                        return(false);
                    }
                }
            }
            return(true);
        }
Beispiel #13
0
        public bool sua(ChiTietPhieuXuatDTO ctpx)
        {
            bool re = ctpxDal.sua(ctpx);

            return(re);
        }
Beispiel #14
0
        private bool Process_Button()
        {
            //Lấy các trường để insert vào bảng PhieuXuat
            PhieuXuatDTO phieuXuatDTO = new PhieuXuatDTO();

            phieuXuatDTO.MaPhieuXuat = txtMaPhieuXuat.Text;
            phieuXuatDTO.NgayBan     = DateTimeSystem;
            phieuXuatDTO.MaNhanVien  = ThongTin.NhanVienDTO.MaNhanVien;

            if (txtMaThanhVien.Text == "")
            {
                //MaThanhVien Thamchieu bang ThanhVien => notnull=>sua storeproc
                phieuXuatDTO.MaThanhVien = null;

                if (txtTenKhachHang.Text == "")
                {
                    MessageBox.Show("Tên khách hàng không hợp lệ");
                    return(false);
                }
                else
                {
                    phieuXuatDTO.TenKhachHang = txtTenKhachHang.Text;
                }

                if (txtDiaChi.Text == "")
                {
                    MessageBox.Show("Địa chỉ không hợp lệ");
                    return(false);
                }
                else
                {
                    phieuXuatDTO.DiaChi = txtDiaChi.Text;
                }
                phieuXuatDTO.MaLoaiPhieuXuat = "LPX02";
            }
            else
            {
                phieuXuatDTO.MaThanhVien     = txtMaThanhVien.Text;
                phieuXuatDTO.TenKhachHang    = txtTenKhachHang.Text;
                phieuXuatDTO.DiaChi          = txtDiaChi.Text;
                phieuXuatDTO.MaLoaiPhieuXuat = "LPX01";
            }

            //Lấy các trường để insert vào bảng ChiTietPhieuXuat
            List <ChiTietPhieuXuatDTO> listChiTietPhieuXuatDTO = new List <ChiTietPhieuXuatDTO>();
            SanPhamDTO sanPhamDTO = new SanPhamDTO();

            for (int i = 0; i < dataGridView_XuatHang.Rows.Count; i++)
            {
                ChiTietPhieuXuatDTO chiTietPhieuXuatDTO = new ChiTietPhieuXuatDTO();
                DataGridViewRow     Row = dataGridView_XuatHang.Rows[i];
                int check;
                int.TryParse(Row.Cells["clSoLuong"].Value.ToString(), out check);
                if (check > 0)
                {
                    chiTietPhieuXuatDTO.MaChiTietPhieuXuat = txtMaPhieuXuat.Text;
                    if (i > 100)
                    {
                        chiTietPhieuXuatDTO.MaChiTietPhieuXuat += (i + 1).ToString();
                    }
                    else if (i > 100)
                    {
                        chiTietPhieuXuatDTO.MaChiTietPhieuXuat += "0" + (i + 1).ToString();
                    }
                    else
                    {
                        chiTietPhieuXuatDTO.MaChiTietPhieuXuat += "00" + (i + 1).ToString();
                    }

                    chiTietPhieuXuatDTO.MaPhieuXuat = txtMaPhieuXuat.Text;
                    chiTietPhieuXuatDTO.MaSanPham   = Row.Cells["clMaSanPham"].Value.ToString();
                    chiTietPhieuXuatDTO.CV          = int.Parse(Row.Cells["clCV"].Value.ToString());
                    chiTietPhieuXuatDTO.SoLuong     = int.Parse(Row.Cells["clSoLuong"].Value.ToString());
                    chiTietPhieuXuatDTO.DonGia      = float.Parse(Row.Cells["clDonGia"].Value.ToString());
                    chiTietPhieuXuatDTO.ThanhTien   = float.Parse(Row.Cells["clThanhTien"].Value.ToString());
                    listChiTietPhieuXuatDTO.Add(chiTietPhieuXuatDTO);

                    //Tinh SoLuongTon của sản phẩm
                    int SoLuongTon = int.Parse(Row.Cells["clSoLuongTon"].Value.ToString()) - int.Parse(Row.Cells["clSoLuong"].Value.ToString());
                    sanPhamDTO            = SanPhamBUS.SelectSanPhamById(chiTietPhieuXuatDTO.MaSanPham);
                    sanPhamDTO.SoLuongTon = SoLuongTon;
                    SanPhamBUS.UpdateSanPhamById(sanPhamDTO);

                    //Tinh TongCV
                    TongCV += int.Parse(Row.Cells["clCV"].Value.ToString()) * int.Parse(Row.Cells["clSoLuong"].Value.ToString());
                }
            }

            //insert dữ liệu
            if (PhieuXuatBUS.InsertPhieuXuat(phieuXuatDTO))
            {
                foreach (ChiTietPhieuXuatDTO chiTietPhieuXuatDTO in listChiTietPhieuXuatDTO)
                {
                    ChiTietPhieuXuatBUS.InsertChiTietPhieuXuat(chiTietPhieuXuatDTO);
                }
                if (IsThanhVien == true)
                {
                    thanhVienDTO.CV += TongCV;
                    ThanhVienBUS.UpdateThanhVienById(thanhVienDTO);
                }

                MessageBox.Show("Nhập dữ liệu thành công");
                return(true);
            }
            else
            {
                MessageBox.Show("Nhập dữ liệu thất bại");
            }
            return(false);
        }
Beispiel #15
0
        public bool them(ChiTietPhieuXuatDTO ctpx)
        {
            bool re = ctpxDal.them(ctpx);

            return(re);
        }
Beispiel #16
0
 public int UpdateCTPX(ChiTietPhieuXuatDTO chiTiet)
 {
     return(chiTietPhieuXuat.UpdateCTPX(chiTiet));
 }
Beispiel #17
0
 public int InsertCTPX(ChiTietPhieuXuatDTO chiTiet)
 {
     return(chiTietPhieuXuat.InsertCTPX(chiTiet));
 }
 public static bool InsertChiTietPhieuXuat(ChiTietPhieuXuatDTO chiTietPhieuXuatDTO)
 {
     return(ChiTietPhieuXuatDAO.InsertChiTietPhieuXuat(chiTietPhieuXuatDTO));
 }
 public static bool UpdateChiTietPhieuXuatById(ChiTietPhieuXuatDTO chiTietPhieuXuatDTO)
 {
     return(ChiTietPhieuXuatDAO.UpdateChiTietPhieuXuatById(chiTietPhieuXuatDTO));
 }
Beispiel #20
0
        public List <ChiTietPhieuXuatDTO> select(string sKmahs)
        {
            string query = string.Empty;

            query += "SELECT [MaHoSo],[dbo].[CHITIETPHIEUXUAT].MaChiTietPhieuXuat,[SoLuong],[TenLoaiVatTu],[dbo].[LOAIVATTU].DonGia,[TienCong],[ThanhTien],[BienSo],[NgaySuaChua],[NoiDung],[TenLoaiTienCong]";
            query += ",[dbo].[LOAITIENCONG].MaLoaiTienCong,[dbo].[CHITIETPHIEUXUAT].MaLoaiVatTu";//, SUM(ThanhTien) AS TongTien";
            query += " FROM [dbo].[CHITIETPHIEUXUAT]";
            query += " join [dbo].LOAIVATTU on [dbo].[CHITIETPHIEUXUAT].MaLoaiVatTu = [dbo].[LOAIVATTU].MaLoaiVatTu";
            query += " join [dbo].LOAITIENCONG on [dbo].[CHITIETPHIEUXUAT].MaLoaiTienCong = [dbo].[LOAITIENCONG].MaLoaiTienCong";
            query += " WHERE [MaHoSo] = @MaHoSo";
            List <ChiTietPhieuXuatDTO> lsCtpx = new List <ChiTietPhieuXuatDTO>();

            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = query;
                    cmd.Parameters.AddWithValue("@MaHoSo", sKmahs);
                    try
                    {
                        con.Open();
                        SqlDataReader reader = null;
                        reader = cmd.ExecuteReader();
                        if (reader.HasRows == true)
                        {
                            while (reader.Read())
                            {
                                ChiTietPhieuXuatDTO ctpx = new ChiTietPhieuXuatDTO();
                                //HoSoDTO hs = new HoSoDTO();
                                ctpx.Mactpx      = int.Parse(reader["MaChiTietPhieuXuat"].ToString());
                                ctpx.Mahs        = int.Parse(reader["MaHoSo"].ToString());
                                ctpx.Tiencong    = int.Parse(reader["TienCong"].ToString());
                                ctpx.Tenloaitc   = reader["TenLoaiTienCong"].ToString();
                                ctpx.Vtpt        = reader["TenLoaiVatTu"].ToString();
                                ctpx.Soluong     = int.Parse(reader["SoLuong"].ToString());
                                ctpx.Dongia      = (int)float.Parse(reader["DonGia"].ToString());
                                ctpx.Ngaysuachua = DateTime.Parse(reader["NgaySuaChua"].ToString());
                                ctpx.Nd          = reader["NoiDung"].ToString();
                                ctpx.Bienso      = reader["BienSo"].ToString();
                                ctpx.Mavtpt      = int.Parse(reader["MaLoaiVatTu"].ToString());
                                ctpx.Maloaitc    = int.Parse(reader["MaLoaiTienCong"].ToString());
                                ctpx.Mahs        = int.Parse(reader["MaHoSo"].ToString());
                                ctpx.Thanhtien   = int.Parse(reader["ThanhTien"].ToString());
                                //hs.Tongtien = int.Parse(reader["TongTien"].ToString());
                                lsCtpx.Add(ctpx);
                            }
                        }

                        con.Close();
                        con.Dispose();
                    }
                    catch (Exception ex)
                    {
                        con.Close();
                        return(null);
                    }
                }
            }
            return(lsCtpx);
        }