private void Create_Admin(string username, string pass) { string sqlString; int boolvalue; if (admin) { boolvalue = 1; } else { boolvalue = 0; } sqlString = "INSERT INTO QUANLYUSER (Username, Password) VALUES ('" + username + "',"; sqlString = sqlString + " '" + pass + "')"; if (hdbhData.runSQLCmd(sqlString)) { sqlString = "INSERT INTO UserRole (Username, RoleID, Value) VALUES ('" + username + "', "; sqlString = sqlString + "'8', '" + boolvalue + "')"; hdbhData.runSQLCmd(sqlString); created = true; } else { created = false; } 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(); }
private void UpdateUser() { string sqlStr; int LoaiKH; if (chkPhanloai.Checked == false) //Khach hang doanh nghiep { LoaiKH = 1; } else { LoaiKH = 2; } sqlStr = "UPDATE [KHACHHANG] SET [TenKH] = '" + txtCusName.Text + "', "; sqlStr = sqlStr + "[DinhDanh] = '" + txtIdentCardNum.Text + "', "; sqlStr = sqlStr + "[Ngaycap] = '" + txtIssDate.Text + "', "; sqlStr = sqlStr + "[NoiCap] = '" + txtIssPlace.Text + "', "; sqlStr = sqlStr + "[SoDT] = '" + txtPhoneNum.Text + "', "; sqlStr = sqlStr + "[Diachi] = '" + txtAddress.Text + "', "; sqlStr = sqlStr + "[TaikhoanNH] = '" + txtAccount.Text + "', "; sqlStr = sqlStr + "[TenNH] = '" + txtBank.Text + "', "; sqlStr = sqlStr + "[MaLoaiKH] = " + LoaiKH; sqlStr = sqlStr + " WHERE [MaKH] = '" + txtCusCode.Text + "'"; try { CusDb.runSQLCmd(sqlStr); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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 Create_Admin(string username, string pass) { string sqlString; sqlString = "INSERT INTO QUANLYUSER ([Username], [Password]) VALUES ('" + username + "',"; sqlString = sqlString + " '" + pass + "')"; if (hdbhData.runSQLCmd(sqlString)) { sqlString = "INSERT INTO UserRole ([Username], [RoleID], [Value]) VALUES ('" + username + "', "; sqlString = sqlString + "8, " + admin + ")"; hdbhData.runSQLCmd(sqlString); created = true; } else { created = false; } this.Close(); }
private void cmdDelete_Click(object sender, EventArgs e) { DataGridViewRow dtGridRow; string sqlStr; if (dtGridUser.SelectedRows.Count == 0) { return; } dtGridRow = dtGridUser.SelectedRows[0]; if (dtGridRow.Cells["Ten nguoi dung"].Value.ToString() == "admin") { MessageBox.Show("Ban khong the xoa nguoi dung admin"); return; } sqlStr = "DELETE FROM [Quanlyuser] WHERE [Username] = '" + dtGridRow.Cells["Ten nguoi dung"].Value.ToString() + "'"; dbUser.runSQLCmd(sqlStr); sqlStr = "DELETE FROM [UserRole] WHERE [Username] = '" + dtGridRow.Cells["Ten nguoi dung"].Value.ToString() + "'"; dbUser.runSQLCmd(sqlStr); dtGridUser.Rows.Remove(dtGridRow); }
private void cmdSave_Click(object sender, EventArgs e) { string sqlStr; int i; for (i = 0; i < dtGridCF.Rows.Count; i++) { sqlStr = "UPDATE [TIENLAI] SET [Sotienlai] = " + dtGridCF.Rows[i].Cells["Tienlai"].Value.ToString(); sqlStr = sqlStr + ", [Laisuat] = " + txtLaisuat.Text + " WHERE [MaDT] = " + dtGridCF.Rows[i].Cells["MaDongTien"].Value.ToString(); CashDB.runSQLCmd(sqlStr); } saved = true; this.Close(); }
private void cmdSubmit_Click_1(object sender, EventArgs e) { string sqlString; string user = cbxUserName.Text; foreach (Control ctl in this.gpQuyen.Controls) { if (ctl.ToString().Contains("CheckBox")) { CheckBox crrCtl = (CheckBox)ctl; sqlString = "UPDATE [UserRole] SET [VALUE] = " + crrCtl.Checked; sqlString = sqlString + " WHERE Username = '******' AND"; sqlString = sqlString + " RoleID = " + crrCtl.Tag.ToString(); roledb.runSQLCmd(sqlString); } } 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 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 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(); } }