// Event change of one combobox private void comb_stk_SelectedIndexChanged(object sender, EventArgs e) { int _maSoTietKiem = int.Parse(comb_stk.EditValue.ToString()); SoTietKiem_DTO _soTietKiem = SoTietKiemBus.GetById(_maSoTietKiem); Init(_soTietKiem); }
/// <summary> /// Tính lãi xuất đến ngày hiện tại /// </summary> /// <param name="soTietKiem_DTO"></param> /// <returns></returns> public static double TinhLaiXuat(SoTietKiem_DTO soTietKiem_DTO) { using (QLSoTietKiemDBContext ql = new QLSoTietKiemDBContext()) { decimal _laiKhongThoiHan = ql.KyHanVay.FirstOrDefault(x => x.SoThang == 0 && x.TinhTrang).LaiSuat; return(Utils.TinhLaiXuat(soTietKiem_DTO.NgayHieuLuc, soTietKiem_DTO.NgayDenHan, soTietKiem_DTO.KyHanGui, soTietKiem_DTO.SoTienGui, soTietKiem_DTO.LaiXuat, _laiKhongThoiHan)); } }
// Row click of grid view private void gridView_SoTietKiem_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e) { if (gridView_SoTietKiem.GetFocusedRowCellValue("MaSTK") != null) { var _maSoTietKiem = int.Parse(gridView_SoTietKiem.GetFocusedRowCellValue("MaSTK").ToString()); SoTietKiem_DTO _soTietKiem = SoTietKiemBus.GetById(_maSoTietKiem); Init(_soTietKiem); } }
// event row click private void gridView_SoTietKiem_Click(object sender, EventArgs e) { if (gridView_SoTietKiem.GetFocusedRowCellValue("MaSTK") != null) { var _maSoTietKiem = int.Parse(gridView_SoTietKiem.GetFocusedRowCellValue("MaSTK").ToString()); SoTietKiem_DTO _soTietKiem = SoTietKiemBus.GetById(_maSoTietKiem); textBox_masotk.Text = _soTietKiem.MaSTK.ToString(); dateEditCreate.DateTime = _soTietKiem.NgayHieuLuc; dateEditDaoHan.DateTime = _soTietKiem.NgayDenHan; txtTienGui.Text = _soTietKiem.SoTienGui.ToString(); grid_khachhang.EditValue = _soTietKiem.MaKh; var kyhan = KyHanVayBus.GetById(_soTietKiem.MaKyHan); gridLookUpEditKyhan.EditValue = kyhan.MaKyHan; textBox_LaiXuat.Text = kyhan.LaiSuat.ToString(); var tienTe = LoaiTienBus.GetById(_soTietKiem.TienTe); gridLookUpEditLoaiTien.EditValue = tienTe.MaLoaiTien; } }
/// <summary> /// Khởi tạo tất cả các label and dataEdit /// </summary> /// <param name="soTietKiem"></param> private void Init(SoTietKiem_DTO soTietKiem) { label_tongtien.Visible = true; label_infotongtien.Visible = true; if (soTietKiem != null && soTietKiem.MaSTK > 0) { double _lai = SoTietKiemBus.TinhLaiXuat(soTietKiem); label_tenkh.Text = soTietKiem.KhachHang; label_cmnd.Text = soTietKiem.CMND; label_diachi.Text = soTietKiem.DiaChi; label_loaitien.Text = soTietKiem.TienTe.ToString(); label_kyhan.Text = soTietKiem.KyHanGui.ToString(); label_laixuat.Text = soTietKiem.LaiXuat.ToString(); label_sotien.Text = soTietKiem.SoTienGui.ToString(); label_tongtien.Text = (_lai + soTietKiem.SoTienGui).ToString(); dateEditCreate.DateTime = soTietKiem.NgayHieuLuc; dateEditDaoHan.DateTime = soTietKiem.NgayDenHan; label_sotienlai.Text = _lai.ToString(); label_std.Text = soTietKiem.SDT; textBox_tinhtrang.Text = soTietKiem.TrangThai; label_ngaysinh.Text = soTietKiem.NgaySinh.ToString("dd/MM/yyyy"); comb_stk.EditValue = soTietKiem.MaSTK; } else { label_tenkh.Text = null; label_sotienlai.Text = null; label_cmnd.Text = null; label_std.Text = null; label_diachi.Text = null; label_kyhan.Text = null; label_loaitien.Text = null; label_laixuat.Text = null; label_sotien.Text = null; label_tongtien.Text = null; label_sotienlai.Text = null; label_tongtien.Visible = false; label_infotongtien.Visible = false; textBox_tinhtrang.Text = null; comb_stk.EditValue = null; label_ngaysinh.Text = null; } }
// focus RowChange private void gridView_SoTietKiem_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { _soTietKiemDTO = (SoTietKiem_DTO)gridView_SoTietKiem.GetRow(e.FocusedRowHandle); }
/// <summary> /// Tình lãi xuất của một sổ bất kỳ /// </summary> /// <param name="soTietKiem_DTO"></param> /// <returns></returns> public static double TinhLaiXuat(SoTietKiem_DTO soTietKiem_DTO) { return(SoTietKiemDao.TinhLaiXuat(soTietKiem_DTO)); }