private void btnEditDirectSales_Click(object sender, RoutedEventArgs e) { EmployeeStatusModel empStatus = dgvEmpStatus.SelectedItem as EmployeeStatusModel; if (empStatus != null) { strRecordID = empStatus.ID; txtEmpStatus.Text = empStatus.Status; txtDescription.Text = empStatus.Description; dgvEmpStatus.IsEnabled = false; btnSave.Visibility = Visibility.Hidden; btnUpdate.Visibility = Visibility.Visible; } }
private void loadEmployeeStatus() { conDB = new ConnectionDB(); queryString = "SELECT ID, status, description FROM tblempstatus WHERE isDeleted = 0"; EmployeeStatusModel empStatus = new EmployeeStatusModel(); cmbStatus.Items.Clear(); MySqlDataReader reader = conDB.getSelectConnection(queryString, null); while (reader.Read()) { empStatus.ID = reader["ID"].ToString(); empStatus.Status = reader["status"].ToString(); empStatus.Description = reader["description"].ToString(); cmbStatus.Items.Add(empStatus); empStatus = new EmployeeStatusModel(); } conDB.closeConnection(); }
public void CreateNewEmployee(object e) { var newEmployee = new EmployeeModel(); newEmployee.FirstName = FirstName; newEmployee.LastName = LastName; newEmployee.Nickname = Nickname; newEmployee.HireDate = HireDate; newEmployee.Emails = Emails; newEmployee.Phones = Phones; newEmployee.Certifications = Certifications; newEmployee.Restrictions = Restrictions; newEmployee.Department = _selectedDepartment; newEmployee.JobTitle = _selectedJobTitle; EmployeeStatusModel newEmployeeStatus = new EmployeeStatusModel(); newEmployeeStatus.Id = 1; newEmployee.Status = newEmployeeStatus; SendData.CreateEmployee(newEmployee); }
private List <EmployeeStatusModel> loadDatagridDetails() { conDB = new ConnectionDB(); List <EmployeeStatusModel> lstEmpStatusModel = new List <EmployeeStatusModel>(); EmployeeStatusModel emp = new EmployeeStatusModel(); queryString = "SELECT ID, status, description FROM tblempstatus WHERE isDeleted = 0"; MySqlDataReader reader = conDB.getSelectConnection(queryString, null); while (reader.Read()) { emp.ID = reader["ID"].ToString(); emp.Status = reader["status"].ToString(); emp.Description = reader["description"].ToString(); lstEmpStatusModel.Add(emp); emp = new EmployeeStatusModel(); } conDB.closeConnection(); return(lstEmpStatusModel); }
public static async Task <ObservableCollection <EmployeeModel> > EmployeeQueryAsync() { using (var connection = new System.Data.SqlClient.SqlConnection(CnnString(database))) { var employees = new Dictionary <int, EmployeeModel>(); await connection.QueryAsync <EmployeeModel>("dbo.spGetEmployeeData_All", new[] { typeof(EmployeeModel), typeof(EmailModel), typeof(JobTitleModel), typeof(PhoneModel), typeof(DepartmentModel), typeof(EmployeeStatusModel), typeof(CitationModel), typeof(CertificationModel), typeof(EquipmentAssignmentRecordModel), typeof(RestrictionModel) } , obj => { EmployeeModel employeeModel = obj[0] as EmployeeModel; EmailModel emailModel = obj[1] as EmailModel; JobTitleModel titleModel = obj[2] as JobTitleModel; PhoneModel phoneModel = obj[3] as PhoneModel; DepartmentModel departmentModel = obj[4] as DepartmentModel; EmployeeStatusModel statusModel = obj[5] as EmployeeStatusModel; CitationModel citationModel = obj[6] as CitationModel; CertificationModel certificationModel = obj[7] as CertificationModel; EquipmentAssignmentRecordModel equipmentAssignmentRecord = obj[8] as EquipmentAssignmentRecordModel; RestrictionModel restrictionModel = obj[9] as RestrictionModel; //employeemodel var employeeEntity = new EmployeeModel(); if (!employees.TryGetValue(employeeModel.Id, out employeeEntity)) { employees.Add(employeeModel.Id, employeeEntity = employeeModel); } //list<emailmodel> if (employeeEntity.Emails == null) { employeeEntity.Emails = new ObservableCollection <EmailModel>(); } if (emailModel != null) { if (!employeeEntity.Emails.Any(x => x.Id == emailModel.Id)) { employeeEntity.Emails.Add(emailModel); } } //phonemodel if (employeeEntity.Phones == null) { employeeEntity.Phones = new ObservableCollection <PhoneModel>(); } if (phoneModel != null) { if (!employeeEntity.Phones.Any(x => x.Id == phoneModel.Id)) { employeeEntity.Phones.Add(phoneModel); } } //title if (employeeEntity.JobTitle == null) { if (titleModel != null) { employeeEntity.JobTitle = titleModel; } } //department if (employeeEntity.Department == null) { if (departmentModel != null) { employeeEntity.Department = departmentModel; } } //status if (employeeEntity.Status == null) { if (statusModel != null) { employeeEntity.Status = statusModel; } } //citation if (employeeEntity.Citations == null) { employeeEntity.Citations = new ObservableCollection <CitationModel>(); } if (citationModel != null) { if (!employeeEntity.Citations.Any(x => x.Id == citationModel.Id)) { employeeEntity.Citations.Add(citationModel); } } //certification if (employeeEntity.Certifications == null) { employeeEntity.Certifications = new ObservableCollection <CertificationModel>(); } if (certificationModel != null) { if (!employeeEntity.Certifications.Any(x => x.Id == certificationModel.Id)) { employeeEntity.Certifications.Add(certificationModel); } } //restriction if (employeeEntity.Restrictions == null) { employeeEntity.Restrictions = new ObservableCollection <RestrictionModel>(); } if (restrictionModel != null) { if (!employeeEntity.Restrictions.Any(x => x.Id == restrictionModel.Id)) { employeeEntity.Restrictions.Add(restrictionModel); } } //equipment record if (employeeEntity.EquipmentAssignments == null) { employeeEntity.EquipmentAssignments = new ObservableCollection <EquipmentAssignmentRecordModel>(); } if (equipmentAssignmentRecord != null) { if (!employeeEntity.EquipmentAssignments.Any(x => x.Id == equipmentAssignmentRecord.Id)) { employeeEntity.EquipmentAssignments.Add(equipmentAssignmentRecord); } } return(employeeEntity); });; var result = employees.Values.ToList(); var employeeCollection = new ObservableCollection <EmployeeModel>(result); return(employeeCollection); } }
public async Task <ObservableCollection <EmployeeModel> > GetEmployeeList() { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString("WorkDeskDB"))) { var sql = @"SELECT e.id, e.FirstName, e.LastName, e.Nickname, e.HireDate, em.id as ID, em.Address, em.Type, jt.id as ID, jt.Name, p.id as ID, p.Number, p.Type, d.id as ID, d.Name, es.id as ID, es.Name, ecitt.id as ID, cit.Name, ecitt.Date, ecitt.Description, ecert.id as ID, cet.Name, cet.Description, ecert.InitialDate, ecert.EmployeeID, eqa.id as ID, eq.InventoryID, eq.Description, eqa.DateOut, eqa.DateIn, eqa.ConditionOut, eqa.ConditionIn, eqa.DueDate FROM dbo.Employees e LEFT JOIN dbo.Emails em ON em.EmployeeID = e.id LEFT JOIN dbo.JobTitles jt ON e.JobTitleID = jt.id LEFT JOIN Phones p ON p.EmployeeID = e.id LEFT JOIN dbo.Departments d ON e.DepartmentID = d.id LEFT JOIN dbo.EmployeeStatus es ON e.StatusID = es.id LEFT JOIN dbo.EmployeeCitationType ecitt ON e.id = ecitt.EmployeeID LEFT JOIN dbo.CitationTypes cit ON ecitt.CitationTypeID = cit.id LEFT JOIN dbo.EmployeeCertificationType ecert ON e.id = ecert.EmployeeID LEFT JOIN dbo.CertificationType cet ON ecert.NameID = cet.id LEFT JOIN EquipmentAssignments eqa ON eqa.EmployeeID = e.id LEFT JOIN Equipment eq ON eqa.EquipmentID = eq.id" ; var employees = new Dictionary <int, EmployeeModel>(); await connection.QueryAsync <EmployeeModel> (sql, new[] { typeof(EmployeeModel), typeof(EmailModel), typeof(TitleModel), typeof(PhoneModel), typeof(DepartmentModel), typeof(EmployeeStatusModel), typeof(CitationModel), typeof(CertificationModel), typeof(EquipmentAssignmentRecordModel) } , obj => { EmployeeModel employeeModel = obj[0] as EmployeeModel; EmailModel emailModel = obj[1] as EmailModel; TitleModel titleModel = obj[2] as TitleModel; PhoneModel phoneModel = obj[3] as PhoneModel; DepartmentModel departmentModel = obj[4] as DepartmentModel; EmployeeStatusModel statusModel = obj[5] as EmployeeStatusModel; CitationModel citationModel = obj[6] as CitationModel; CertificationModel certificationModel = obj[7] as CertificationModel; EquipmentAssignmentRecordModel equipmentAssignmentRecord = obj[8] as EquipmentAssignmentRecordModel; //employeemodel EmployeeModel employeeEntity = new EmployeeModel(); if (!employees.TryGetValue(employeeModel.ID, out employeeEntity)) { employees.Add(employeeModel.ID, employeeEntity = employeeModel); } //list<emailmodel> if (employeeEntity.Emails == null) { employeeEntity.Emails = new ObservableCollection <EmailModel>(); } if (emailModel != null) { if (!employeeEntity.Emails.Any(x => x.ID == emailModel.ID)) { employeeEntity.Emails.Add(emailModel); } } //phonemodel if (employeeEntity.Phones == null) { employeeEntity.Phones = new ObservableCollection <PhoneModel>(); } if (phoneModel != null) { if (!employeeEntity.Phones.Any(x => x.ID == phoneModel.ID)) { employeeEntity.Phones.Add(phoneModel); } } //title if (employeeEntity.JobTitle == null) { if (titleModel != null) { employeeEntity.JobTitle = titleModel; } } //department if (employeeEntity.Department == null) { if (departmentModel != null) { employeeEntity.Department = departmentModel; } } //status if (employeeEntity.JobStatus == null) { if (statusModel != null) { employeeEntity.JobStatus = statusModel; } } //citation if (employeeEntity.Citations == null) { employeeEntity.Citations = new ObservableCollection <CitationModel>(); } if (citationModel != null) { if (!employeeEntity.Citations.Any(x => x.ID == citationModel.ID)) { employeeEntity.Citations.Add(citationModel); } } //certification if (employeeEntity.Certifications == null) { employeeEntity.Certifications = new ObservableCollection <CertificationModel>(); } if (certificationModel != null) { if (!employeeEntity.Certifications.Any(x => x.ID == certificationModel.ID)) { employeeEntity.Certifications.Add(certificationModel); } } //equipment record if (employeeEntity.EquipmentAssignments == null) { employeeEntity.EquipmentAssignments = new ObservableCollection <EquipmentAssignmentRecordModel>(); } if (equipmentAssignmentRecord != null) { if (!employeeEntity.EquipmentAssignments.Any(x => x.ID == equipmentAssignmentRecord.ID)) { employeeEntity.EquipmentAssignments.Add(equipmentAssignmentRecord); } } return(employeeEntity); });; var result = employees.Values.ToList(); ObservableCollection <EmployeeModel> employeeCollection = new ObservableCollection <EmployeeModel>(result); return(employeeCollection); } }