Example #1
0
        private void AssignEmployeeJobRegisterButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                CheckForEmpty(this.AssignEmplyeeJobGrid);
                if (this.textboxstatus == false)
                {
                    MessageBox.Show("A field has not been entered");
                    textboxstatus = false;
                    return;
                }

                // look for fields in the tables
                AllContainer = new Container();
                DB1 = new DBManager();
                AllContainer = DB1.GetWholeEntity();

                var result = from item in AllContainer._employeeslist
                             where item.employee_name.ToLower().Contains(this.AssignEmployeejobEmployeeNameTextbox.Text.ToLower())
                             select item;
                // get the id of the first value found
                employees emp = (employees)result.ToList().First();

                var rs = from item in AllContainer._job_typelist
                         where item.job_name.ToLower().Contains(this.AssignEmployeeJobJobNameTextBox.Text.ToLower())
                         select item;
                job_type job = (job_type)rs.ToList().First();

                // get the values from the two entities so as to merge them
                Container Entity1 = new Container();
                Entity1._job_description.employee_id = emp.employee_id;
                Entity1._job_description.job_type_id = job.job_type_id;
                if (DB1.InsertValue(Entity1, Constants.Job_Description))
                {
                    MessageBox.Show("the job description has been registered");
                    EmptyAllfields(this.AssignEmplyeeJobGrid);
                    RefreshContainer();
                }
            }
            catch { }
        }
Example #2
0
        private void AssignTaskMaterialsAssignButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                RefreshContainer();
                // check for empty value
                CheckForEmpty(this.AssignTaskMaterialsGrid);
                if (this.textboxstatus == false)
                {
                    MessageBox.Show("A field has not been entered");
                    textboxstatus = false;
                    return;
                }
                // check if the material already exists
                if (this.AllContainer._employeeslist.Count == 0)
                {
                    RefreshContainer();
                }

                // get the detials of the assignment
                Container Entity1 = new Container();
                Entity1._task_materials = new task_materials();

                //get the project id
                var projectresult = from item in DB1.GetProjects("")
                                    where ((item.project_name).Contains(this.AssignTaskMaterialsProjectNameTextBox.Text))
                                    select item;
                int pid = projectresult.ToList().First().project_id;

                // get the task id
                var taskresult = from item in AllContainer._tasklist
                                 where (  (item.task_name.ToLower().Contains(this.AssignTaskMaterialsTaskNameTextBox.Text.ToLower())  ) && (item.project_id == pid)  )
                                 select item;
                if (taskresult.Count() > 0)
                {
                    // get the first id
                    Entity1._task_materials.task_id = taskresult.ToList().First().task_id;
                }
                else
                {
                    return;
                }

                //get the material id
                var materialresult = from item in AllContainer._materialslist
                                     where (item.material_name.ToLower().Contains(this.AssignTaskMaterialsMaterialNameTextBox.Text.ToLower()))
                                     select item;
                if (materialresult.Count() > 0)
                {
                    Entity1._task_materials.material_id = materialresult.ToList().First().material_id;
                }
                else
                {
                    return;
                }

                // get the type of assignment the administrator wishes to do
                MessageBoxResult r = MessageBox.Show("Do you wish to assign from stock", "Assign materials", MessageBoxButton.YesNoCancel);
                if (r == MessageBoxResult.Yes)
                {
                    // remove the values from the stock and update it
                    Entity1._task_materials.unit_buying_price = 0;

                    //update the stock
                    stock_materials s = DB1.GetStock("SELECT * FROM stock_materials WHERE material_id = " + Entity1._task_materials.material_id).First();
                    s.quanitity -= Convert.ToInt32(this.AssignTaskMaterialsQuantityTextBox.Text);
                    DB1.UpdateValue(s);
                }
                else if (r == MessageBoxResult.No)
                {
                    Entity1._task_materials.unit_buying_price = Convert.ToInt32(this.AssignTaskMaterialsUnitBuyingPriceTextBox.Text);
                }
                else if (r == MessageBoxResult.Cancel)
                {
                    return;
                }

                Entity1._task_materials.quantity = Convert.ToInt32(this.AssignTaskMaterialsQuantityTextBox.Text);
                Entity1._task_materials.date_allocated = DateTime.Now;

                DB1 = new DBManager();
                if (DB1.InsertValue(Entity1, Constants.Task_Materials))
                {
                    MessageBox.Show("the materials have been allocated");
                    EmptyAllfields(this.AssignTaskMaterialsGrid);
                    RefreshContainer();
                }

            }
            catch { }
        }
Example #3
0
        private static Request MaterialRequestHandler(Request req)
        {
            try
            {
                //switch based on the purpose
                switch (req.purpose)
                {
                    case Constants.Request_Material:
                        // show the input to the user
                        MessageBox.Show("A request has been made for\n " + (JsonConvert.DeserializeObject<MaterialRequest>(req.content).MaterialName) + "\n quantity " + (JsonConvert.DeserializeObject<MaterialRequest>(req.content).quantity) , "Field Request", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.None);
                        //Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.Background, new Action( () => ) );
                        //Application.Current.Dispatcher.Invoke(new Action(() => FillRequests));

                        break;
                    case Constants.Remainder_Materials:
                        //show the user the request
                        MessageBox.Show("There is a remainder of \n " + (JsonConvert.DeserializeObject<MaterialRequest>(req.content).MaterialName) + "\n in " + (JsonConvert.DeserializeObject<RemainderRequest>(req.content).quantity) + "amount", "Field Request", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.None);
                        DB1 = new DBManager();
                        if (DB1.UpdateValue((JsonConvert.DeserializeObject<RemainderRequest>(req.content).quantity), (JsonConvert.DeserializeObject<MaterialRequest>(req.content).MaterialName)))
                        {
                            MessageBox.Show("stock has been updated");
                        }
                        break;
                }
            }
            catch { }

            return req;
        }
Example #4
0
        private void RegisterMaterialCreateButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // check for empty value
                CheckForEmpty(this.RegisterMaterialsGrid);
                if (this.textboxstatus == false)
                {
                    MessageBox.Show("A field has not been entered");
                    textboxstatus = false;
                    return;
                }

                // get the values from the fields
                Container Entity1 = new Container();
                Entity1._materials.material_name = this.RegisterMaterialMaterialNameTextBox.Text;
                Entity1._materials.measuring_unit = this.RegisterMaterialMeasuringUnitTextBox.Text;
                DB1 = new DBManager();
                if (DB1.InsertValue(Entity1, Constants.Materials))
                {
                    MessageBox.Show("has been successfully registered");
                    EmptyAllfields(this.RegisterMaterialsGrid);
                    RefreshContainer();
                }
            }
            catch { }
        }
Example #5
0
 private void RegisterEmployeeButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         // check for empty value
         CheckForEmpty(this.RegisterEmployeeGrid);
         if (this.textboxstatus == false)
         {
             MessageBox.Show("A field has not been entered");
             textboxstatus = false;
             return;
         }
     }
     catch
     { }
     try
     {
         // get the name of the employee
         Container Entity1 = new Container();
         Entity1._employees.employee_id = 0;
         Entity1._employees.employee_name = this.RegisterEmployeeNameTextBox.Text;
         Entity1._employees.employee_contact_number = this.RegisterEmployeeContactNumberTextBox.Text;
         DBManager DB1 = new DBManager();
         if (DB1.InsertValue(Entity1, Constants.employees))
         {
             MessageBox.Show(this.RegisterEmployeeNameTextBox.Text + " has been successfully registered");
             EmptyAllfields(this.RegisterEmployeeGrid);
             RefreshContainer();
         }
         else
         {
             MessageBox.Show("There was a problem entering data to the database");
             EmptyAllfields(this.RegisterEmployeeGrid);
             RefreshContainer();
         }
     }
     catch { }
 }
Example #6
0
        private void RefreshContainer()
        {
            DBManager DB1 = new DBManager();

            this.AllContainer = DB1.GetWholeEntity();
        }
Example #7
0
        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 { }
        }
Example #8
0
        private void CreateProject_Click(object sender, RoutedEventArgs e)
        {
            // get all the values from the
            // check if any of the values is left empty
            try
            {

                // check for empty ness
                CheckForEmpty(this.RegisterProjectGrid);
                if (this.textboxstatus == false)
                {
                    MessageBox.Show("A field has not been entered");
                    textboxstatus = false;
                    return;
                }

                try
                {

                    Container Entity1 = new Container();
                    Entity1._project.project_id = 0;
                    Entity1._project.project_name = this.RegisterProjectProjectNameTextBox.Text;
                    Entity1._project.location = this.RegisterProjectLocationTextBox.Text;
                    Entity1._project.description = this.RegisterProjectDescriptionTextBox.Text;
                    Entity1._project.end_date = (DateTime)this.RegisterProjectEndDatePicker.SelectedDate;
                    Entity1._project.start_date = (DateTime)this.RegisterProjectStartDatePicker.SelectedDate;

                    // get the client
                    try
                    {
                        Container container1 = new Container();
                        DB1 = new DBManager();
                        container1 = DB1.GetWholeEntity();
                        List<clients> cc = container1._clientlist;
                        var result = from item in cc
                                     where item.client_name.ToLower().Contains(this.RegisterProjectClientTextBox.Text.ToLower())
                                     select item;

                        if (result != null)
                        {
                            Entity1._project.client_id = Convert.ToInt32(((List<clients>)result.ToList()).First().client_id);
                        }

                    }
                    catch { }

                    if (DB1.InsertValue(Entity1, Constants.Project))
                    {
                        MessageBox.Show("The Project has been registered successfully");
                        EmptyAllfields(this.RegisterProjectGrid);
                    }
                }
                catch { }

            }
            catch { }
        }
Example #9
0
 private void TasksSummary()
 {
     try
     {
         DB1 = new DBManager();
         this.RunningTasksListView.ItemsSource = DB1.GetTasks("SELECT * FROM tasks WHERE start_date < '" + DateTime.Now.ToString("yyyy'-'MM'-'dd") + "' AND end_date > '" + DateTime.Now.ToString("yyyy'-'MM'-'dd") + "'");
         Debug.WriteLine("SELECT * FROM tasks WHERE start_date < '" + DateTime.Now.ToString("yyyy'-'MM'-'dd") + "' AND end_date > '" + DateTime.Now.ToString("yyyy'-'MM'-'dd") + "'");
         this.AllTasksDatagrid.ItemsSource = DB1.GetRawData("SELECT a.task_name AS 'ALL TASKS'  , b.project_name  FROM tasks a , projects b WHERE a.project_id = b.project_id").DefaultView;
     }
     catch { }
 }
Example #10
0
 private void TasksListViewItemClicked(object sender, RoutedEventArgs e)
 {
     try
     {
         // get the task clicked
         ListView l = (ListView)sender;
         task t = (task)l.SelectedItem;
         DB1 = new DBManager();
         this.TaskDetailsListView.ItemsSource = null;
         this.TaskDetailsListView.ItemsSource = DB1.GetTaskDetails("SELECT a.* , b.project_name , c.employee_name , TIMESTAMPDIFF(DAY, a.start_date, a.end_date) AS duration FROM tasks a , projects b , employees c WHERE a.project_id = b.project_id AND a.employee_id = c.employee_id AND a.task_id = " + t.task_id);
         this.TaskResourcesListView.ItemsSource = DB1.GetProjectMaterials("SELECT a.*, d.*, SUM(b.quantity) AS quantity, SUM(b.quantity * b.unit_buying_price) AS Cost FROM materials a , task_materials b , tasks c , projects d WHERE a.material_id = b.material_id AND b.task_id = c.task_id AND c.project_id = d.project_id AND c.task_id = " + t.task_id + " Group BY a.material_name");
         Debug.WriteLine("SELECT a.*, d.*, SUM(b.quantity) AS quantity, SUM(b.quantity * b.unit_buying_price) AS Cost FROM materials a , task_materials b , tasks c , projects d WHERE a.material_id = b.material_id AND b.task_id = c.task_id AND c.project_id = d.project_id AND c.task_id = " + t.task_id + " Group BY a.material_name");
     }
     catch { }
 }
Example #11
0
        private void AssignProjectEmployeeEmployeeNameComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                // get a list of all projects the employee is in

                DB1 = new DBManager();
                this.CommitedProjectsListView.ItemsSource = DB1.GetProjects("SELECt a.* from projects a , project_employee_allocation b , employees c where a.project_id = b.project_id AND b.employee_id = c.employee_id and c.employee_name = '" + ((ComboBox)sender).SelectedItem.ToString() + "'");

            }
            catch { }
        }
Example #12
0
 private void ReportsTasksCombobox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         DB1 = new DBManager();
         ComboBoxItem c = (ComboBoxItem) ((ComboBox)sender).SelectedItem;
         switch (c.Content.ToString().ToLower())
         {
             case "all tasks":
                 this.ReportsDataGrid.ItemsSource = DB1.GetRawData("SELECT * FROM tasks").DefaultView;
                 break;
             case "running tasks":
                 this.ReportsDataGrid.ItemsSource = DB1.GetRawData("SELECT * FROM tasks WHERE start_date < '" + DateTime.Now.ToString("yyyy'-'MM'-'dd") + "' AND end_date > '" + DateTime.Now.ToString("yyyy'-'MM'-'dd") + "'").DefaultView;
                 break;
             case "resource allocation":
                 this.ReportsDataGrid.ItemsSource = DB1.GetRawData("SELECT a.task_name  , b.material_name , c.quantity , c.unit_buying_price , (c.quantity * c.unit_Buying_price) AS 'cost' , c.date_allocated AS 'Date' FROM tasks a , materials b , task_materials c  WHERE c.material_id = b.material_id  AND c.task_id = a.task_id ").DefaultView;
                 break;
             case "resource expenses":
                 this.ReportsDataGrid.ItemsSource = DB1.GetRawData("SELECT c.task_name, a.material_name,  SUM(b.quantity) AS quantity, SUM(b.quantity * b.unit_buying_price) AS Cost FROM materials a , task_materials b , tasks c , projects d WHERE a.material_id = b.material_id AND b.task_id = c.task_id AND c.project_id = d.project_id  Group BY c.task_name, a.material_name").DefaultView;
                 break;
         }
     }
     catch { }
 }
Example #13
0
 private void ReportsProjectsCombobox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         DB1 = new DBManager();
         ComboBoxItem c = (ComboBoxItem) ((ComboBox)sender).SelectedItem;
         switch (c.Content.ToString().ToLower())
         {
             case "all projects":
                 // get a list of all projects
                 this.ReportsDataGrid.ItemsSource = DB1.GetRawData("SELECT * FROM projects ").DefaultView;
                 break;
             case  "running projects":
                 this.ReportsDataGrid.ItemsSource = DB1.GetRawData("SELECT * FROM projects WHERE start_date < '" + DateTime.Now.ToString("yyyy'-'MM'-'dd") + "' AND end_date > '" + DateTime.Now.ToString("yyyy'-'MM'-'dd") + "'").DefaultView;
                 break;
             case "job allocation":
                 this.ReportsDataGrid.ItemsSource = DB1.GetRawData("SELECT e.project_name , a.job_name , count(b.job_type_id) AS count FROM job_type a , job_description b , employees c , project_employee_allocation d , projects e WHERE a.job_type_id = b.job_type_id AND b.employee_id = c.employee_id AND c.employee_id = d.employee_id AND d.project_id = e.project_id  GROUP BY  e.project_name , a.job_name ").DefaultView;
                 break;
             case "resource expenses":
                 this.ReportsDataGrid.ItemsSource = DB1.GetRawData("SELECT  d.project_name , a.material_name , SUM(b.quantity) AS quantity, SUM(b.quantity * b.unit_buying_price) AS Cost FROM materials a , task_materials b , tasks c , projects d WHERE a.material_id = b.material_id AND b.task_id = c.task_id AND c.project_id = d.project_id  Group BY d.project_name ,  a.material_name").DefaultView;
                 break;
             case "tasks in project":
                 this.ReportsDataGrid.ItemsSource = DB1.GetRawData("SELECT b.project_name , a.* FROM tasks a , projects b WHERE a.project_id = b.project_id" ).DefaultView;
                 break;
         }
     }
     catch { }
 }
Example #14
0
 private void ReportsEmployeesCombobox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
           DB1 = new DBManager();
         ComboBoxItem c = (ComboBoxItem) ((ComboBox)sender).SelectedItem;
         switch (c.Content.ToString().ToLower())
         {
             case "all employees":
                 this.ReportsDataGrid.ItemsSource = DB1.GetRawData("SELECT employee_name , employee_contact_number FROM employees").DefaultView;
                 break;
             case "job descriptions":
                 this.ReportsDataGrid.ItemsSource = DB1.GetRawData("SELECT a.employee_name , a.employee_contact_number , c.job_name FROM employees a , job_description b , job_type c WHERE c.job_type_id = b.job_type_id AND b.employee_id = a.employee_id ").DefaultView;
                 break;
         }
     }
     catch { }
 }
Example #15
0
        private void RegisterTaskCreateButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                RefreshContainer();
                // check for empty value
                CheckForEmpty(this.RegisterTaskGrid);
                if (this.textboxstatus == false)
                {
                    MessageBox.Show("A field has not been entered");
                    textboxstatus = false;
                    return;
                }

                // get the project id
                // check if the material already exists
                if (this.AllContainer._employeeslist.Count == 0)
                {
                    RefreshContainer();
                }

                var result = from item in AllContainer._projectlist
                             where (item.project_name.Contains(this.RegisterTaskProjectNameTextBox.Text))
                             select (item.project_id);
                int p_id = ((List<int>)result.ToList()).First();
                result = from item in AllContainer._employeeslist
                         where (item.employee_name.Contains(this.RegisterTaskForemanTextBox.Text))
                         select (item.employee_id);
                int e_id = ((List<int>)result.ToList()).First();

                Container Entity1 = new Container();
                Entity1._task = new task();
                Entity1._task.task_name = this.RegisterTaskTaskNameTextBox.Text;
                Entity1._task.project_id = p_id;
                Entity1._task.employee_id = e_id;
                Entity1._task.budget = Convert.ToInt32(this.RegisterTaskBudgetTextBox.Text);
                Entity1._task.start_date = (DateTime)this.RegisterTaskStartDatePicker.SelectedDate;
                Entity1._task.end_date = (DateTime)this.RegisterTaskDeadlineDatePicker.SelectedDate;

                //register in database
                DB1 = new DBManager();
                if (DB1.InsertValue(Entity1, Constants.Task))
                {
                    MessageBox.Show("the task has been registered");
                    EmptyAllfields(this.RegisterTaskGrid);
                    Initialization();
                }

            }
            catch { }
        }
Example #16
0
 private void AssignTaskMaterialsMaterialNameTextBox_TextChanged(object sender, RoutedEventArgs e)
 {
     try
     {
         // get the quantity of materials
         DB1 = new DBManager();
         this.AssignTaskMaterialsStockQuantityTextBlock.Text = DB1.GetStock("SELECT b.* , a.material_name FROM materials a ,  stock_materials b WHERE a.material_id = b.material_id AND a.material_name = '" + this.AssignTaskMaterialsMaterialNameTextBox.Text + "'").First().quanitity.ToString();
     }
     catch { }
 }
Example #17
0
        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 { }
        }
Example #18
0
        private void UpdateProjectButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // check for empty ness
                CheckForEmpty(this.UpdateProjectGrid);
                if (this.textboxstatus == false)
                {
                    MessageBox.Show("A field has not been entered");
                    textboxstatus = false;
                    return;
                }
                DB1 = new DBManager();

                Container Entity1 = new Container();
                Entity1._project.project_id = DB1.GetProjects("SELECT * FROM projects WHERE project_name = '" + this.UpdateProjectProjectNameComboBox.SelectedItem.ToString() + "'").First().project_id;
                Entity1._project.project_name = this.UpdateProjectProjectNameTextBox.Text;
                Entity1._project.location = this.UpdateProjectLocationTextBox.Text;
                Entity1._project.description = this.UpdateProjectDescriptionTextBox.Text;
                Entity1._project.end_date = (DateTime)this.UpdateProjectEndDatePicker.SelectedDate;
                Entity1._project.start_date = (DateTime)this.UpdateProjectStartDatePicker.SelectedDate;

                // get the client
                try
                {
                    List<clients> cc = DB1.GetClients("");
                    var result = from item in cc
                                 where item.client_name.ToLower().Contains(this.RegisterProjectClientTextBox.Text.ToLower())
                                 select item;

                    if (result != null)
                    {
                        Entity1._project.client_id = Convert.ToInt32(((List<clients>)result.ToList()).First().client_id);
                    }

                }
                catch { }

                if (DB1.UpdateProject(Entity1._project))
                {
                    MessageBox.Show("Project Successfully updated");
                    EmptyAllfields(this.UpdateProjectGrid);
                    Initialization();
                    //this.UpdateProjectProjectNameComboBox = new ComboBox();
                    //ComboboxPopulating(this.UpdateProjectProjectNameComboBox, null);
                }

            }
            catch { }
        }
Example #19
0
 private void EmployeeSummary()
 {
     try
     {
         // get all the job typesavailable
         DB1 = new DBManager();
         this.JobTypesListView.ItemsSource = DB1.GetJobTypeDetails("");
     }
     catch { }
 }
Example #20
0
 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 { }
 }
Example #21
0
 private void ProjectSummary()
 {
     // get a summary of all data relating to the projects
     try
     {
         // get a list of all running projects
         try
         {
             DB1 = new DBManager();
             this.RunningProjectsListView.ItemsSource = DB1.GetProjects("SELECT * FROM projects WHERE start_date < '" + DateTime.Now.ToString("yyyy'-'MM'-'dd") + "' AND end_date > '" + DateTime.Now.ToString("yyyy'-'MM'-'dd") + "'");
             Debug.WriteLine("SELECT * FROM projects WHERE start_date < '" + DateTime.Now.ToString("yyyy'-'MM'-'dd") + "' AND end_date > '" + DateTime.Now.ToString("yyyy'-'MM'-'dd") + "'");
             ProjectListviewItem_Click(null, null);
             this.ProjectsDatagrid.ItemsSource = DB1.GetRawData("SELECT project_name AS 'ALL PROJECTS' FROM projects ").DefaultView;
         }
         catch { }
     }
     catch { }
 }
Example #22
0
        private void UpdateProjectProjectNameComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                DB1 = new DBManager();
                projects p = DB1.GetProjects("SELECT * FROM projects WHERE project_name = '" + ((ComboBox)sender).SelectedItem.ToString() + "'").First();
                clients c = DB1.GetClients("SELECT a.* FROM clients a , projects b WHERE a.client_id = b.client_id AND a.client_id = " + p.client_id).First();
                Debug.WriteLine("SELECT a.* FROM clients a , projects b WHERE a.client_id = b.client_id AND a.client_id = " + p.client_id);
                //populate fields with values
                this.UpdateProjectProjectNameTextBox.Text = p.project_name;
                this.UpdateProjectDescriptionTextBox.Text = p.description;
                this.UpdateProjectLocationTextBox.Text = p.location;
                this.UpdateProjectStartDatePicker.SelectedDate = p.start_date;
                this.UpdateProjectEndDatePicker.SelectedDate = p.end_date;
                this.UpdateProjectClientTextBox.Text = c.client_name;

            }
            catch { }
        }
Example #23
0
        private void RegisterClientButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {

                try
                {
                    // check for empty value
                    CheckForEmpty(this.RegisterClientGrid);
                    if (this.textboxstatus == false)
                    {
                        MessageBox.Show("A field has not been entered");
                        textboxstatus = false;
                        return;
                    }
                }
                catch
                { }

                // get the name of the client
                Container Entity1 = new Container();
                Entity1._client.client_name = this.RegisterClientNameTextBox.Text;
                Entity1._client.email = this.RegisterClientEmailTextBox.Text;
                Entity1._client.contact = this.RegisterClientEmailTextBox.Text;
                Entity1._client.client_id = 0;
                DBManager DB1 = new DBManager();
                if (DB1.InsertValue(Entity1, Constants.Client))
                {
                    MessageBox.Show("has been successfully registered");
                    EmptyAllfields(this.RegisterClientGrid);
                    RefreshContainer();
                }
            }
            catch { }
        }
Example #24
0
        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 { }
        }
Example #25
0
        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 { }
        }
Example #26
0
        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 { }
        }
Example #27
0
        private void RegisterStockCreateButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // check for empty value
                CheckForEmpty(this.RegisterStockGrid);
                if (this.textboxstatus == false)
                {
                    MessageBox.Show("A field has not been entered");
                    textboxstatus = false;
                    return;
                }

                // check if the material already exists
                if (this.AllContainer._employeeslist.Count == 0)
                {
                    RefreshContainer();
                }

                // get the list of all materials
                var result = from item in AllContainer._materialslist
                             where (item.material_name.ToLower().Contains(this.RegisterStockMaterialNameTextBox.Text))
                             select item;
                if (result.Count() > 0)
                {
                    // get the id of the material
                    int material_id = (from _mat in (List<materials>)result.ToList() select (_mat.material_id)).ToList().First();

                    //find the row with the material id provided
                    var s = from item in AllContainer._stock_materialslist
                            where (item.material_id == material_id)
                            select item;
                    if (s.Count() > 0)
                    {
                        stock_materials stock = ((List<stock_materials>)s.ToList()).First();

                        // change the values of the quantity of the stock
                        stock.quanitity += Convert.ToInt32(this.RegisterStockQuantityTextBox.Text);

                        //update the db

                        if (DB1.UpdateValue(stock))
                        {
                            MessageBox.Show("Stock has been updated");
                        }
                        EmptyAllfields(this.RegisterStockGrid);
                    }
                    else
                    {
                        // create a new row for the material
                        Container Entity1 = new Container();
                        Entity1._stock_materials = new stock_materials();
                        Entity1._stock_materials.material_id = material_id;
                        Entity1._stock_materials.quanitity = Convert.ToInt32(this.RegisterStockQuantityTextBox.Text);
                        DB1 = new DBManager();
                        if (DB1.InsertValue(Entity1, Constants.Stock_Materails))
                        {
                            MessageBox.Show("New value entered successfull");
                            EmptyAllfields(this.RegisterStockGrid);
                            RefreshContainer();
                        }
                    }
                }

            }
            catch { }
        }
Example #28
0
        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 ;
            }
        }