private void JobTypesListView_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { try { ListView l = (ListView)sender; job_type_details jtd =(job_type_details) l.SelectedItem; //show the employee details DB1 = new DBManager(); this.JobTypeEmployeeListView.ItemsSource = DB1.GetEmployees("SELECT a.* from employees a , job_description b , job_type c WHERE a.employee_id = b.employee_id AND b.job_type_id = c. job_type_id AND c.job_name = '" + jtd.job_name + "'"); } catch { } }
private void AssignProjectEmployeeAssignButton_Click(object sender, RoutedEventArgs e) { try { // check for empty value CheckForEmpty(this.AssignProjectEmployeeGrid); if (this.textboxstatus == false) { MessageBox.Show("A field has not been entered"); textboxstatus = false; return; } } catch { } try { // get the details of employee and project DB1 = new DBManager(); projects prj = (projects)DB1.GetProjects("SELECT * FROM projects where project_name = '" + this.AssignProjectEmployeeProjectNameTextBox.Text + "'").First(); employees emp = (employees)DB1.GetEmployees("SELECT * FROM employees WHERE employee_name = '" + this.AssignProjectEmployeeEmployeeNameComboBox.SelectedItem.ToString() + "'").First(); Container c = new Container(); c._project_employee_allocation = new project_employee_allocation(); c._project_employee_allocation.employee_id = emp.employee_id; c._project_employee_allocation.project_id = prj.project_id; if (DB1.InsertValue(c, Constants.Project_Employee_Allocation)) { MessageBox.Show("Employee allocated"); EmptyAllfields(this.AssignProjectEmployeeGrid); RefreshContainer(); } } catch { } }
private void UpdateTaskTaskNameTextBox_TextChanged(object sender, RoutedEventArgs e) { try { // get a list of all project with same name DB1 = new DBManager(); Debug.WriteLine("SELECT a.* FROM tasks a , projects b WHERE a.project_id = b.project_id AND a.task_name = '" + this.UpdateTaskTaskNameTextBox.Text +" AND b.project_name = '" + this.UpdateTaskProjectNameTextBox.Text + "'"); task t = DB1.GetTasks("SELECT a.* FROM tasks a , projects b WHERE a.project_id = b.project_id AND a.task_name = '" + this.UpdateTaskTaskNameTextBox.Text + "' AND b.project_name = '" + this.UpdateTaskProjectNameTextBox.Text + "'").First(); // fill the records this.UpdateTaskStartDatePicker.SelectedDate = t.start_date; this.UpdateTaskDeadlineDatePicker.SelectedDate = t.end_date; this.UpdateTaskForemanTextBox.Text = DB1.GetEmployees("select a.* from employees a , tasks b where a.employee_id = b.employee_id AND b.task_id = " + t.task_id).First().employee_name.ToString(); this.UpdateTaskBudgetTextBox.Text = t.budget.ToString(); } catch { } }
private void UpdateTaskCreateButton_Click(object sender, RoutedEventArgs e) { try { // get id of the task DB1 = new DBManager(); task t = DB1.GetTasks("SELECT a.* FROM tasks a , projects b WHERE a.project_id = b.project_id AND a.task_name = '" + this.UpdateTaskTaskNameTextBox.Text + "' AND b.project_name = '" + this.UpdateTaskProjectNameTextBox.Text + "'").First(); // fill the records t.start_date = (DateTime) this.UpdateTaskStartDatePicker.SelectedDate; t.end_date = (DateTime) this.UpdateTaskDeadlineDatePicker.SelectedDate; t.employee_id = DB1.GetEmployees("SELECT * from employees where employee_name = '" + this.UpdateTaskForemanTextBox.Text + "'").First().employee_id; t.budget = Convert.ToInt32(this.UpdateTaskBudgetTextBox.Text); if (DB1.UpdateTask(t)) { MessageBox.Show("Task has been updated"); EmptyAllfields(this.UpdateTasksGrid); Initialization(); } } catch { } }
private void AssignProjectEmployeeJobTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { // get a list of employees who fit the description DB1 = new DBManager(); List<employees> em = DB1.GetEmployees("SELECT a.* FROM employees a , job_description b , job_type c WHERE a.employee_id = b.employee_id AND b.job_type_id = c.job_type_id AND c.job_name = '" + this.AssignProjectEmployeeJobTypeComboBox.SelectedItem.ToString() + "'"); Debug.WriteLine("SELECT a.* FROM employees a , job_description b , job_type c WHERE a.employee_id = b.employee_id AND b.job_type_id = c.job_type_id AND c.job_name = '" + this.AssignProjectEmployeeJobTypeComboBox.SelectedItem.ToString() + "'"); this.AssignProjectEmployeeEmployeeNameComboBox.ItemsSource = (List<string>)(from item in em select item.employee_name).ToList(); } catch { } }
private void UpdateEmployeeEmployeeNameComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { DB1 = new DBManager(); employees emp = DB1.GetEmployees("SELECT * from employees where employee_name = '" + ((ComboBox)sender).SelectedItem.ToString() + "'").First(); this.UpdateEmployeeNameTextBox.Text= emp.employee_name.ToString(); this.UpdateEmployeeContactNumberTextBox.Text = emp.employee_contact_number.ToString(); } catch { } }
private static Request LabourerRequestHander(Request req) { try { LabourerRequest lr = JsonConvert.DeserializeObject<LabourerRequest>(req.content); switch (req.purpose) { case Constants.New_Labourer: //inform the user MessageBoxResult mr = MessageBox.Show("A request has been made to register a new labourer proceed" ,"Labourer registration" , MessageBoxButton.YesNo); if(mr == MessageBoxResult.No) { return null; } Container c = new Container(); c._labourers = new labourers(); c._project_labour_allocation = new project_labour_allocation(); // insert a new value to the labourers table c._labourers.national_id = lr.national_id; c._labourers.labourer_id = lr.labourer_id; c._labourers.labourer_name = lr.labourer_name; c._labourers.labourer_contact = lr.labourer_contact; DB1 = new DBManager(); if (DB1.InsertValue(c, Constants.Labourers)) { MessageBox.Show("the labourer has been registered"); } // get the derived labourer id //allocate the registered labourer c._project_labour_allocation.project_id = lr.project_id; c._project_labour_allocation.labourer_id = DB1.GetLabourers("SELECT * FROM labourers WHERE national_id = '" + lr.national_id + "'").First().labourer_id; if (DB1.InsertValue(c, Constants.Project_Labour_Allocation)) { MessageBox.Show("the labourer has been registered to the project"); } break; case Constants.Labourers_List: // return the list of labourers to the foreman // DB1 = new DBManager(); c = new Container(); c._labourerslist = new List<labourers>(); c._labourerslist = DB1.GetLabourers("SELECT a.* FROM labourers a , project_labour_allocation b WHERE a.labourer_id = b.labourer_id AND b.project_id = " + lr.project_id + ""); Debug.WriteLine("SELECT a.* FROM labourers a , project_labour_allocation b WHERE a.labourer_id = b.labourer_id AND b.project_id = " + lr.project_id + ""); c._employeeslist = new List<employees>(); c._employeeslist = DB1.GetEmployees("SELECT a.* FROM employees a , project_employee_allocation b WHERE a.employee_id = b.employee_id AND b.project_id = " + lr.project_id + ""); Debug.WriteLine("SELECT a.* FROM employees a , project_employee_allocation b WHERE a.employee_id = b.employee_id AND b.project_id = " + lr.project_id + ""); //c._employees_list = DB1.GetLabourers() req.content = JsonConvert.SerializeObject(c); req.category = Constants.Labourers; req.purpose = Constants.Labourers_List; break; case Constants.Submit_Work_Day: DB1 = new DBManager(); c = JsonConvert.DeserializeObject<Container>(req.content); foreach (labourers labour in c._labourerslist) { // get the project allocation id where the labourer id is entered c._project_labour_working_day = new project_labour_working_day(); c._project_labour_working_day.project_labour_allocation_id = DB1.GetProjectLabourAllocation("SELECT a.* FROM project_labour_allocation a , labourers b WHERE a.labourer_id = b.labourer_id AND b.labourer_id = " + labour.labourer_id + "").First().project_labour_allocation_id; c._project_labour_working_day.working_date = DateTime.Now.Date; if(!DB1.InsertValue(c , Constants.Project_Labour_Working_Day)) { MessageBox.Show("labourer not entered"); } } foreach (employees emp in c._employeeslist) { c._project_employee_working_day = new project_employee_working_day(); c._project_employee_working_day.project_employee_allocation_id = DB1.GetProjectEmployeeAllocation("SELECT a.* FROM project_employee_allocation a , employees b WHERE a.employee_id = b.employee_id AND b.employee_id = " + emp.employee_id + "").First().project_employee_allocation_id; c._project_employee_working_day.working_date = DateTime.Now.Date; if (!DB1.InsertValue(c, Constants.Project_employee_Working_Day)) { MessageBox.Show("employee not entered"); } } MessageBox.Show("data entered"); break; } return req; } catch { return null ; } }