private void btnCreateBooking_Click(object sender, EventArgs e) { if (dtpTodaysDate.Value.Day < dtpExpiryDate.Value.Day) { if (cbAddress.Checked == true && cbCustomer.Checked == true && cbItem.Checked == true) { DialogResult dr = new DialogResult(); dr = MessageBox.Show("Are you sure you want to add this booking?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { CUser user = CUser.GetInstance(); CLogin login = CLogin.GetInstance(); CBooking booking = new CBooking(); int iBookingID = booking.CreateBooking(dtpTodaysDate.Value, dtpExpiryDate.Value); bookinginstance.iUserID = user.GetUserID(login.GetUser()); bookinginstance.iBookingID = iBookingID; bookinginstance.CreateBookingInstance(); MessageBox.Show("Booking has been created.", "Note", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("Ensure that you have selected a customer, an address and an item.", "Note", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("Please select a date greater than todays date.", "Note", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void PopulateUserList() { lstbxUsers.Items.Clear(); User = CUser.GetInstance(); foreach (CUser user in User.getUsers()) { lstbxUsers.Items.Add(user.sName + " " + user.sSurname + user.sUserName); } }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { ClearUserText(); btnAdd.Visible = false; btnEdit.Visible = true; grpbxAddUsers.Enabled = true; grpbxAddUsers.Text = "Edit User"; User = CUser.GetInstance(); User = User.GetUser(conn, lstbxUsers.SelectedItem.ToString()); txtUserID.Text = User.sID.ToString(); txtName.Text = User.sName; txtPassword.Text = User.sPassword; txtSurname.Text = User.sSurname; txtUseranme.Text = User.sUserName; cmbUserType.SelectedIndex = cmbUserType.FindStringExact(User.sUserType); }
private void btnEdit_Click(object sender, EventArgs e) { if (txtName.Text != "" && txtPassword.Text != "" && txtSurname.Text != "" && txtUseranme.Text != "") { User = CUser.GetInstance(); int IsValid; IsValid = User.EditUser(conn, Convert.ToInt32(txtUserID.Text), txtName.Text, txtSurname.Text, txtUseranme.Text, txtPassword.Text, cmbUserType.SelectedItem.ToString()); if (IsValid == 1) { MessageBox.Show("User updated successfully!"); } else { MessageBox.Show("There was an error updating this user!"); } PopulateUserList(); } }
private void btnRemove_Click(object sender, EventArgs e) { DialogResult dr = new DialogResult(); dr = MessageBox.Show("Are you sure you want to remove this user?", "OK", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { User = CUser.GetInstance(); int IsValid; IsValid = User.RemoveUser(conn, Convert.ToInt32(txtUserID.Text)); if (IsValid == 1) { MessageBox.Show("User has successfully been removed!"); PopulateUserList(); ClearUserTextBoxes(); lstbxUsers.SelectedIndex = 0; } else { MessageBox.Show("Please select a user to be removed."); } } }
private void btnAdd_Click(object sender, EventArgs e) { if (txtName.Text != "" && txtPassword.Text != "" && txtSurname.Text != "" && txtUseranme.Text != "") { User = CUser.GetInstance(); int IsValid = User.AddNewUser(conn, txtUseranme.Text, txtPassword.Text, txtName.Text, txtSurname.Text, cmbUserType.SelectedItem.ToString()); if (IsValid == 1) { MessageBox.Show("User added successfully!"); PopulateUserList(); ClearUserTextBoxes(); lstbxUsers.SelectedIndex = 0; EnableUserButtons(); } else { MessageBox.Show("User with this username already exists."); } } else { MessageBox.Show("Please fill in all the text boxes available."); } }