private void btnLogin_Click(object sender, EventArgs e) { System.Data.DataTable dt = loginQuery(txtUsername.Text, txtPassword.Text); dbClass db = new dbClass(); if (dt.Rows.Count > 0) { this.Width = 934; if (dt.Rows[0][3].ToString() == "admin") { db.dbInsert("INSERT INTO loginlog (email, date, usertype) VALUES('" + txtUsername.Text + "', '" + getDateTime() + "', 'admin')"); showHide("login", false); showHide("room", true); showHide("menu", true); labelUser.Text = dt.Rows[0][5].ToString(); labelUserType.Text = dt.Rows[0][3].ToString(); linkEditUsers.Visible = true; } else { db.dbInsert("INSERT INTO loginlog (email, date, usertype) VALUES('" + txtUsername.Text + "', '" + getDateTime() + "', 'staff')"); showHide("login", false); showHide("room", true); showHide("menu", true); labelUser.Text = dt.Rows[0][5].ToString(); labelUserType.Text = dt.Rows[0][3].ToString(); linkEditUsers.Visible = false; } getLoginLog(); } else { MessageBox.Show("Incorrect username/password!"); } }
private void btnUpdate_Click(object sender, EventArgs e) { if (txtEmail.Text.Contains('@')) { dbClass db = new dbClass(); if (txtRoomOwner.Text == "" || txtEmail.Text == "") { MessageBox.Show("Fill up all forms!"); } else { if (checkDateIfExist() == false) { System.Data.DataTable owner = db.dbSelect("SELECT * FROM client WHERE name='" + txtRoomOwner.Text + "'"); if (owner.Rows.Count == 0) { db.dbInsert("INSERT INTO client (name, email, phone) VALUES('" + txtRoomOwner.Text + "', '" + txtEmail.Text + "', '" + txtMobile.Text + "')"); } else { db.dbUpdate("UPDATE client SET name = '" + txtRoomOwner.Text + "', email='" + txtEmail.Text + "', phone='" + txtMobile.Text + "' WHERE name='" + txtRoomOwner.Text + "'"); } decimal percent = (decimal)0.70; double formula = Convert.ToDouble((noOfDays.Value * 2000) - (((noOfDays.Value * 2000) * percent))); db.dbInsert("INSERT INTO room_ind (name, owner, reserveddate, email, phone, days, reference) VALUES('Room " + txtRoomId.Text + "', '" + txtRoomOwner.Text + "', '" + dateTimeFrom.Text + "', '" + txtEmail.Text + "', '" + txtMobile.Text + "', '" + noOfDays.Value + "', '" + this.reference + "')"); db.dbInsert("INSERT INTO reservelog (name, owner, reserveddate, email, phone, days, balance, reference) VALUES('Room " + txtRoomId.Text + "', '" + txtRoomOwner.Text + "', '" + dateTimeFrom.Text + "', '" + txtEmail.Text + "', '" + txtMobile.Text + "', '" + noOfDays.Value + "', '" + formula + "', '" + this.reference + "')"); showHide("client", false); showHide("menu", true); setRoomState(); getRoomsCount(); getCheckoutLog(); sendMail(txtRoomOwner.Text, txtEmail.Text, txtRoomId.Text, dateTimeFrom.Text, noOfDays.Value); RecentCheckOutTab.Hide(); RecentCheckOutTab.Show(); MessageBox.Show("Room Reserved to " + txtRoomOwner.Text); clearFields(); genReference(); } else { MessageBox.Show("Reservation date exist!"); } } } else { MessageBox.Show("Enter valid email address!"); } }
private void btnReg_Click(object sender, EventArgs e) { dbClass db = new dbClass(); db.dbInsert("INSERT INTO security (email, password, usertype, fullname) VALUES('" + txtEmail.Text + "', '" + txtPassword.Text + "', '" + cmbType.Text + "', '" + txtFullName.Text + "')"); this.Hide(); MessageBox.Show("User Added!"); }