private void logoutToolStripMenuItem_Click(object sender, EventArgs e) { //when user click logout, the object become null loggeduser = null; }
/// <summary> /// Create a new MsStaff object. /// </summary> /// <param name="staffID">Initial value of the StaffID property.</param> /// <param name="staffName">Initial value of the StaffName property.</param> /// <param name="staffShift">Initial value of the StaffShift property.</param> /// <param name="staffUsername">Initial value of the StaffUsername property.</param> /// <param name="staffPassword">Initial value of the StaffPassword property.</param> /// <param name="staffType">Initial value of the StaffType property.</param> public static MsStaff CreateMsStaff(global::System.String staffID, global::System.String staffName, global::System.String staffShift, global::System.String staffUsername, global::System.String staffPassword, global::System.Int32 staffType) { MsStaff msStaff = new MsStaff(); msStaff.StaffID = staffID; msStaff.StaffName = staffName; msStaff.StaffShift = staffShift; msStaff.StaffUsername = staffUsername; msStaff.StaffPassword = staffPassword; msStaff.StaffType = staffType; return msStaff; }
/// <summary> /// Deprecated Method for adding a new object to the MsStaff EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToMsStaff(MsStaff msStaff) { base.AddObject("MsStaff", msStaff); }
private void btnSubmit_Click(object sender, EventArgs e) { //if button submit is clicked, validate all the fields according to the project case if (txtName.Text.Equals("")) lblError.Text = "Name must not be empty"; else if (!checkName()) lblError.Text = "Name can only accept alphabet"; else if (txtName.Text.Length > 50) lblError.Text = "Max name length is 50 characters"; else if (txtUser.Text.Equals("")) lblError.Text = "Username must not be empty"; else if (!checkUsername()) lblError.Text = "Username can only accept [a-z][A-Z][-]"; else if (txtUser.Text.Length > 10) lblError.Text = "Max username length is 10 characters"; else if (txtPass.Text.Length < 8 || txtPass.Text.Length > 50) lblError.Text = "Password length must be at least 8 characters and maximum 50 characters"; else if (cmbShift.SelectedIndex < 0) lblError.Text = "Select staff shift"; else { if (op == 1) { //if the varible op contain 1 value, then do insert to database MsStaff obj = new MsStaff(); obj.StaffID = txtID.Text; obj.StaffName = txtName.Text; obj.StaffType = cmbType.SelectedIndex + 1; obj.StaffPassword = txtPass.Text; obj.StaffUsername = txtUser.Text; obj.StaffShift = cmbShift.SelectedItem.ToString(); ent.AddToMsStaff(obj); ent.SaveChanges(); refreshList(); } else if (op == 2) { //if the varible op contain 2 value, then do update to database MsStaff obj = (from x in ent.MsStaff where x.StaffID.Equals(txtID.Text) select x).First(); obj.StaffName = txtName.Text; obj.StaffType = cmbType.SelectedIndex + 1; obj.StaffPassword = txtPass.Text; obj.StaffUsername = txtUser.Text; obj.StaffShift = cmbShift.SelectedItem.ToString(); ent.SaveChanges(); refreshList(); } //return to the initial state btnCancel.Visible = false; btnSubmit.Visible = false; btnUpdate.Enabled = true; if (user.Equals("admin")) btnDelete.Enabled = true; if (!user.Equals("del")) btnInsert.Enabled = true; dataEnabled(false); op = 0; } }