private void btnSuaTK_Click(object sender, EventArgs e) { try { if (gridTabKH.RowCount > 0 && gridTabKH.SelectedRows.Count > 0) { SuaTTKH suaKH = new SuaTTKH(); suaKH.dataGridView = gridTabKH; QLyKHDTO khachHang = new QLyKHDTO(); QLyKHBUS khachHangBUS = new QLyKHBUS(); string jsonData = khachHangBUS.layMotKhachHang(gridTabKH.SelectedRows[0].Cells[0].Value.ToString()); khachHang = JsonConvert.DeserializeObject <QLyKHDTO>(jsonData); suaKH.khachHang = khachHang; suaKH.ShowDialog(); } else { MessageBox.Show("Thao tác lỗi. Bạn chưa chọn khách hàng nào", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("Lỗi: " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button1_Click(object sender, EventArgs e) { try { // Xóa dữ liệu hiển thị cũ gridTabKH.Rows.Clear(); // Lấy DS khách hàng List <QLyKHDTO> list = new List <QLyKHDTO>(); QLyKHDTO listCMND = new QLyKHDTO(); QLyKHDTO listTKLK = new QLyKHDTO(); QLyKHBUS khachHangBUS = new QLyKHBUS(); string jsonData = khachHangBUS.layDSKhachHang(); string jsonCMND = khachHangBUS.GetKH(txtTimKiem.Text); string jsonTKLK = khachHangBUS.layMotKhachHang(txtTimKiem.Text); list = JsonConvert.DeserializeObject <List <QLyKHDTO> >(jsonData); listCMND = JsonConvert.DeserializeObject <QLyKHDTO>(jsonCMND); listTKLK = JsonConvert.DeserializeObject <QLyKHDTO>(jsonTKLK); // Hiển thị danh sách khách hàng lên grid view if (txtTimKiem.Text == "") { foreach (QLyKHDTO temp in list) { gridTabKH.Rows.Add(temp.STKLK, temp.hoTenKH, temp.ngaySinhKH, temp.soCMNNKH, temp.NgayCap, temp.NoiCap, temp.gioiTinhKH, temp.diaChiKH, temp.ngayMoTKKH, temp.SDTKH, temp.emailKH, temp.HanMucVay, temp.MaRo, temp.SoTienMat, temp.SoDuNo); } } else if (listCMND != null) { gridTabKH.Rows.Add(listCMND.STKLK, listCMND.hoTenKH, listCMND.ngaySinhKH, listCMND.soCMNNKH, listCMND.NgayCap, listCMND.NoiCap, listCMND.gioiTinhKH, listCMND.diaChiKH, listCMND.ngayMoTKKH, listCMND.SDTKH, listCMND.emailKH, listCMND.HanMucVay, listCMND.MaRo, listCMND.SoTienMat, listCMND.SoDuNo); } else if (listTKLK != null) { gridTabKH.Rows.Add(listTKLK.STKLK, listTKLK.hoTenKH, listTKLK.ngaySinhKH, listTKLK.soCMNNKH, listTKLK.NgayCap, listTKLK.NoiCap, listTKLK.gioiTinhKH, listTKLK.diaChiKH, listTKLK.ngayMoTKKH, listTKLK.SDTKH, listTKLK.emailKH, listTKLK.HanMucVay, listTKLK.MaRo, listTKLK.SoTienMat, listTKLK.SoDuNo); } else { MessageBox.Show("Không tìm thấy KH nào trong hệ thống"); } if (gridTabKH.RowCount > 1) { gridTabKH.Rows[0].Selected = true; } } catch (Exception ex) { MessageBox.Show("Lỗi: " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void txtSoTKLK_Leave(object sender, EventArgs e) { try { QLLuukiBUS qLTienMatBUS = new QLLuukiBUS(); //lấy thông tin từ số TKLK string jsonData = qLTienMatBUS.timKiem(txtSoTKLK.Text); List <QLLuuKiDTO> list = JsonConvert.DeserializeObject <List <QLLuuKiDTO> >(jsonData); lblError.ForeColor = Color.Red; if (txtSoTKLK.Text == "") { lblError.Text = "Dòng màu đỏ là thông tin bắt buộc nhập"; } else if (list == null) { } else { QLyKHBUS qLyKHBUS = new QLyKHBUS(); QLyKHDTO qLyKHDTO = JsonConvert.DeserializeObject <QLyKHDTO>(qLyKHBUS.layMotKhachHang(txtSoTKLK.Text)); if (qLyKHDTO != null) { txthoTen.Text = qLyKHDTO.hoTenKH; txtsoCMND.Text = qLyKHDTO.soCMNNKH; txtSDT.Text = qLyKHDTO.SDTKH; } else { lblError.Text = "Số TKLK không có trong hệ thống"; txthoTen.Text = ""; txtsoCMND.Text = ""; txtSDT.Text = ""; } gridView.Rows.Clear(); foreach (QLLuuKiDTO temp in list) { txthoTen.Text = temp.HoTen; txtSDT.Text = temp.SoDT; txtsoCMND.Text = temp.SoCMND; lblError.Text = ""; long tsdb = temp.SoLuong * temp.GiaVay * temp.TiLeVay / 100; gridView.Rows.Add(temp.MaCK, temp.TenCK, temp.SoLuong, temp.GiaVay, temp.TiLeVay, tsdb); } } } catch (Exception ex) { MessageBox.Show("Lỗi: " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } //try //{ // QLLuukiBUS qLLuuki = new QLLuukiBUS(); // string jsonData = qLLuuki.timKiem(txtSoTKLK.Text); // List<QLLuuKiDTO> list = JsonConvert.DeserializeObject<List<QLLuuKiDTO>>(jsonData); // switch (qLLuuki.KtraNhapSoTKLK(txtSoTKLK.Text)) // { // case 1: // { // lblError.Text = "Bạn chưa nhập số TKLK"; // break; // } // case 2: // { // lblError.Text = "Số tài khoản lưu kí không tồn tại trong hệ thống"; // break; // } // case 0: // { // gridView.Rows.Clear(); // foreach (QLLuuKiDTO temp in list) // { // txthoTen.Text = temp.HoTen; // txtSDT.Text = temp.SoDT; // txtsoCMND.Text = temp.SoCMND; // lblError.Text = ""; // long tsdb = temp.SoLuong * temp.GiaVay * temp.TiLeVay; // gridView.Rows.Add(temp.MaCK, temp.TenCK, temp.SoLuong, temp.GiaVay, temp.TiLeVay, tsdb); // } // break; // } // } //} //catch (Exception ex) //{ // MessageBox.Show("Lỗi: " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); //} }