示例#1
0
        public static KhachHangDTO LayKhachHang(int MaKH)
        {
            SqlConnection cnn = KetNoiCSDL.TaoKetNoi();
            string query = String.Format("select * from Khach_Hang where MaKH = {0}", MaKH);
            SqlCommand cmd = new SqlCommand(query, cnn);

            cnn.Open();

            try
            {
                SqlDataReader dr = cmd.ExecuteReader();
                KhachHangDTO khDto = new KhachHangDTO();
                while (dr.Read())
                {
                    khDto.MaKH = (int)dr["MaKH"];
                    khDto.HoTen = dr["HoTen"].ToString();
                    khDto.CMND = dr["CMND"].ToString();
                    khDto.DiaChi = dr["DiaChi"].ToString();
                }
                cnn.Close();
                return khDto;
            }
            catch (Exception ex)
            {
                cnn.Close();
                throw ex;
            }
        }
        public bool ThemKhachHang()
        {
            string hoKh      = txtHoKhachHang.Text;
            string tenKh     = txtTenKhachHang.Text;
            string ngaySinh  = dtpNgaySinhKhachHang.Text;
            string dienThoai = txtDienThoaiKhachHang.Text;
            string eMail     = txtEmailKhachHang.Text;
            string diaChi    = txtDiaChiKhachHang.Text;

            BLL.KhachHangBLL khachHang = new BLL.KhachHangBLL();

            if (txtHoKhachHang.Text != "" && txtTenKhachHang.Text != "" && dtpNgaySinhKhachHang.Text != "" && txtDiaChiKhachHang.Text != "" && (rbNamKhachHang.Checked == true || rbNuKhachHang.Checked == true))
            {
                if (rbNamKhachHang.Checked == true)
                {
                    // sử dụng procdure trong sql tự động sinh mã nên không cần truyền mã khách hàng xuống
                    kh = new KhachHangDTO("", hoKh, tenKh, ngaySinh, true, diaChi, dienThoai, eMail);
                }
                else
                {
                    kh = new KhachHangDTO("", hoKh, tenKh, ngaySinh, false, diaChi, dienThoai, eMail);
                }
                return(khachHang.Insert(kh));
            }
            else
            {
                MessageBox.Show("Bạn hãy nhập đầy đủ thông tin trong phần khách hàng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtHoKhachHang.Focus();
            }
            return(false);
        }
 public string UpdateKH(KhachHangDTO dtoKhachHang)
 {
     string strError = "";
     if (dtoKhachHang.TenKH.Trim().Equals("") == true)
     {
         strError += " Tên khách hàng không được rỗng.";
     }
     if (dtoKhachHang.SoTaiKhoan.Trim().Equals("") == true)
     {
         strError += " Số tài khoản không được rỗng.";
     }
     if (dtoKhachHang.MaSoThue.Trim().Equals("") == true)
     {
         strError += " Mã số thuế không được rỗng.";
     }
     if (dtoKhachHang.NganHang.Trim().Equals("") == true)
     {
         strError += " Tên ngân hàng không được rỗng.";
     }
     if (dtoKhachHang.SDT.Trim().Equals("") == true)
     {
         strError += " Số điện thoại không được rỗng.";
     }
     if (strError == "")
     {
         bool boolResult = dalKhachHang.UpdateKH(dtoKhachHang);
         return "ok";
     }
     else
     {
         return strError;
     }
 }
 public bool ThemHoaDon()
 {
     BLL.HoaDonBLL    hoaDon    = new BLL.HoaDonBLL();
     BLL.KhachHangBLL khachHang = new BLL.KhachHangBLL();
     kh = khachHang.getLastCustomer();
     hd = new DTO.HoaDonDTO("", DateTime.Now.ToString("yyyy-MM-dd"), kh.MaKH, LoginAccount.UserName);
     return(hoaDon.Insert(hd));
 }
        public static bool XoaKhachHang(KhachHangDTO KH_DTO)
        {
            SqlConnection con = DataProvider.ConnectionString();

            string strSQL = "delete from KhachHang where MaKH = " + KH_DTO.IMaKH;

            return DataProvider.ExecuteNonQuery(strSQL, con);
        }
 private void btnThemKhachHang_Click(object sender, EventArgs e)
 {
     try
     {
         KhachHangDTO dtoKhachHang = new KhachHangDTO();
         string strAction = btnThemKhachHang.Tag.ToString();
         if (strAction == "add")
         {
             dtoKhachHang.MaKH = cf.CreateId("KHA", "KHACHHANG");
             dtoKhachHang.TenKH = txtTenKhachHang.Text;
             dtoKhachHang.SoTaiKhoan = txtSoTaiKhoan.Text;
             dtoKhachHang.NganHang = txtNganHang.Text;
             dtoKhachHang.MaSoThue = txtMaSoThue.Text;
             dtoKhachHang.DiaChi = txtDiaChi.Text;
             dtoKhachHang.SDT = txtDienThoai.Text;
             dtoKhachHang.Email = txtEmail.Text;
             dtoKhachHang.GhiChu = txtGhiChu.Text;
             string strResult = bllKhachHang.InsertKhachHang(dtoKhachHang);
             if (strResult == "ok")
             {
                 MessageBox.Show("Thêm Khách Hàng Thành Công!", "Thêm Khách Hàng", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.Close();
             }
             else
             {
                 MessageBox.Show(strResult, "Thêm Khách Hàng", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             string strMaKH = txtMaKH.Text;
             dtoKhachHang.MaKH = strMaKH;
             dtoKhachHang.TenKH = txtTenKhachHang.Text;
             dtoKhachHang.SoTaiKhoan = txtSoTaiKhoan.Text;
             dtoKhachHang.NganHang = txtNganHang.Text;
             dtoKhachHang.MaSoThue = txtMaSoThue.Text;
             dtoKhachHang.DiaChi = txtDiaChi.Text;
             dtoKhachHang.SDT = txtDienThoai.Text;
             dtoKhachHang.Email = txtEmail.Text;
             dtoKhachHang.GhiChu = txtGhiChu.Text;
             string strResult = bllKhachHang.UpdateKH(dtoKhachHang);
             if (strResult == "ok")
             {
                 MessageBox.Show("Cập nhật Khách Hàng Thành Công!", "Cập Nhật Khách Hàng", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.Close();
             }
             else
             {
                 MessageBox.Show(strResult, "Cập Nhật Khách Hàng", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     catch { }
 }
        public static int Them(KhachHangDTO chuSoHuuDto, KhachHangDTO dongSoHuuDto, LoaiTienTeDTO loaiTTDto)
        {
            SqlConnection cnn = KetNoiCSDL.TaoKetNoi();
            SqlCommand cmd = new SqlCommand("sp_MoTKDongSoHuu", cnn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@HoTenCSH", SqlDbType.NVarChar);
            cmd.Parameters.Add("@CMNDCSH", SqlDbType.VarChar);
            cmd.Parameters.Add("@NgayCapCMNDCSH", SqlDbType.Date);
            cmd.Parameters.Add("@NoiCapCMNDCSH", SqlDbType.NVarChar);
            cmd.Parameters.Add("@DiaChiCSH", SqlDbType.NVarChar);
            cmd.Parameters.Add("@SoDtCSH", SqlDbType.VarChar);

            cmd.Parameters.Add("@HoTenDSH", SqlDbType.NVarChar);
            cmd.Parameters.Add("@CMNDDSH", SqlDbType.VarChar);
            cmd.Parameters.Add("@NgayCapCMNDDSH", SqlDbType.Date);
            cmd.Parameters.Add("@NoiCapCMNDDSH", SqlDbType.NVarChar);
            cmd.Parameters.Add("@DiaChiDSH", SqlDbType.NVarChar);
            cmd.Parameters.Add("@SoDtDSH", SqlDbType.VarChar);
            cmd.Parameters.Add("@LoaiTienTe", SqlDbType.Int);

            cmd.Parameters["@HoTenCSH"].Value = chuSoHuuDto.HoTen;
            cmd.Parameters["@CMNDCSH"].Value = chuSoHuuDto.CMND;
            cmd.Parameters["@NgayCapCMNDCSH"].Value = chuSoHuuDto.NgayCapCMND;
            cmd.Parameters["@NoiCapCMNDCSH"].Value = chuSoHuuDto.NoiCapCMND;
            cmd.Parameters["@DiaChiCSH"].Value = chuSoHuuDto.DiaChi;
            cmd.Parameters["@SoDtCSH"].Value = chuSoHuuDto.SoDT;

            cmd.Parameters["@HoTenDSH"].Value = dongSoHuuDto.HoTen;
            cmd.Parameters["@CMNDDSH"].Value = dongSoHuuDto.CMND;
            cmd.Parameters["@NgayCapCMNDDSH"].Value = dongSoHuuDto.NgayCapCMND;
            cmd.Parameters["@NoiCapCMNDDSH"].Value = dongSoHuuDto.NoiCapCMND;
            cmd.Parameters["@DiaChiDSH"].Value = dongSoHuuDto.DiaChi;
            cmd.Parameters["@SoDtDSH"].Value = dongSoHuuDto.SoDT;

            cmd.Parameters["@LoaiTienTe"].Value = loaiTTDto.MaLoaiTienTe;

            cnn.Open();
            int rs = 0;
            try
            {
                rs = (int)cmd.ExecuteNonQuery();
                cnn.Close();
                return rs;
            }
            catch (Exception ex)
            {
                if (cnn.State == ConnectionState.Open)
                    cnn.Close();
                throw ex;
            }
        }
 public bool InsertKhachHang(KhachHangDTO dtoKhachHang)
 {
     string strQuery = "Insert Into KHACHHANG Values(";
     strQuery += "N'" + dtoKhachHang.MaKH + "',";
     strQuery += "N'" + dtoKhachHang.TenKH + "',";
     strQuery += "N'" + dtoKhachHang.SoTaiKhoan + "',";
     strQuery += "N'" + dtoKhachHang.NganHang + "',";
     strQuery += "N'" + dtoKhachHang.MaSoThue + "',";
     strQuery += dtoKhachHang.DuNo + ",";
     strQuery += "N'" + dtoKhachHang.DiaChi + "',";
     strQuery += "N'" + dtoKhachHang.SDT + "',";
     strQuery += "N'" + dtoKhachHang.Email + "',";
     strQuery += "N'" + dtoKhachHang.GhiChu + "', 1)";
     return dp.ExecuteNonQuery(strQuery);
 }
 public bool UpdateKH(KhachHangDTO dtoKhachHang)
 {
     string strQuery = "Update KHACHHANG Set ";
     strQuery += "TENKHACHHANG = N'" + dtoKhachHang.TenKH + "',";
     strQuery += "SOTAIKHOAN = N'" + dtoKhachHang.SoTaiKhoan + "',";
     strQuery += "NGANHANG = N'" + dtoKhachHang.NganHang + "',";
     strQuery += "MASOTHUE = N'" + dtoKhachHang.MaSoThue + "',";
     strQuery += "DUNO = " + dtoKhachHang.DuNo + ",";
     strQuery += "DIACHI = N'" + dtoKhachHang.DiaChi + "',";
     strQuery += "DIENTHOAI = N'" + dtoKhachHang.SDT + "',";
     strQuery += "EMAIL = N'" + dtoKhachHang.Email + "',";
     strQuery += "GHICHU = N'" + dtoKhachHang.GhiChu + "' ";
     strQuery += "Where MAKHACHHANG = N'" + dtoKhachHang.MaKH + "'";
     return dp.ExecuteNonQuery(strQuery);
 }
        public static bool SuaKhachHang(KhachHangDTO KH_DTO)
        {
            SqlConnection con = DataProvider.ConnectionString();

            string strSQL = "update KhachHang set TenKH = N'"
            + KH_DTO.StrTenKH + "', GiayToTuyThan = "
            + KH_DTO.LGiayToTuyThan + ", GioiTinh = '"
            + bool.Parse(KH_DTO.BGioiTinh.ToString()) + "', DiaChi = N'"
            + KH_DTO.StrDiaChi + "', SoDT = "
            + KH_DTO.StrSoDienThoai + ", MaLK = "
            + KH_DTO.IMaLK + ", MaPhieuThue = "
            + KH_DTO.IMaPhieuThue + " where MaKH = "
            + KH_DTO.IMaKH;

            return DataProvider.ExecuteNonQuery(strSQL, con);
        }
        public static bool ThemKhachHang(KhachHangDTO KH_DTO)
        {
            SqlConnection con = DataProvider.ConnectionString();

            string strSQL = "insert into KhachHang values ("
            + KH_DTO.IMaKH + ",N'"
            + KH_DTO.StrTenKH + "',"
            + KH_DTO.LGiayToTuyThan + ",'"
            + bool.Parse(KH_DTO.BGioiTinh.ToString()) + "',N'"
            + KH_DTO.StrDiaChi + "',"
            + KH_DTO.StrSoDienThoai + ","
            + KH_DTO.IMaLK + ","
            + KH_DTO.IMaPhieuThue + ")";

            return DataProvider.ExecuteNonQuery(strSQL, con);
        }
        public static int Them(KhachHangDTO khDto, LoaiTienTeDTO loaiTTDto, string recentUser, int kihan)
        {
            SqlConnection cnn = KetNoiCSDL.TaoKetNoi();
            SqlCommand cmd = new SqlCommand("sp_MoTKTKCoKiHan", cnn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@HoTen", SqlDbType.NVarChar);
            cmd.Parameters.Add("@CMND", SqlDbType.VarChar);
            cmd.Parameters.Add("@NgayCapCMND", SqlDbType.Date);
            cmd.Parameters.Add("@NoiCapCMND", SqlDbType.NVarChar);
            cmd.Parameters.Add("@DiaChi", SqlDbType.NVarChar);
            cmd.Parameters.Add("@SoDt", SqlDbType.VarChar);

            cmd.Parameters.Add("@ChiNhanhGD", SqlDbType.Int);
            cmd.Parameters.Add("@LoaiTienTe", SqlDbType.Int);
            cmd.Parameters.Add("@kihan", SqlDbType.Int);

            cmd.Parameters["@HoTen"].Value = khDto.HoTen;
            cmd.Parameters["@CMND"].Value = khDto.CMND;
            cmd.Parameters["@NgayCapCMND"].Value = khDto.NgayCapCMND;
            cmd.Parameters["@NoiCapCMND"].Value = khDto.NoiCapCMND;
            cmd.Parameters["@DiaChiC"].Value = khDto.DiaChi;
            cmd.Parameters["@SoDt"].Value = khDto.SoDT;

            cmd.Parameters["@ChiNhanhGD"].Value = NhanVienDAO.LayChiNhanhGD(recentUser);
            cmd.Parameters["@LoaiTienTe"].Value = loaiTTDto.MaLoaiTienTe;
            cmd.Parameters["@kihan"].Value = kihan;

            cnn.Open();
            int rs = 0;
            try
            {
                rs = (int)cmd.ExecuteNonQuery();
                cnn.Close();
                return rs;
            }
            catch (Exception ex)
            {
                if (cnn.State == ConnectionState.Open)
                    cnn.Close();
                throw ex;
            }
        }
 public KhachHangDTO GetKhachHangByID(string strIDKhachHang)
 {
     KhachHangDTO dtoKhachHang = new KhachHangDTO();
     string strQuery = "Select * From KHACHHANG Where TINHTRANG = 1 and MAKHACHHANG = '" + strIDKhachHang +"'";
     DataTable dtKhachHang = dp.ExecuteQuery(strQuery);
     if (dtKhachHang.Rows.Count > 0)
     {
         dtoKhachHang.MaKH = dtKhachHang.Rows[0]["MAKHACHHANG"].ToString();
         dtoKhachHang.TenKH = dtKhachHang.Rows[0]["TENKHACHHANG"].ToString();
         dtoKhachHang.SoTaiKhoan = dtKhachHang.Rows[0]["SOTAIKHOAN"].ToString();
         dtoKhachHang.NganHang = dtKhachHang.Rows[0]["NGANHANG"].ToString();
         dtoKhachHang.MaSoThue = dtKhachHang.Rows[0]["MASOTHUE"].ToString();
         dtoKhachHang.DiaChi = dtKhachHang.Rows[0]["DIACHI"].ToString();
         dtoKhachHang.SDT = dtKhachHang.Rows[0]["DIENTHOAI"].ToString();
         dtoKhachHang.Email = dtKhachHang.Rows[0]["EMAIL"].ToString();
         dtoKhachHang.DuNo = double.Parse(dtKhachHang.Rows[0]["DUNO"].ToString());
     }
     return dtoKhachHang;
 }
示例#14
0
        public static int Them(KhachHangDTO khDto)
        {
            khDto.MaKH = LayMaKH();

            khDto.SoDT = "2323";

            SqlConnection cnn = KetNoiCSDL.TaoKetNoi();
            string query = "insert into Khach_Hang values (@MaKH,@HoTen,@CMND,@NgayCap,@NoiCap,@DiaChi,@SoDT)";
            SqlCommand cmd = new SqlCommand(query, cnn);

            cmd.Parameters.Add("@MaKH", SqlDbType.Int);
            cmd.Parameters.Add("@HoTen", SqlDbType.NVarChar);
            cmd.Parameters.Add("@CMND", SqlDbType.VarChar);
            cmd.Parameters.Add("@NgayCap", SqlDbType.DateTime);
            cmd.Parameters.Add("@NoiCap", SqlDbType.NVarChar);
            cmd.Parameters.Add("@DiaChi", SqlDbType.NVarChar);
            cmd.Parameters.Add("@SoDT", SqlDbType.VarChar);

            cmd.Parameters["@MaKH"].Value = khDto.MaKH;
            cmd.Parameters["@HoTen"].Value = khDto.HoTen;
            cmd.Parameters["@CMND"].Value = khDto.CMND;
            cmd.Parameters["@NgayCap"].Value = khDto.NgayCapCMND;
            cmd.Parameters["@NoiCap"].Value = khDto.NoiCapCMND;
            cmd.Parameters["@DiaChi"].Value = khDto.DiaChi;
            cmd.Parameters["@SoDT"].Value = khDto.SoDT;

            cnn.Open();
            try
            {
                return cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                if (cnn.State == ConnectionState.Open)
                    cnn.Close();
                throw ex;
            }
            finally
            {
                cnn.Dispose();
            }
        }
示例#15
0
        public static void ThemGiaoDich(GiaoDichDTO gdDto, PhieuNapTienDTO napTienDto, KhachHangDTO khachHangDto, string nhanVien, ref double LePhi)
        {
            SqlConnection cnn = KetNoiCSDL.TaoKetNoi();
            SqlCommand cmd = new SqlCommand("sp_Lay_phi_nap", cnn);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@Ma_TK", SqlDbType.Char);
            cmd.Parameters.Add("@So_tien", SqlDbType.Money);
            cmd.Parameters.Add("@MaNV", SqlDbType.VarChar);
            cmd.Parameters.Add("@HoTenNguoiNhan", SqlDbType.NVarChar);
            cmd.Parameters.Add("@HoTenNguoiGui", SqlDbType.NVarChar);
            cmd.Parameters.Add("@DiaChiNguoiGui", SqlDbType.NVarChar);

            cmd.Parameters["@Ma_TK"].Value = gdDto.MaTK;
            cmd.Parameters["@So_tien"].Value = napTienDto.SoTien ;
            cmd.Parameters["@MaNV"].Value = nhanVien;
            cmd.Parameters["@HoTenNguoiNhan"].Value = khachHangDto.HoTen ;
            cmd.Parameters["@HoTenNguoiGui"].Value = napTienDto.HoTenNguoiGui ;
            cmd.Parameters["@DiaChiNguoiGui"].Value = napTienDto.DiaChiNguoiGui ;
            cnn.Open();
            SqlDataReader dr = cmd.ExecuteReader();

            try
            {
                if (dr.Read())
                {
                    LePhi = double.Parse(dr["LePhi"].ToString());
                }
                cnn.Close();
            }
            catch (Exception ex)
            {
                if (cnn.State == ConnectionState.Open)
                    cnn.Close();
                throw ex;
            }
        }
 public static DataSet HienThiDanhSachKhachHang(KhachHangDTO KH_DTO)
 {
     SqlConnection con = DataProvider.ConnectionString();
     string strSQL = "select * from KhachHang";
     return DataProvider.GetDataSet(strSQL, con);
 }
 public static int Them(KhachHangDTO khDto, LoaiTienTeDTO loaiTTDto, string recentUser)
 {
     return MoTKTienGuiThanhToanDAO.Them(khDto, loaiTTDto, recentUser);
 }
示例#18
0
        //0712455
        private void bt_CT_Tim_Click(object sender, EventArgs e)
        {
            dtgv_CT_DanhSach.Enabled = true;
            string kt = kiemTraHopLeCTien();
            if (kt != "")
            {
                MessageBox.Show(kt);
                return;
            }

            try
            {
                List<TaiKhoanDTO> lstTaiKhoan = new List<TaiKhoanDTO>();
                if (tb_CT_MaTK.TextLength != 0)
                {
                    TaiKhoanDTO taiKhoanDto = new TaiKhoanDTO();
                    taiKhoanDto = TaiKhoanBUS.TimTaiKhoan(tb_CT_MaTK.Text.Trim());
                    lstTaiKhoan.Add(taiKhoanDto);
                }
                else
                {
                    KhachHangDTO khDto = new KhachHangDTO();
                    if (tb_CT_HoTen.TextLength != 0)
                    {
                        khDto.HoTen = tb_CT_HoTen.Text.Trim();
                    }
                    if (tb_CT_CMND.TextLength != 0)
                    {
                        khDto.CMND = tb_CT_CMND.Text.Trim();
                    }
                    List<KhachHangDTO> lstKH = KhachHangBUS.TimKhachHang(khDto);
                    lstTaiKhoan = TaiKhoanBUS.TimDSTaiKhoan(lstKH);
                }

                dtgv_CT_DanhSach.DataSource = lstTaiKhoan;

                dtgv_CT_DanhSach.Columns["MaTK"].Visible = true;
                dtgv_CT_DanhSach.Columns["MaLoaiTK"].Visible = false;
                dtgv_CT_DanhSach.Columns["MaKH"].Visible = false;
                dtgv_CT_DanhSach.Columns["NgayBatDau"].Visible = true;
                dtgv_CT_DanhSach.Columns["NgayKetThuc"].Visible = true;
                dtgv_CT_DanhSach.Columns["SoDuCo"].Visible = false;
                dtgv_CT_DanhSach.Columns["SoDuNo"].Visible = false;
                dtgv_CT_DanhSach.Columns["SoDu"].Visible = true;
                dtgv_CT_DanhSach.Columns["TinhTrang"].Visible = true;
                dtgv_CT_DanhSach.Columns["LoaiTienTe"].Visible = true;
                dtgv_CT_DanhSach.Columns["MaChiNhanh"].Visible = false;
                dtgv_CT_DanhSach.AutoResizeColumns();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#19
0
        private void button_Tim_rut_Click(object sender, EventArgs e)
        {
            string ChuoiLoi = KiemTraDuLieuNhapPanelRutTien();
            if (ChuoiLoi != "")
            {
                MessageBox.Show(ChuoiLoi);
                return;
            }

            try
            {
                List<TaiKhoanDTO> lstTaiKhoan = new List<TaiKhoanDTO>();
                KhachHangDTO khDto = new KhachHangDTO();
                if (tb_HoTen_rut.TextLength > 0)
                {
                    khDto.HoTen = tb_HoTen_rut.Text.Trim();
                }
                if (tb_CMND_rut.TextLength > 0)
                 {
                    khDto.CMND = tb_CMND_rut.Text.Trim();
                 }
                 List<KhachHangDTO> lstKH = KhachHangBUS.TimKhachHang(khDto);
                 lstTaiKhoan = TaiKhoanBUS.TimDSTaiKhoan(lstKH);
                 data_bang_rut.DataSource = lstTaiKhoan;
                 data_bang_rut.Columns["MaTK"].Visible = true;
                 data_bang_rut.Columns["MaLoaiTK"].Visible = false;
                 data_bang_rut.Columns["MaKH"].Visible = false;
                 data_bang_rut.Columns["NgayBatDau"].Visible = true;
                 data_bang_rut.Columns["NgayKetThuc"].Visible = true;
                 data_bang_rut.Columns["SoDuCo"].Visible = false;
                 data_bang_rut.Columns["SoDuNo"].Visible = false;
                 data_bang_rut.Columns["SoDu"].Visible = true;
                 data_bang_rut.Columns["TinhTrang"].Visible = true;
                 data_bang_rut.Columns["LoaiTienTe"].Visible = true;
                 data_bang_rut.Columns["MaChiNhanh"].Visible = false;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#20
0
        //0712455
        private void bt_TKKH_Tim_Click(object sender, EventArgs e)
        {
            dtgv_TKKH_DanhSach.Enabled = true;
            string kt = kiemTraHopLeTimKiemKhachHang();
            if (kt != "")
            {
                MessageBox.Show(kt);
                return;
            }

            try
            {
                List<KhachHangDTO> lstKhachHang = new List<KhachHangDTO>();
                if (tb_TKKH_MaKH.TextLength > 0)
                {
                    KhachHangDTO khDto = new KhachHangDTO();
                    int maKH = Int32.Parse(tb_TKKH_MaKH.Text.Trim());
                    khDto = KhachHangBUS.LayKhachHang(maKH);
                    lstKhachHang.Add(khDto);
                }
                else
                {
                    KhachHangDTO khDto = new KhachHangDTO();
                    if (tb_TKTK_HoTen.TextLength > 0)
                    {
                        khDto.HoTen = tb_TKKH_HoTen.Text.Trim();
                    }
                    if (tb_TKTK_CMND.TextLength > 0)
                    {
                        khDto.CMND = tb_TKKH_CMND.Text.Trim();
                    }
                    lstKhachHang = KhachHangBUS.TimKhachHang(khDto);
                }

                dtgv_TKKH_DanhSach.DataSource = lstKhachHang;

                dtgv_TKKH_DanhSach.Columns["MaKH"].Visible = true;
                dtgv_TKKH_DanhSach.Columns["HoTen"].Visible = true;
                dtgv_TKKH_DanhSach.Columns["CMND"].Visible = true;
                dtgv_TKKH_DanhSach.Columns["DiaChi"].Visible = true;
                dtgv_TKKH_DanhSach.Columns["NgayCapCMND"].Visible = false;
                dtgv_TKKH_DanhSach.Columns["NoiCapCMND"].Visible = false;
                dtgv_TKKH_DanhSach.Columns["SoDT"].Visible = false;
                dtgv_TKKH_DanhSach.AutoResizeColumns();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#21
0
 // 0712455 begin
 public static int Them(KhachHangDTO KhachHangDto)
 {
     return KhachHangDAO.Them(KhachHangDto);
 }
示例#22
0
        //0712467
        private void bt_PT_PhongToa_Click(object sender, EventArgs e)
        {
            if (dtgv_PT_DanhSach.SelectedRows == null)
            {
                MessageBox.Show("Bạn phải chọn tài khoản cần phong tỏa");
                return;
            }
            else
            {
                tkDuocChon.MaTK = dtgv_PT_DanhSach.SelectedRows[0].Cells[0].Value.ToString();
                tkDuocChon.MaLoaiTK = Int32.Parse(dtgv_PT_DanhSach.SelectedRows[0].Cells[1].Value.ToString());
                tb_PTSub_MaTK.Text = tkDuocChon.MaTK;

                LoaiTaiKhoanDTO ltkDto = new LoaiTaiKhoanDTO();
                ltkDto.MaLoaiTK = tkDuocChon.MaLoaiTK;
                //tb_PTSub_LoaiTK.Text = LoaiTaiKhoanBUS.TimTenLoaiTaiKhoan(ltkDto).TenLoaiTK;

                KhachHangDTO khDto = new KhachHangDTO();
                khDto.MaKH = Int32.Parse(dtgv_PT_DanhSach.SelectedRows[0].Cells[2].Value.ToString());
                khDuocChon = KhachHangBUS.LayKhachHang(khDto.MaKH );

                tb_PTSub_MaKH.Text = khDuocChon.MaKH.ToString();
                tb_PTSub_HoTen.Text = khDuocChon.HoTen;
                tb_PTSub_CMND.Text = khDuocChon.CMND;

                pnl_PhongToaTK_sub.BringToFront();
            }
        }
示例#23
0
        //0712467
        private void bt_DTK_Tim_Click(object sender, EventArgs e)
        {
            if (KiemTraHopLeDuLieuNhapPanelDongTaiKhoan() == true)
            {
                if (tb_DTK_MaTK.Text != "")
                {
                    TaiKhoanDTO tkDto = TaiKhoanBUS.TimTaiKhoan(tb_DTK_MaTK.Text.Trim());
                    List<TaiKhoanDTO> lst = new List<TaiKhoanDTO>();
                    lst.Add(tkDto);
                    dtgv_DTK_DanhSach.DataSource = tkDto;
                }
                else
                {
                    TaiKhoanBUS tkBus = new TaiKhoanBUS();
                    KhachHangDTO khDto = new KhachHangDTO();

                    if (tb_DTK_CMND.Text != "")
                    {
                        khDto.CMND = tb_DTK_CMND.Text;
                    }
                    if (tb_DTK_HoTen.Text != "")
                    {
                        khDto.HoTen = tb_DTK_HoTen.Text;
                    }

                    List<KhachHangDTO> lstKH = KhachHangBUS.TimKhachHang(khDto);
                    dtgv_DTK_DanhSach.DataSource = TaiKhoanBUS.TimDSTaiKhoan(lstKH);
                }
                //hien thong tin len datagridview
                dtgv_DTK_DanhSach.Columns["MaTK"].Visible = true;
                dtgv_DTK_DanhSach.Columns["MaLoaiTK"].Visible = false;
                dtgv_DTK_DanhSach.Columns["MaKH"].Visible = false;
                dtgv_DTK_DanhSach.Columns["NgayBatDau"].Visible = true;
                dtgv_DTK_DanhSach.Columns["NgayKetThuc"].Visible = true;
                dtgv_DTK_DanhSach.Columns["SoDuCo"].Visible = false;
                dtgv_DTK_DanhSach.Columns["SoDuNo"].Visible = false;
                dtgv_DTK_DanhSach.Columns["SoDu"].Visible = true;
                dtgv_DTK_DanhSach.Columns["TinhTrang"].Visible = true;
               dtgv_DTK_DanhSach.Columns["LoaiTienTe"].Visible = true;
                dtgv_DTK_DanhSach.Columns["LoaiTienTe"].Visible = false;
                dtgv_DTK_DanhSach.Columns["MaChiNhanh"].Visible = false;
            }
        }
示例#24
0
 private double NapTienVoTaiKhoan()
 {
     double Lephi = 0.0;
         PhieuNapTienDTO napTienDto = new PhieuNapTienDTO();
         GiaoDichDTO gdDto = new GiaoDichDTO();
         KhachHangDTO khachHangDto = new KhachHangDTO();
         gdDto.MaTK = tb_MaTK_nap.Text.Trim();
         khachHangDto.HoTen = tb_hoTenChuKhoan_nap.Text;
         napTienDto.HoTenNguoiGui = tb_HoTenNgGui_nap.Text;
         napTienDto.DiaChiNguoiGui = tb_DiaChiNggui_nap.Text;
         napTienDto.SoTien = Convert.ToDouble(tb_soTien_nap.Text.Trim());
         try
         {
             NapTienBUS.ThemGiaoDich(gdDto, napTienDto, khachHangDto, recentUser,ref Lephi);
             MessageBox.Show("Đã nạp tiền thành công ");
             return Lephi;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
             return Lephi ;
         }
 }
示例#25
0
        //0712455
        private void MoTKDongSoHuu()
        {
            string chuoi_loi = KiemTraHopLeDuLieuNhapPanelMoTaiKhoanDSH();
            if (chuoi_loi == "")
            {
                KhachHangDTO ChuSoHuuDto = new KhachHangDTO();
                KhachHangDTO DongSoHuuDto = new KhachHangDTO();

                ChuSoHuuDto.HoTen = tb_DSH_CSH_HoTen.Text.Trim();
                ChuSoHuuDto.CMND = tb_DSH_CSH_CMND.Text.Trim();
                ChuSoHuuDto.NgayCapCMND = Convert.ToDateTime(tb_DSH_CSH_NgayCap.Text);
                ChuSoHuuDto.NoiCapCMND = tb_DSH_CSH_NoiCap.Text.Trim();
                ChuSoHuuDto.DiaChi = tb_DSH_CSH_DiaChi.Text.Trim();
                ChuSoHuuDto.SoDT = tb_DSH_CSH_DienThoai.Text.Trim();

                DongSoHuuDto.HoTen = tb_DSH_DSH_HoTen.Text.Trim();
                DongSoHuuDto.CMND = tb_DSH_DSH_CMND.Text.Trim();
                DongSoHuuDto.NgayCapCMND = Convert.ToDateTime(tb_DSH_DSH_NgayCap.Text);
                DongSoHuuDto.NoiCapCMND = tb_DSH_DSH_NoiCap.Text.Trim();
                DongSoHuuDto.DiaChi = tb_DSH_DSH_DiaChi.Text.Trim();
                DongSoHuuDto.SoDT = tb_DSH_DSH_DienThoai.Text.Trim();

                LoaiTienTeDTO loaiTTDto = new LoaiTienTeDTO();
                loaiTTDto = (LoaiTienTeDTO)cb_MTKTGTT_LoaiTienTe.SelectedItem;

                try
                {
                    MoTKDongSoHuuBUS.Them(ChuSoHuuDto, DongSoHuuDto, loaiTTDto);
                    MessageBox.Show("Đã mở tài khoản thành công");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show(chuoi_loi);
            }
        }
示例#26
0
 public static void ThemGiaoDich(GiaoDichDTO gdDto, PhieuNapTienDTO napTienDto, KhachHangDTO khachHangDto, string nhanVien,ref double LePhi)
 {
     NapTienDAO.ThemGiaoDich(gdDto, napTienDto, khachHangDto, nhanVien,ref LePhi);
 }
 private void FrmCTCongNoThu_Load(object sender, EventArgs e)
 {
     string strIDKhachHang = lbKhachHang.Tag.ToString();
     KhachHangDTO dtoKhachHang = new KhachHangDTO();
     dtoKhachHang = bllKhachHang.GetKhachHangByID(strIDKhachHang);
     DateTime dtBatDau = DateTime.Parse(lbTuNgay.Text);
     DateTime dtKetThuc = DateTime.Parse(lbDenNgay.Text);
     DataTable dtPhieuThu = new DataTable();
     dtPhieuThu = bllPhieuThu.TimKiemChiTiet(strIDKhachHang, dtBatDau, dtKetThuc);
     DataTable dtXuatKho = new DataTable();
     dtXuatKho = bllXuatKho.TimKiemChiTiet(dtBatDau, dtKetThuc, strIDKhachHang);
     int intRowCount = dtXuatKho.Rows.Count + dtPhieuThu.Rows.Count + 3;
     int intRun = 0;
     for (int i = 0; i < intRowCount; i++)
     {
         dgvChiTiet.Rows.Add();
     }
     // Lấy dư nợ khách hàng
     dgvChiTiet.Rows[0].Cells[2].Value = "Dư nợ của khách hàng";
     // Nếu dư nợ - thì cần phải thanh toán
     // Nếu dư nợ + thì đã thanh toán
     if (dtoKhachHang.DuNo < 0)
         dgvChiTiet.Rows[0].Cells[3].Value = Math.Abs(dtoKhachHang.DuNo);
     else if (dtoKhachHang.DuNo > 0)
         dgvChiTiet.Rows[0].Cells[4].Value = dtoKhachHang.DuNo;
     // Lấy chi tiết phiếu xuất
     double dbTongTienXuat = 0;
     for (int i = 0; i < dtXuatKho.Rows.Count; i++)
     {
         intRun++;
         dgvChiTiet.Rows[intRun].Cells[0].Value = dtXuatKho.Rows[i]["NGAYXUAT"].ToString();
         dgvChiTiet.Rows[intRun].Cells[1].Value = dtXuatKho.Rows[i]["MAXUATKHO"].ToString();
         dgvChiTiet.Rows[intRun].Cells[2].Value = "Tiền cần thanh toán";
         double dbTienXuat = double.Parse(dtXuatKho.Rows[i]["THANHTIEN"].ToString());
         dbTongTienXuat += dbTienXuat;
         dgvChiTiet.Rows[intRun].Cells[3].Value = dtXuatKho.Rows[i]["THANHTIEN"].ToString();
     }
     intRun++;
     dgvChiTiet.Rows[intRun].Cells[2].Value = "Tổng tiền cần thu: ";
     dgvChiTiet.Rows[intRun].Cells[3].Value = dbTongTienXuat;
     // Lấy chi tiết phiếu thu
     double dbTongTienThu = 0;
     for (int i = 0; i < dtPhieuThu.Rows.Count; i++)
     {
         intRun++;
         dgvChiTiet.Rows[intRun].Cells[0].Value = dtPhieuThu.Rows[i]["NGAYLAP"].ToString();
         dgvChiTiet.Rows[intRun].Cells[1].Value = dtPhieuThu.Rows[i]["MAPHIEUTHU"].ToString();
         dgvChiTiet.Rows[intRun].Cells[2].Value = "Đã thu tiền";
         double dbThuTien = double.Parse(dtPhieuThu.Rows[i]["SOTIEN"].ToString());
         dbTongTienThu += dbThuTien;
         dgvChiTiet.Rows[intRun].Cells[4].Value = dtPhieuThu.Rows[i]["SOTIEN"].ToString();
     }
     intRun++;
     dgvChiTiet.Rows[intRun].Cells[2].Value = "Tổng tiền đã thu: ";
     dgvChiTiet.Rows[intRun].Cells[4].Value = dbTongTienThu;
     intRun++;
     dgvChiTiet.Rows[intRun].Cells[2].Value = "Còn lại: ";
     double dbDuNo = dbTongTienThu - dbTongTienXuat + dtoKhachHang.DuNo;
     if (dbDuNo < 0)
         dgvChiTiet.Rows[intRun].Cells[3].Value = Math.Abs(dbDuNo);
     else if (dbDuNo > 0)
         dgvChiTiet.Rows[intRun].Cells[4].Value = dbDuNo;
 }
示例#28
0
        //0712467
        private void bt_PT_Tim_Click(object sender, EventArgs e)
        {
            if (KiemTraHopLeDuLieuNhapPanelPhongToa() == true)
            {
                if (tb_PT_MaTK.Text != "")
                {
                    TaiKhoanDTO tkDto = TaiKhoanBUS.TimTaiKhoan(tb_PT_MaTK.Text.Trim());
                    List<TaiKhoanDTO> lst = new List<TaiKhoanDTO>();
                    lst.Add(tkDto);
                    dtgv_PT_DanhSach.DataSource = lst;

                }
                else
                {
                    TaiKhoanBUS tkBus = new TaiKhoanBUS();
                    KhachHangDTO khDto = new KhachHangDTO();

                    if (tb_PT_CMND.Text != "")
                    {
                        khDto.CMND = tb_PT_CMND.Text;
                    }
                    if (tb_PT_HoTen.Text != "")
                    {
                        khDto.HoTen = tb_PT_HoTen.Text;
                    }

                    List<KhachHangDTO> lstKH = KhachHangBUS.TimKhachHang(khDto);
                    dtgv_PT_DanhSach.DataSource = TaiKhoanBUS.TimDSTaiKhoan(lstKH);
                }
                //hien thong tin len datagridview
                if (dtgv_PT_DanhSach.DataSource != null)
                {
                    dtgv_PT_DanhSach.Columns["MaTK"].Visible = true;
                    dtgv_PT_DanhSach.Columns["MaLoaiTK"].Visible = false;
                    dtgv_PT_DanhSach.Columns["MaKH"].Visible = false;
                    dtgv_PT_DanhSach.Columns["NgayBatDau"].Visible = true;
                    dtgv_PT_DanhSach.Columns["NgayKetThuc"].Visible = true;
                    dtgv_PT_DanhSach.Columns["SoDuCo"].Visible = false;
                    dtgv_PT_DanhSach.Columns["SoDuNo"].Visible = false;
                    dtgv_PT_DanhSach.Columns["SoDu"].Visible = true;
                    dtgv_PT_DanhSach.Columns["TinhTrang"].Visible = true;
                    dtgv_PT_DanhSach.Columns["LoaiTienTe"].Visible = false ;
                    dtgv_PT_DanhSach.Columns["MaChiNhanh"].Visible = false;
                }
                else
                {
                    MessageBox.Show("Không tìm thấy tài khoản thỏa thông tin tìm kiếm");
                }
            }
        }
示例#29
0
 public static List<KhachHangDTO> TimKhachHang(KhachHangDTO khDto)
 {
     return KhachHangDAO.TimKhachHang(khDto);
 }
示例#30
0
        // 0712455
        public static List<KhachHangDTO> TimKhachHang(KhachHangDTO khDto)
        {
            SqlConnection cnn = KetNoiCSDL.TaoKetNoi();

            string query = "select * from Khach_Hang where ";

            if (khDto.HoTen != null)
            {
                query = query + "HoTen = @HoTen and ";
            }
            if (khDto.CMND != null)
            {
                query = query + "CMND = @CMNDkh and ";
            }
            query = query + "(1 = 1)";

            SqlCommand cmd = new SqlCommand(query, cnn);

            if (khDto.HoTen != null)
            {
                cmd.Parameters.Add("@HoTen", SqlDbType.NVarChar);
                cmd.Parameters["@HoTen"].Value = khDto.HoTen;
            }
            if (khDto.CMND != null)
            {
                cmd.Parameters.Add("@CMNDkh", SqlDbType.VarChar);
                cmd.Parameters["@CMNDkh"].Value = khDto.CMND;
            }

            cnn.Open();
            List<KhachHangDTO> lstKH = new List<KhachHangDTO>();
            try
            {
                SqlDataReader dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    KhachHangDTO khachHangDto = new KhachHangDTO();

                    khachHangDto.MaKH = (int)dr["MaKH"];
                    khachHangDto.HoTen = dr["HoTen"].ToString();
                    khachHangDto.CMND = dr["CMND"].ToString();
                    khachHangDto.DiaChi = dr["DiaChi"].ToString();

                    lstKH.Add(khachHangDto);
                }
                cnn.Close();
                return lstKH;
            }
            catch (Exception ex)
            {
                if (cnn.State == ConnectionState.Open)
                    cnn.Close();
                throw ex;
            }
        }
 public static int Them(KhachHangDTO khDto, LoaiTienTeDTO loaiTTDto, string recentUser, int kihan)
 {
     return MoTKTKCoKiHanDAO.Them(khDto, loaiTTDto, recentUser, kihan);
 }
示例#32
0
        //0712455
        private void MoTaiKhoanTKKhongKiHan()
        {
            string chuoi_loi = KiemTraHopLeDuLieuNhapPanelMoTKTKKhongKiHan();
            if (chuoi_loi == "")
            {
                KhachHangDTO khDto = new KhachHangDTO();

                khDto.HoTen = tb_MoTKTKKKH_HoTen.Text.Trim();
                khDto.CMND = tb_MoTKTKKKH_CMND.Text.Trim();
                khDto.NgayCapCMND = Convert.ToDateTime(tb_MoTKTKKKH_NgayCap.Text.Trim());
                khDto.NoiCapCMND = tb_MoTKTKKKH_NoiCap.Text.Trim();
                khDto.DiaChi = tb_MoTKTKKKH_DiaChi.Text.Trim();
                khDto.SoDT = tb_MoTKTKKKH_DienThoai.Text.Trim();

                LoaiTienTeDTO loaiTTDto = new LoaiTienTeDTO();
                loaiTTDto = (LoaiTienTeDTO)cb_MTKTKKKH_LoaiTienTe.SelectedItem;

                try
                {
                    MoTKTKKhongKiHanBUS.Them(khDto, loaiTTDto, recentUser);
                    MessageBox.Show("Đã mở tài khoản thành công");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show(chuoi_loi);
            }
        }