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 btnCancel_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Cancel", "Confirm", MessageBoxDefaultButton.Button1, MessageBoxIcon.Information); if (result.Equals(DialogResult.OK)) { dbClass db = new dbClass(); db.dbUpdate("UPDATE room SET owner = '', state='available', reserveddate='', email='', phone='', days=1 WHERE id=" + txtRoomId.Text); showHide("menu", true); showHide("client", false); setRoomState(); getRoomsCount(); getCheckoutLog(); RecentCheckOutTab.Hide(); RecentCheckOutTab.Show(); MessageBox.Show("Room " + txtRoomId.Text + " is now available!"); } else { } }
private void btnAvailable_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Checkout", "Confirm", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (result.Equals(DialogResult.OK)) { dbClass db = new dbClass(); db.dbUpdate("UPDATE room SET owner = '', state='available', reserveddate='', email='', phone='', days=1, reference='' WHERE id=" + txtRoomId.Text); db.dbUpdate("UPDATE reservelog SET state='checkout', checkoutdate='" + getDateTime() + "' WHERE reference='" + labelRef.Text + "'"); showHide("menu", true); showHide("client", false); setRoomState(); getRoomsCount(); getCheckoutLog(); RecentCheckOutTab.Hide(); RecentCheckOutTab.Show(); MessageBox.Show("Room " + txtRoomId.Text + " is now available!"); } else { } }