private void addJobForm_Load(object sender, EventArgs e) { try { contx = new saavyTechDBE(); //Populate the equipment Dropdown var equipment = contx.equiptmentType.ToList(); cboequipType.DataSource = equipment; cboequipType.DisplayMember = "equiptmentName"; cboequipType.ValueMember = "Id"; //Populate the brand Dropdown var brand = contx.Brand.ToList(); cbobrand.DataSource = brand; cbobrand.DisplayMember = "brandName"; cbobrand.ValueMember = "Id"; //Populate the status Dropdown var status = contx.status.ToList(); cbostatus.DataSource = status; cbostatus.DisplayMember = "statusName"; cbostatus.ValueMember = "Id"; } catch (Exception ex) { throw ex; } }
private void btnLogin_Click(object sender, EventArgs e) { var username = txtusername.Text; var password = txtPassword.Text; //declare object of DB model var contx = new saavyTechDBE(); //check if true value was returned fron the user check and grant access //If false, then continue to restrict access var user = contx.Users.SingleOrDefault(q => q.username == username && q.password == password); if (user != null) { var parent = (saavyTechManinForm)MdiParent; parent.isLoggedIn = true; var usr = user.firstName + " " + user.lastName; var roleID = user.roleId; int userid = user.Id; parent.userName = usr; parent.userRole = (int)roleID; parent.userId = userid; parent.checkjobs(); parent.UpdateMain(); //notify icon txtNotify.Text = "User " + username + "is logged in"; txtNotify.BalloonTipText = "User " + usr + " is logged in"; txtNotify.BalloonTipTitle = "Login Successful"; txtNotify.Icon = SystemIcons.Application; txtNotify.ShowBalloonTip(1000); this.Close(); } else { MessageBox.Show("Invalid Credentials. Please try again."); txtusername.Text = ""; txtPassword.Text = ""; txtusername.Focus(); } }
private void jobsForm_Load(object sender, EventArgs e) { contx = new saavyTechDBE(); checkRole(); try { //Populate the status Dropdown and get status var status = contx.status.ToList(); // set roles datasource cbostatus.DataSource = status; //Set the data member and value member to the values cbostatus.DisplayMember = "statusName"; cbostatus.ValueMember = "Id"; //Populate The Grid View RefreshGridView(); //Manually set the text you want for the column headers. gvJobs.Columns["firstName"].HeaderText = "First Name"; gvJobs.Columns["lastName"].HeaderText = "Last Name"; gvJobs.Columns["jobNumber"].HeaderText = "Job Number"; gvJobs.Columns["equiptmentName"].HeaderText = "Equipment"; gvJobs.Columns["brandName"].HeaderText = "Brand"; gvJobs.Columns["model"].HeaderText = "Model"; gvJobs.Columns["serial"].HeaderText = "Serial"; gvJobs.Columns["issues"].HeaderText = "Problems"; gvJobs.Columns["techReport"].HeaderText = "Tech Report"; gvJobs.Columns["statusName"].HeaderText = "Status"; //Hide columns that you do not want to display for users gvJobs.Columns[0].Visible = false; //Set the first row as selected by default //gvJobs.Rows[0].Selected = true; } catch (Exception ex) { throw ex; } }
public void checkjobs() { //declare object of DB model var contx = new saavyTechDBE(); int newCount = contx.Jobs.Count(q => q.statusId == 1); int completeCount = contx.Jobs.Count(q => q.statusId == 3); //check jobs and show count switch (userRole) { case 2: lbljobCount.Text = completeCount.ToString() + " Completed Job(s) Available."; lbljobCount.ForeColor = Color.Blue; break; case 3: lbljobCount.Text = newCount.ToString() + " New Job(s) in Queue."; lbljobCount.ForeColor = Color.Red; break; } }
private void usersForm_Load(object sender, EventArgs e) { try { contx = new saavyTechDBE(); //Populate the roles Dropdown and get roles var Roles = contx.userRole.ToList(); // set roles datasource cbouserRole.DataSource = Roles; //Set the data member and value member to the values cbouserRole.DisplayMember = "role"; cbouserRole.ValueMember = "Id"; //Populate The Grid View RefreshGridView(); //Manually set the text you want for the column headers. gvusers.Columns["firstName"].HeaderText = "First Name"; gvusers.Columns["lastName"].HeaderText = "Last Name"; gvusers.Columns["phoneNumber"].HeaderText = "Phone #"; gvusers.Columns["email"].HeaderText = "Email"; gvusers.Columns["username"].HeaderText = "Username"; gvusers.Columns["role"].HeaderText = "User Role"; //Hide columns that you do not want to display for users gvusers.Columns[0].Visible = false; //Set the first row as selected by default //gvusers.Rows[0].Selected = true; } catch (Exception ex) { throw ex; } }