private void cbThoiHanThuTien_SelectedIndexChanged(object sender, EventArgs e) { int sothang = cbThoiHanTinhLai.SelectedIndex - 2; if (sothang > 0) { decimal so_tien = (sotiencam / 100) * txtLaiSuatThang.Value * sothang; string tien_tam = String.Format("{0:##,##0}", so_tien); so_tien = Convert.ToDecimal(tien_tam) - Convert.ToDecimal(tien_tam) % Convert.ToDecimal(Math.Pow(10, 3)); txtNgayGhiSo.DateTime = ngayghisocamdo.AddMonths(sothang); if (cbLoai.SelectedIndex == 0) { txtSoTien.Value = sotiencam + so_tien; } else { txtSoTien.Value = so_tien; } txtTienLai.Value = so_tien; } else if(sothang == -2) { if (cbLoai.SelectedIndex != 3) { txtNgay.DateTime = DateTime.Now; txtNgayGhiSo.DateTime = DateTime.Now; } var tinh_toan = new TinhToan(); //decimal so_tien = tinh_toan.Tinh_Tien_Lai(sotiencam, txtLaiSuatThang.Value, ngayghisocamdo, txtNgayGhiSo.DateTime); decimal so_tien = tinh_toan.Tinh_Tien_Lai_Theo_Chung_Tu(txtMaChungTuCamDo.Text, txtNgayGhiSo.DateTime); if (cbLoai.SelectedIndex == 0) { txtSoTien.Value = sotiencam + so_tien; } else { txtSoTien.Value = so_tien; } txtTienLai.Value = so_tien; } else if (sothang == -1) { var tinh_toan = new TinhToan(); //decimal so_tien = tinh_toan.Tinh_Tien_Lai(sotiencam, txtLaiSuatThang.Value, ngayghisocamdo, txtNgayGhiSo.DateTime); decimal so_tien = tinh_toan.Tinh_Tien_Lai_Theo_Chung_Tu(txtMaChungTuCamDo.Text, txtNgayGhiSo.DateTime); if (cbLoai.SelectedIndex == 0) { txtSoTien.Value = sotiencam + so_tien; } else { txtSoTien.Value = so_tien; } txtTienLai.Value = so_tien; } else if (sothang == 0) { var tinh_toan = new TinhToan(); //decimal so_tien = tinh_toan.Tinh_Tien_Lai(sotiencam, txtLaiSuatThang.Value, ngayghisocamdo, txtNgay.DateTime); decimal so_tien = tinh_toan.Tinh_Tien_Lai_Theo_Chung_Tu(txtMaChungTuCamDo.Text, txtNgayGhiSo.DateTime); if (cbLoai.SelectedIndex == 0) { txtSoTien.Value = sotiencam + so_tien; } else { txtSoTien.Value = so_tien; } txtTienLai.Value = so_tien; } }
public void Thiet_Lap(string ma_chung_tu_cam_do, string so, string ten_khach_hang, string so_cmnd, decimal so_tien_cam, decimal lai_suat_thang, DateTime ngay_ghi_so_cam_do ,int loai_thu) { machungtucamdo = ma_chung_tu_cam_do; socamdo = so; tenkhachhang = ten_khach_hang; socmnd = so_cmnd; sotiencam = so_tien_cam; ngayghisocamdo = ngay_ghi_so_cam_do; loaithu = loai_thu; txtMaChungTuCamDo.Text = ma_chung_tu_cam_do; txtSo.Text = so; txtTenKhachhang.Text = ten_khach_hang; txtSoCMND.Text = so_cmnd; txtLaiSuatThang.Value = lai_suat_thang; txtSoTienCam.Value = so_tien_cam; txtNgayCamDo.DateTime = ngay_ghi_so_cam_do; txtMaChungTuCamDo.Properties.ReadOnly = true; txtSo.Properties.ReadOnly = true; txtTenKhachhang.Properties.ReadOnly = true; var tinhToan = new TinhToan(); //decimal tien_lai = tinhToan.Tinh_Tien_Lai(so_tien_cam, lai_suat_thang, ngay_ghi_so_cam_do, txtNgayGhiSo.DateTime); decimal tien_lai = tinhToan.Tinh_Tien_Lai_Theo_Chung_Tu(txtMaChungTuCamDo.Text, txtNgayGhiSo.DateTime); txtTienLai.Value = tien_lai; if (loai_thu == 0) // chuộc { txtSoTien.EditValue = so_tien_cam + tien_lai; } else if (loai_thu == 1) // khách trả tiền lời { txtSoTien.EditValue = tien_lai; } else if (loai_thu == 2) // khách trả bớt tiền { txtSoTien.EditValue = 0; } else { txtSoTien.EditValue = 0; lyThoiHanTinhLai.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; lyLaiSuatThang.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; } cbLoai.SelectedIndex = loai_thu; }