Beispiel #1
0
        private void btnAddProject_Click(object sender, EventArgs e)
        {
            ProjectForm form            = new ProjectForm();
            var         listofEmployees = managementService.GetEmployees(0, 0).Select(x => new ManagerComboBoxItem(x.Name + " " + x.LastName + "(" + x.Id + ")", x.Id)).ToList();

            form.comboManager.Items.AddRange(listofEmployees.ToArray());
            if (DialogResult.OK == form.ShowDialog(this))
            {
                var           managerText   = form.comboManager.Text;
                var           manager       = listofEmployees.Where(t => t.ToString() == managerText).SingleOrDefault();
                CreateProject createProject = new CreateProject(form.textCode.Text, form.textName.Text, manager == null ? 0 : (int)manager.Value, form.comboType.ValueMember == "W" ? 0 : 1);
                var           project       = managementService.CreateProject(createProject);
                UpdateGridProjects();
            }
        }
Beispiel #2
0
        private void btnProjectEdit_Click(object sender, EventArgs e)
        {
            ProjectForm form            = new ProjectForm();
            var         listofEmployees = managementService.GetEmployees(0, 0).Select(x => new ManagerComboBoxItem(x.Name + " " + x.LastName + "(" + x.Id + ")", x.Id)).ToList();

            form.comboManager.Items.AddRange(listofEmployees.ToArray());
            var selected  = gridProject.SelectedRows[0];
            int projectId = int.Parse(selected.Cells[0].Value.ToString());
            var toEdit    = managementService.GetProject(projectId.ToString());

            form.textId.Text    = toEdit.Id.ToString();
            form.textName.Text  = toEdit.Name;
            form.textCode.Text  = toEdit.Code;
            form.comboType.Text = toEdit.Type == 0 ? "W" : "B";
            var projectManager = managementService.GetProjectManager(projectId.ToString());

            form.comboManager.Text = projectManager == null ? "" : listofEmployees.Where(x => (int)x.Value == projectManager.Id).Single().ToString();
            if (DialogResult.OK == form.ShowDialog(this))
            {
                Project updateProject = new Project(int.Parse(form.textId.Text), form.textCode.Text, form.textName.Text, form.comboType.Text == "W" ? 0 : 1);
                var     branch        = managementService.UpdateProject(form.textId.Text, updateProject);
                UpdateGridProjects();
            }
        }