private void cmdSubmit_Click(object sender, EventArgs e) { string sqlString; string dbpass; if ((txtConfirm.Text == "") || (txtNewPass.Text == "") || (txtOldPass.Text == "")) { MessageBox.Show("Ban phai nhap day du thong tin!"); return; } if (txtNewPass.Text != txtConfirm.Text) { MessageBox.Show("Thong tin ve mat khau va xac nhan mat khau khong giong nhau \n Ban phai nhap lai"); return; } byte[] d = Encoding.Unicode.GetBytes(txtConfirm.Text); dbpass = System.Convert.ToBase64String(d); if (!checkoldpass(txtOldPass.Text)) { MessageBox.Show("Ban nhap mat khau khong dung"); return; } sqlString = "UPDATE QUANLYUSER SET [password] = '" + dbpass + "' WHERE [UserName] = '" + username + "'"; pwddb.runSQLCmd(sqlString); pwddb.close(); this.Close(); }
private void cmdAccept_Click(object sender, EventArgs e) { foreach (Control ctl in this.Controls) { if (ctl.ToString().Contains("TextBox")) { if (ctl.Text.Length == 0) { MessageBox.Show("Ban phai nhap day du thong tin ve khach hang!"); ctl.Focus(); return; } } } if (Utilities.isDateTime(txtIssDate.Text) == false) { MessageBox.Show("Ban nhap chu dung dinh dang ngay thang!"); return; } if (newuser == true) { Create_New_User(); } else { UpdateUser(); } CusDb.close(); this.Close(); }
private void cmdUpdate_Click(object sender, EventArgs e) { string sqlStr; Int64 vonmoi; Int64 tienmat; if (Utilities.isInt64(txtTienvon.Text) == false) { MessageBox.Show("Tien von ban nhap chua dung"); txtTienvon.Focus(); return; } vonmoi = Int64.Parse(txtTienvon.Text); if (vonmoi != voncu) { sqlStr = "UPDATE [TIEN] SET [SoLuong] = " + txtTienvon.Text + " WHERE [Matien] = 'Tienvon'"; CashDB.runSQLCmd(sqlStr); sqlStr = "UPDATE [DONGTIEN] SET [Sotien] = " + txtTienvon.Text + " WHERE [MaHD] = 'Tienvon'"; CashDB.runSQLCmd(sqlStr); tienmat = Int64.Parse(txtTienmat.Text); tienmat = tienmat + (vonmoi - voncu); sqlStr = "UPDATE [TIEN] SET [SoLuong] = " + tienmat.ToString() + " WHERE [Matien] = 'TongTien'"; CashDB.runSQLCmd(sqlStr); } CashDB.close(); this.Close(); }
public Boolean init(string dbname, string workingdir) { string sqlStr; OleDbDataReader oleReader; contractDb = new db(dbname); edit = false; laisuat = 0; MaHD = ""; HTTra = TraDinhKy; optTraDK.Checked = true; dbfile = dbname; frmNhapTN = new NhapKyTraNo(); frmNhapTN.saved = false; dirWork = workingdir; if (contractDb == null) { MessageBox.Show("Loi ket noi den database"); this.Close(); } sqlStr = "SELECT [MaKH] FROM [KHACHHANG] ORDER BY [MaKH]"; try { oleReader = contractDb.genDataReader(sqlStr); while (oleReader.Read()) { cbxMaKH.Items.Add(oleReader[0].ToString()); } cbxMaKH.Text = cbxMaKH.Items[0].ToString(); sqlStr = "SELECT [LaiSuat], [LoaiLS] FROM [LAISUAT]"; oleReader = contractDb.genDataReader(sqlStr); LSChovay = new ArrayList(); LSHuydong = new ArrayList(); while (oleReader.Read()) { if (oleReader["LoaiLS"].ToString() == "1") { LSChovay.Add(oleReader["LaiSuat"].ToString()); cbxLaisuat.Items.Add(oleReader["LaiSuat"].ToString()); } else { LSHuydong.Add(oleReader["LaiSuat"].ToString()); } } Create_List_CT(); return(true); } catch (Exception ex) { //MessageBox.Show(ex.Message); contractDb.close(); this.Close(); return(false); } }
private void cmdClose_Click(object sender, EventArgs e) { dbUser.close(); this.Close(); }
private void cmdClose_Click(object sender, EventArgs e) { saved = false; CashDB.close(); this.Close(); }
private void cmdHuy_Click_1(object sender, EventArgs e) { hdbhData.close(); this.Close(); }
private void cmdUpadate_Click(object sender, EventArgs e) { string sqlStrL, sqlStrG, sqlStr; int i; string Datra; Boolean Realdata; Int64 tientra = 0; if ((dtGridCFG.Rows.Count == 0) && (dtGridCFL.Rows.Count == 0)) { return; } if (dtGridCFG.Rows[0].Cells["Real"].Value.ToString() == "True") { Realdata = true; } else { Realdata = false; } for (i = 0; i < dtGridCFG.Rows.Count; i++) { if (KytraG[i].ToString() == "False") { continue; } if (dtGridCFG.Rows[i].Cells["Datra"].Value.ToString() == "False") { continue; } Datra = "Yes"; DatraG.RemoveAt(i); DatraG.Insert(i, "True"); tientra = tientra + Int64.Parse(dtGridCFG.Rows[i].Cells["Sotien"].Value.ToString()); sqlStrG = "UPDATE [DONGTIEN] SET [Datra] = " + Datra; sqlStrG = sqlStrG + " WHERE [MaDT] = " + dtGridCFG.Rows[i].Cells["MaDT"].Value.ToString() + ""; CashDB.runSQLCmd(sqlStrG); } for (i = 0; i < dtGridCFL.Rows.Count; i++) { if (KytraL[i].ToString() == "False") { continue; } if (dtGridCFL.Rows[i].Cells["Datra"].Value.ToString() == "False") { continue; } Datra = "Yes"; DatraL.RemoveAt(i); DatraL.Insert(i, "True"); tientra = tientra + Int64.Parse(dtGridCFL.Rows[i].Cells["Sotienlai"].Value.ToString()); tienlai = tienlai + Int64.Parse(dtGridCFL.Rows[i].Cells["Sotienlai"].Value.ToString()); sqlStrL = "UPDATE [TIENLAI] SET [Datra] = " + Datra; sqlStrL = sqlStrL + " WHERE [MaDT] = " + dtGridCFL.Rows[i].Cells["MaDT"].Value.ToString() + ""; CashDB.runSQLCmd(sqlStrL); } if (Realdata) { tienmat = tienmat + tientra; sqlStr = "UPDATE [TIEN] SET [SoLuong] = " + tienmat + " WHERE [Matien] = 'TongTien'"; CashDB.runSQLCmd(sqlStr); } if (traxong()) { sqlStr = "UPDATE [HOPDONG] SET [Hoanthanh] = True WHERE [MaHD] = '" + txtMaHD.Text + "'"; CashDB.runSQLCmd(sqlStr); } CashDB.close(); this.Close(); }
public Boolean init(string dbname, string workingdir) { string sqlStr; OleDbDataReader oleReader; contractDb = new db(dbname); edit = false; laisuat = 0; MaHD = ""; HTTra = TraDinhKy; optTraDK.Checked = true; dbfile = dbname; frmNhapTN = new NhapKyTraNo(); frmNhapTN.saved = false; dirWork = workingdir; if (contractDb == null) { MessageBox.Show("Loi ket noi den database"); this.Close(); } sqlStr = "SELECT [MaKH] FROM [KHACHHANG] ORDER BY [MaKH]"; try { oleReader = contractDb.genDataReader(sqlStr); while (oleReader.Read()) { cbxMaKH.Items.Add(oleReader[0].ToString()); } cbxMaKH.Text = cbxMaKH.Items[0].ToString(); sqlStr = "SELECT [LaiSuat], [LoaiLS] FROM [LAISUAT]"; oleReader = contractDb.genDataReader(sqlStr); LSChovay = new ArrayList(); LSHuydong = new ArrayList(); while (oleReader.Read()) { if (oleReader["LoaiLS"].ToString() == "1") { LSChovay.Add(oleReader["LaiSuat"].ToString()); cbxLaisuat.Items.Add(oleReader["LaiSuat"].ToString()); } else LSHuydong.Add(oleReader["LaiSuat"].ToString()); } Create_List_CT(); return true; } catch (Exception ex) { //MessageBox.Show(ex.Message); contractDb.close(); this.Close(); return false; } }
/* * Init function using to create object db for Quanlykhachhang * And this function is using to import list custommer from database to form */ public void init(string dbFile) { string sqlString; OleDbDataReader oleReader; string LoaiKH; int MaLoaiKH, i; DataGridViewButtonColumn dtGridBt = new DataGridViewButtonColumn(); LoaiKHList = new ArrayList(); QlkhDb = new db(dbFile); dbname = dbFile; sqlString = "SELECT [MaLoaiKH], [TenLoaiKH] FROM [LOAIKH]"; dtGridKH.AllowUserToAddRows = true; try { oleReader = QlkhDb.genDataReader(sqlString); if (oleReader == null) { MessageBox.Show("Loi ket noi den database!"); this.Close(); return; } while (oleReader.Read()) { MaLoaiKH = int.Parse(oleReader.GetValue(0).ToString()); LoaiKH = oleReader.GetString(1); cbxLoaiKH.Items.Add(LoaiKH); LoaiKHList.Add(MaLoaiKH); } cbxLoaiKH.Items.Add("All"); cbxLoaiKH.Text = cbxLoaiKH.Items[0].ToString(); sqlString = "SELECT [MAKH], [TenKH], [TaikhoanNH], [TenNH], [DinhDanh],[SoDT], [Diachi] FROM [KHACHHANG]"; QlkhDb.fillDtGridView(sqlString, dtGridKH); for (i = 0; i < dtGridKH.Columns.Count; i++) { dtGridKH.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } for (i = 0; i < dtGridKH.Rows.Count; i++) { if (rowColor) { dtGridKH.Rows[i].DefaultCellStyle.BackColor = activeC; } else { dtGridKH.Rows[i].DefaultCellStyle.BackColor = NegativeC; } rowColor = !rowColor; } dtGridBt.Text = "..."; dtGridBt.Name = "Capnhat"; dtGridBt.Width = 60; dtGridBt.HeaderText = "Cap nhat"; dtGridBt.UseColumnTextForButtonValue = true; dtGridKH.Columns.Add(dtGridBt); dtGridKH.AllowUserToAddRows = false; } catch (Exception ex) { MessageBox.Show(ex.Message); QlkhDb.close(); this.Close(); } }
private void cmdClose_Click(object sender, EventArgs e) { QlkhDb.close(); this.Close(); }
public void Save_Data(Boolean real, string MaHD, string dbname, Boolean chovay, int laisuat, double phiuythac) { string sqlStrG, sqlStrL, sqlStrP; string tientraG, tientraL; int i; int lephi; double lephiuythac_i, ngaychiulai, dunogoc; TimeSpan difDays; CashDB = new db(dbname); lephi = (int)(phiuythac * 100); for (i = 0; i < dtGridCF.Rows.Count; i++) { string ngaytra; ngaytra = dtGridCF.Rows[i].Cells["Ngaytra"].Value.ToString(); tientraG = dtGridCF.Rows[i].Cells["Sotien"].Value.ToString(); tientraL = dtGridCF.Rows[i].Cells["Tienlai"].Value.ToString(); dunogoc = double.Parse(dtGridCF.Rows[i].Cells["Duno"].Value.ToString()); if (chovay == false) { tientraG = "-" + tientraG; tientraL = "-" + tientraL; } sqlStrG = "INSERT INTO [DONGTIEN] ([MaHD], [NoQH], [Datra], [Real], [MoTa], [Sotien], [NgayTra]) "; sqlStrG = sqlStrG + "VALUES ('" + MaHD +"', No, No, " + real.ToString() + ", 'Tra goc ky " + (i+1).ToString(); sqlStrG = sqlStrG + "', " + tientraG + ", '" + ngaytra + "')"; sqlStrL = "INSERT INTO [TIENLAI] ([MaHD], [NoQH], [Datra], [Real], [MoTa], [Sotienlai], [NgayTra], [Tienchiulai], [Laisuat])"; sqlStrL = sqlStrL + "VALUES ('" + MaHD + "', 0, No, " + real.ToString() + ", 'Tra lai ky " + (i+1).ToString(); sqlStrL = sqlStrL + "', " + tientraL + ", '" + ngaytra + "', " + dtGridCF.Rows[i].Cells["Duno"].Value.ToString(); sqlStrL = sqlStrL + ", " + laisuat + ")"; CashDB.runSQLCmd(sqlStrG); CashDB.runSQLCmd(sqlStrL); if (chovay == false) { difDays = DateTime.Parse(this.ngaytra).Subtract(DateTime.Parse(ngayvay)); ngaychiulai = (double)(difDays.Days); lephiuythac_i = (double)Math.Round((decimal)(ngaychiulai * phiuythac * dunogoc) / (360 * 100)); sqlStrP = "INSERT INTO [TIENLAI] ([MaHD], NoQH, [Datra], [Real], [Mota], [Sotienlai], [Ngaytra], [Tienchiulai], [Laisuat]) VALUES"; sqlStrP = sqlStrP + "('" + MaHD + "', 0, No, " + real.ToString() + ", 'Phi uy thac quan ly von', "; sqlStrP = sqlStrP + lephiuythac_i.ToString() + ", '" + ngaytra + "', " + Math.Abs(tongtien) + ", " + lephi.ToString() + ")"; CashDB.runSQLCmd(sqlStrP); } } //Neu la tien cho vay phi se duoc tinh dua tren so tien gui ban dau if (chovay == true) { difDays = DateTime.Parse(this.ngaytra).Subtract(DateTime.Parse(ngayvay)); ngaychiulai = (double)(difDays.Days); lephiuythac_i = (double)Math.Round((decimal)(ngaychiulai * phiuythac * tongtien) / (360 * 100)); lephiuythac_i = Math.Abs(lephiuythac_i); try { sqlStrP = "INSERT INTO [TIENLAI] ([MaHD], [NoQH], [Datra], [Real], [Mota], [Sotienlai], [Ngaytra], [Tienchiulai], [Laisuat]) VALUES"; sqlStrP = sqlStrP + "('" + MaHD + "', 0, No, " + real.ToString() + ", 'Phi dich vu cho vay bang', "; sqlStrP = sqlStrP + lephiuythac_i.ToString() + ", '" + ngaytra + "', " + Math.Abs(tongtien) + ", " + lephi.ToString() + ")"; CashDB.runSQLCmd(sqlStrP); } catch (Exception ex) { return; } } CashDB.close(); }
private void cmdAccept_Click(object sender, EventArgs e) { string sqlStr; string tongtien; Boolean real, chovay; double phiuythac; chovay = false; if (Check_Data() == false) { return; } if (check_validate() == false) { return; } if (cbxLoaiHD.Text == "Cho vay") { tongtien = "-" + txtTongtien.Text; chovay = true; } else { tongtien = txtTongtien.Text; } real = !chkReal.Checked; laisuat = (int)(float.Parse(cbxLaisuat.Text) * 100); if (edit == true) { sqlStr = "UPDATE [HOPDONG] SET [Real] = " + real.ToString(); sqlStr = sqlStr + ", [DESC] = '" + txtDesc.Text + "', [Laisuat] = " + cbxLaisuat.Text + " WHERE [MaHD] = '" + MaHD + "'"; contractDb.runSQLCmd(sqlStr); sqlStr = "UPDATE [DONGTIEN] SET [Real] = " + real.ToString() + "WHERE [MaHD] ='" + MaHD + "'"; contractDb.runSQLCmd(sqlStr); sqlStr = "UPDATE [TIENLAI] SET [Real] = " + real.ToString() + "WHERE [MaHD] ='" + MaHD + "'"; contractDb.close(); this.Close(); } else { sqlStr = "INSERT INTO [HOPDONG] ([MaHD], [MaKH], [NgayHD], [Tongtien], [Real], [Kyhan], [DonVT], [Laisuat], [Desc]"; sqlStr = sqlStr + ", [Hoanthanh], [NoQH], [Tratruoc], [Hinhthuctra]) VALUES ('"; sqlStr = sqlStr + txtMaHD.Text + "', '" + cbxMaKH.Text + "', '" + cbxDateContracts.Value.ToShortDateString(); sqlStr = sqlStr + "', " + tongtien + ", " + real.ToString(); sqlStr = sqlStr + ", " + cbxKyhan.Text + ", '" + cbxDonvitinh.Text; sqlStr = sqlStr + "', " + laisuat.ToString() + ", '" + txtDesc.Text; sqlStr = sqlStr + "', No, No, No, " + HTTra + ")"; if (contractDb.runSQLCmd(sqlStr) == false) { return; } sqlStr = "INSERT INTO [DONGTIEN] ([MaHD], [NoQH], [Datra], [Real], [MoTa], [Sotien], [NgayTra]) VALUES ("; sqlStr = sqlStr + "'" + txtMaHD.Text + "', No, No, " + real.ToString() + ", '" + txtDesc.Text + "', "; sqlStr = sqlStr + tongtien + ", '" + cbxDateContracts.Value.ToShortDateString() + "')"; if (contractDb.runSQLCmd(sqlStr) == false) { return; } if (!Utilities.isDouble(txtPhiUT.Text)) { MessageBox.Show("Ban phai nhap lai thong tin ve " + lblUythac.Text); txtPhiUT.Focus(); return; } phiuythac = double.Parse(txtPhiUT.Text); frmNhapTN.Save_Data(real, txtMaHD.Text, dbfile, chovay, laisuat, phiuythac); contractDb.close(); this.Close(); } }
public void init(string dbname, string maHD, string workingdir) { string sqlStr; OleDbDataReader oleReader; contractDb = new db(dbname); Int64 tongtien = 0; int i; MaHD = maHD; edit = true; dbfile = dbname; txtMaHD.Text = maHD; txtMaHD.Enabled = false; cmdKytraShow.Enabled = false; frmNhapTN = new NhapKyTraNo(dbname); frmNhapTN.saved = false; cmdViewContracts.Enabled = true; cmdViewContracts.Visible = true; dirWork = workingdir; if (contractDb == null) { MessageBox.Show("Loi ket noi den database"); this.Close(); } sqlStr = "SELECT [MaKH] FROM [KHACHHANG] ORDER BY [MaKH]"; oleReader = contractDb.genDataReader(sqlStr); while (oleReader.Read()) { cbxMaKH.Items.Add(oleReader[0].ToString()); } sqlStr = "SELECT [MaKH], [NgayHD], [Tongtien], [Real], [Kyhan], [DonVT], [Laisuat], [Desc] FROM [HOPDONG]"; sqlStr = sqlStr + " WHERE [MaHD] = '" + maHD + "'"; try { oleReader = contractDb.genDataReader(sqlStr); while (oleReader.Read()) { cbxMaKH.Text = oleReader["MaKH"].ToString(); cbxMaKH.Enabled = false; tongtien = Int64.Parse(oleReader["Tongtien"].ToString()); cbxKyhan.Text = oleReader["Kyhan"].ToString(); cbxKyhan.Enabled = false; cbxDonvitinh.Text = oleReader["DonVT"].ToString(); cbxDonvitinh.Enabled = false; chkReal.Checked = !(Boolean.Parse(oleReader["Real"].ToString())); cbxDateContracts.Value = DateTime.Parse(oleReader["NgayHD"].ToString()); cbxDateContracts.Enabled = false; txtDesc.Text = oleReader["Desc"].ToString(); laisuat = int.Parse(oleReader["Laisuat"].ToString()); cbxLaisuat.Text = float.Parse(laisuat.ToString()) / 100 + ""; oldLS = cbxLaisuat.Text; // cbxLaisuat.Enabled = false; } if (chkReal.Checked == false) { chkReal.Enabled = false; } if (tongtien > 0) { cbxLoaiHD.Text = cbxLoaiHD.Items[1].ToString(); txtTongtien.Text = tongtien.ToString(); } else { cbxLoaiHD.Text = cbxLoaiHD.Items[0].ToString(); tongtien = Math.Abs(tongtien); txtTongtien.Text = tongtien.ToString(); } txtTongtien.Enabled = false; cbxLoaiHD.Enabled = false; // cbxMaKH.Text = cbxMaKH.Items[0].ToString(); grBoxKytra.Enabled = false; sqlStr = "SELECT [LaiSuat], [LoaiLS] FROM [LAISUAT]"; oleReader = contractDb.genDataReader(sqlStr); LSChovay = new ArrayList(); LSHuydong = new ArrayList(); while (oleReader.Read()) { if (oleReader["LoaiLS"].ToString() == "1") { LSChovay.Add(oleReader["LaiSuat"].ToString()); cbxLaisuat.Items.Add(oleReader["LaiSuat"].ToString()); } else { LSHuydong.Add(oleReader["LaiSuat"].ToString()); } } Create_List_CT(); } catch (Exception ex) { MessageBox.Show(ex.Message); contractDb.close(); this.Close(); } }
/* * Init function using to create object db for Quanlykhachhang * And this function is using to import list custommer from database to form */ public void init(string dbFile) { string sqlString; OleDbDataReader oleReader; string LoaiKH; int MaLoaiKH, i; DataGridViewButtonColumn dtGridBt = new DataGridViewButtonColumn(); LoaiKHList = new ArrayList(); QlkhDb = new db(dbFile); dbname = dbFile; sqlString = "SELECT [MaLoaiKH], [TenLoaiKH] FROM [LOAIKH]"; dtGridKH.AllowUserToAddRows = true; try { oleReader = QlkhDb.genDataReader(sqlString); if (oleReader == null) { MessageBox.Show("Loi ket noi den database!"); this.Close(); return; } while(oleReader.Read()) { MaLoaiKH = int.Parse(oleReader.GetValue(0).ToString()); LoaiKH = oleReader.GetString(1); cbxLoaiKH.Items.Add(LoaiKH); LoaiKHList.Add(MaLoaiKH); } cbxLoaiKH.Items.Add("All"); cbxLoaiKH.Text = cbxLoaiKH.Items[0].ToString(); sqlString = "SELECT [MAKH], [TenKH], [TaikhoanNH], [TenNH], [DinhDanh],[SoDT], [Diachi] FROM [KHACHHANG]"; QlkhDb.fillDtGridView(sqlString, dtGridKH); for (i =0; i < dtGridKH.Columns.Count; i++) { dtGridKH.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } for (i = 0; i < dtGridKH.Rows.Count; i++) { if (rowColor) dtGridKH.Rows[i].DefaultCellStyle.BackColor = activeC; else dtGridKH.Rows[i].DefaultCellStyle.BackColor = NegativeC; rowColor = !rowColor; } dtGridBt.Text = "..."; dtGridBt.Name = "Capnhat"; dtGridBt.Width = 60; dtGridBt.HeaderText = "Cap nhat"; dtGridBt.UseColumnTextForButtonValue = true; dtGridKH.Columns.Add(dtGridBt); dtGridKH.AllowUserToAddRows = false; } catch (Exception ex) { MessageBox.Show(ex.Message); QlkhDb.close(); this.Close(); } }
private void cmdClose_Click(object sender, EventArgs e) { this.Close(); ContractDB.close(); }
public void Save_Data(Boolean real, string MaHD, string dbname, Boolean chovay, int laisuat, double phiuythac) { string sqlStrG, sqlStrL, sqlStrP; string tientraG, tientraL; int i; int lephi; double lephiuythac_i, ngaychiulai, dunogoc; TimeSpan difDays; CashDB = new db(dbname); lephi = (int)(phiuythac * 100); for (i = 0; i < dtGridCF.Rows.Count; i++) { string ngaytra; ngaytra = dtGridCF.Rows[i].Cells["Ngaytra"].Value.ToString(); tientraG = dtGridCF.Rows[i].Cells["Sotien"].Value.ToString(); tientraL = dtGridCF.Rows[i].Cells["Tienlai"].Value.ToString(); dunogoc = double.Parse(dtGridCF.Rows[i].Cells["Duno"].Value.ToString()); if (chovay == false) { tientraG = "-" + tientraG; tientraL = "-" + tientraL; } sqlStrG = "INSERT INTO [DONGTIEN] ([MaHD], [NoQH], [Datra], [Real], [MoTa], [Sotien], [NgayTra]) "; sqlStrG = sqlStrG + "VALUES ('" + MaHD + "', No, No, " + real.ToString() + ", 'Tra goc ky " + (i + 1).ToString(); sqlStrG = sqlStrG + "', " + tientraG + ", '" + ngaytra + "')"; sqlStrL = "INSERT INTO [TIENLAI] ([MaHD], [NoQH], [Datra], [Real], [MoTa], [Sotienlai], [NgayTra], [Tienchiulai], [Laisuat])"; sqlStrL = sqlStrL + "VALUES ('" + MaHD + "', 0, No, " + real.ToString() + ", 'Tra lai ky " + (i + 1).ToString(); sqlStrL = sqlStrL + "', " + tientraL + ", '" + ngaytra + "', " + dtGridCF.Rows[i].Cells["Duno"].Value.ToString(); sqlStrL = sqlStrL + ", " + laisuat + ")"; CashDB.runSQLCmd(sqlStrG); CashDB.runSQLCmd(sqlStrL); if (chovay == false) { difDays = DateTime.Parse(this.ngaytra).Subtract(DateTime.Parse(ngayvay)); ngaychiulai = (double)(difDays.Days); lephiuythac_i = (double)Math.Round((decimal)(ngaychiulai * phiuythac * dunogoc) / (360 * 100)); sqlStrP = "INSERT INTO [TIENLAI] ([MaHD], NoQH, [Datra], [Real], [Mota], [Sotienlai], [Ngaytra], [Tienchiulai], [Laisuat]) VALUES"; sqlStrP = sqlStrP + "('" + MaHD + "', 0, No, " + real.ToString() + ", 'Phi uy thac quan ly von', "; sqlStrP = sqlStrP + lephiuythac_i.ToString() + ", '" + ngaytra + "', " + Math.Abs(tongtien) + ", " + lephi.ToString() + ")"; CashDB.runSQLCmd(sqlStrP); } } //Neu la tien cho vay phi se duoc tinh dua tren so tien gui ban dau if (chovay == true) { difDays = DateTime.Parse(this.ngaytra).Subtract(DateTime.Parse(ngayvay)); ngaychiulai = (double)(difDays.Days); lephiuythac_i = (double)Math.Round((decimal)(ngaychiulai * phiuythac * tongtien) / (360 * 100)); lephiuythac_i = Math.Abs(lephiuythac_i); try { sqlStrP = "INSERT INTO [TIENLAI] ([MaHD], [NoQH], [Datra], [Real], [Mota], [Sotienlai], [Ngaytra], [Tienchiulai], [Laisuat]) VALUES"; sqlStrP = sqlStrP + "('" + MaHD + "', 0, No, " + real.ToString() + ", 'Phi dich vu cho vay bang', "; sqlStrP = sqlStrP + lephiuythac_i.ToString() + ", '" + ngaytra + "', " + Math.Abs(tongtien) + ", " + lephi.ToString() + ")"; CashDB.runSQLCmd(sqlStrP); } catch (Exception ex) { return; } } CashDB.close(); }
public void init(string dbname, string maHD, string workingdir) { string sqlStr; OleDbDataReader oleReader; contractDb = new db(dbname); Int64 tongtien = 0; int i; MaHD = maHD; edit = true; dbfile = dbname; txtMaHD.Text = maHD; txtMaHD.Enabled = false; cmdKytraShow.Enabled = false; frmNhapTN = new NhapKyTraNo(dbname); frmNhapTN.saved = false; cmdViewContracts.Enabled = true; cmdViewContracts.Visible = true; dirWork = workingdir; if (contractDb == null) { MessageBox.Show("Loi ket noi den database"); this.Close(); } sqlStr = "SELECT [MaKH] FROM [KHACHHANG] ORDER BY [MaKH]"; oleReader = contractDb.genDataReader(sqlStr); while (oleReader.Read()) { cbxMaKH.Items.Add(oleReader[0].ToString()); } sqlStr = "SELECT [MaKH], [NgayHD], [Tongtien], [Real], [Kyhan], [DonVT], [Laisuat], [Desc] FROM [HOPDONG]"; sqlStr = sqlStr + " WHERE [MaHD] = '" + maHD + "'"; try { oleReader = contractDb.genDataReader(sqlStr); while (oleReader.Read()) { cbxMaKH.Text = oleReader["MaKH"].ToString(); cbxMaKH.Enabled = false; tongtien = Int64.Parse(oleReader["Tongtien"].ToString()); cbxKyhan.Text = oleReader["Kyhan"].ToString(); cbxKyhan.Enabled = false; cbxDonvitinh.Text = oleReader["DonVT"].ToString(); cbxDonvitinh.Enabled = false; chkReal.Checked = !(Boolean.Parse(oleReader["Real"].ToString())); cbxDateContracts.Value = DateTime.Parse(oleReader["NgayHD"].ToString()); cbxDateContracts.Enabled = false; txtDesc.Text = oleReader["Desc"].ToString(); laisuat = int.Parse(oleReader["Laisuat"].ToString()); cbxLaisuat.Text = float.Parse(laisuat.ToString()) / 100 + ""; oldLS = cbxLaisuat.Text; // cbxLaisuat.Enabled = false; } if (chkReal.Checked == false) chkReal.Enabled = false; if (tongtien > 0) { cbxLoaiHD.Text = cbxLoaiHD.Items[1].ToString(); txtTongtien.Text = tongtien.ToString(); } else { cbxLoaiHD.Text = cbxLoaiHD.Items[0].ToString(); tongtien = Math.Abs(tongtien); txtTongtien.Text = tongtien.ToString(); } txtTongtien.Enabled = false; cbxLoaiHD.Enabled = false; // cbxMaKH.Text = cbxMaKH.Items[0].ToString(); grBoxKytra.Enabled = false; sqlStr = "SELECT [LaiSuat], [LoaiLS] FROM [LAISUAT]"; oleReader = contractDb.genDataReader(sqlStr); LSChovay = new ArrayList(); LSHuydong = new ArrayList(); while (oleReader.Read()) { if (oleReader["LoaiLS"].ToString() == "1") { LSChovay.Add(oleReader["LaiSuat"].ToString()); cbxLaisuat.Items.Add(oleReader["LaiSuat"].ToString()); } else LSHuydong.Add(oleReader["LaiSuat"].ToString()); } Create_List_CT(); } catch (Exception ex) { MessageBox.Show(ex.Message); contractDb.close(); this.Close(); } }