public AddShopItemForm(string authUsername, string authPassword, AdminDashboardForm adminDashboardForm) { InitializeComponent(); AuthUsername = authUsername; AuthPassword = authPassword; AdminDashboardForm = adminDashboardForm; }
public AddComputerForm(string authUsername, string authPassword, AdminDashboardForm dashboardForm) { InitializeComponent(); AuthUsername = authUsername; AuthPassword = authPassword; DashboardForm = dashboardForm; }
public EditShopItemForm(string authUsername, string authPassword, long productID, AdminDashboardForm adminDashboardForm, string name, int price) { InitializeComponent(); TextBoxName.Text = name; NumericPrice.Value = price; AuthUsername = authUsername; AuthPassword = authPassword; AdminDashboardForm = adminDashboardForm; ProductID = productID; }
public EditUserForm(string authUsername, string authPassword, long userID, AdminDashboardForm adminDashboardForm, string name, string email, string role, string password) { InitializeComponent(); UserID = userID; AuthUsername = authUsername; AuthPassword = authPassword; AdminDashboardForm = adminDashboardForm; TextBoxName.Text = name; TextBoxEmail.Text = email; TextBoxPassword.Text = password; ComboBoxRole.Text = role; }
private async void ButtonLogin_Click(object sender, EventArgs e) { foreach (Control control in Controls) { control.Enabled = false; } var userUsername = TextBoxUsername.Text; var userPassword = TextBoxPassword.Text; try { var user = await $"{Constant.URL}/api/user/auth" .PostJsonAsync(new { Username = userUsername, Password = userPassword }) .ReceiveJson <User>(); switch (ComboBoxAccess.Text) { case "User": { if (user.Duration <= 0) { MessageBox.Show("You do not have any duration to use the computer"); } else { var PCID = Int64.Parse(TextBoxPCID.Text); var formDashboard = new UserDashboardForm(userUsername, userPassword, PCID, this); formDashboard.Show(this); Hide(); } } break; case "Staff": { if (user.Role != User.Roles.Staff) { MessageBox.Show($"{user.Role} can not login as staff!"); } else { var formDashboard = new StaffDashboardForm(userUsername, userPassword, this); formDashboard.Show(); Hide(); } } break; case "Admin": { if (user.Role != User.Roles.Admin) { MessageBox.Show($"{user.Role} can not login as admin!"); } else { var formDashboard = new AdminDashboardForm(userUsername, userPassword, this); formDashboard.Show(); Hide(); } } break; default: MessageBox.Show("No such roles exists!"); break; } } catch (FlurlHttpException ex) { if (ex.Call.HttpResponseMessage.StatusCode == System.Net.HttpStatusCode.Forbidden) { MessageBox.Show("Wrong username or password"); } else { var errorResp = await ex.Call.Response.GetStringAsync(); MessageBox.Show($"{ex.Message}\n{errorResp}"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } foreach (Control control in Controls) { control.Enabled = true; } }