private void RegisterButton_Click(object sender, EventArgs e) { string UserName = NameBox.Text; string UserEmail = EmailBox.Text; string UserPassword = PasswordBox.Text; string role = RoleBox.Text; int UserRole; if (role == "Menaxher") { UserRole = 1; } else { UserRole = 2; } //we have to register a user DataAccess _DataAccess = new DataAccess(); if (_DataAccess.RegisterUser(UserName, UserEmail, UserPassword, UserRole)) { int UserID = Convert.ToInt32(_DataAccess.ReturnUserID(UserEmail)); AdminDashboard _Dashboard = new AdminDashboard(UserID, _DataAccess.GetState()); MessageBox.Show("Perdoruesi u regjistrua me sukses ne rolin " + role); this.Hide(); _Dashboard.Show(); } }
private void EnterButton_Click(object sender, EventArgs e) { string UserEmail = EmailBox.Text; if (ConfirmEmailAddress(UserEmail)) { string UserPassword = PasswordBox.Text; if (ConfirmPassword(UserPassword)) { DataAccess _DataAccess = new DataAccess(); if (_DataAccess.ConfirmUser(UserEmail, UserPassword)) { int UserID = Convert.ToInt32(_DataAccess.ReturnUserID(UserEmail)); int RoleID = Convert.ToInt32(_DataAccess.ReturnUserRole(UserEmail)); ApplicationState State = _DataAccess.GetState(); if (RoleID == 1) { AdminDashboard _Dashboard = new AdminDashboard(UserID, State); _Dashboard.Show(); this.Hide(); } else if (RoleID == 2) { WaiterDashboard _Dashboard = new WaiterDashboard(UserID, State); _Dashboard.Show(); this.Hide(); } else { MessageBox.Show("Nuk keni privilegje per te hyre ne sistem."); } } else { MessageBox.Show("Kredenciale te pasakta. Ju lutem, provoni perseri!"); } } else { MessageBox.Show("Ju lutem, shkruani fjalekalimin e sakte!"); } } else { MessageBox.Show("Ju lutem, shkruani email-in e sakte!"); } }