コード例 #1
0
 private void buttonClear_Click(object sender, EventArgs e)
 {
     ProjectIdTextBox.Clear();
     ProjectNameTextBox.Clear();
     ProjectDescriptionTextBox.Clear();
     NewClientTb.Clear();
     PayPerHourTextBox.Clear();
     ProjectStartDateDatePicker.Value = DateTime.Now;
     ProjectEndDatePicker.Value       = DateTime.Now;
 }
コード例 #2
0
        internal void RefreshTabProject()
        {
            var customersOnProject = new List <CustomerInProject>();

            var ProjectStatus = new List <string>();

            int rowIndex = 0;

            customerIDList.Clear();
            ProjectDataGridView.Rows.Clear();
            foreach (Project.ProjestStatus status in Enum.GetValues(typeof(Project.ProjestStatus)))
            {
                ProjectStatus.Add(status.ToString());
            }

            for (int i = 0; i < manager.Customers.Count; i++)
            {
                var customerProject = new CustomerInProject(manager.Customers[i].Name.ToString() + " " + manager.Customers[i].Surname.ToString(), manager.Customers[i].CustomerID);
                customersOnProject.Add(customerProject);
            }
            ProjectCustomerComboBox.DataSource    = customersOnProject;
            ProjectCustomerComboBox.DisplayMember = "CustomerName";
            ProjectCustomerComboBox.ValueMember   = "CustomerID";
            StatusComboBox.DataSource             = ProjectStatus;
            for (int i = 0; i < manager.Projects.Count; i++)
            {
                ProjectDataGridView.Rows.Add();
                ProjectDataGridView[ProjectIDColumn.Index, rowIndex].Value   = manager.Projects[i].ProjectID.ToString();
                ProjectDataGridView[ProjectNameColumn.Index, rowIndex].Value = manager.Projects[i].Name.ToString();
                ProjectDataGridView[ProjectDataColumn.Index, rowIndex].Value = manager.Projects[i].DateAgreement.ToString(DateFomat).ToString();
                ProjectDataGridView[ProjectCostColumn.Index, rowIndex].Value = manager.Projects[i].Cost.ToString();
                ProjectStatusColumn.DataSource = ProjectStatus;
                ProjectDataGridView[ProjectStatusColumn.Index, rowIndex].Value = manager.Projects[i].Status.ToString();
                ProjectCustomerColumn.DataSource    = customersOnProject;
                ProjectCustomerColumn.DisplayMember = "CustomerName";
                ProjectCustomerColumn.ValueMember   = "CustomerID";
                ProjectDataGridView[ProjectCustomerColumn.Index, rowIndex].Value = manager.Projects[i].CustomerID;
                ProjectDataGridView[EmployeeCountColumn.Index, rowIndex].Value   = manager.Projects[i].EmployeesID.Count.ToString();
                rowIndex++;
            }
            ProjectDateTimePicker.Value = DateTime.Now;
            ProjectNameTextBox.Clear();
            ProjectCostTextBox.Clear();
            ProjectCustomerComboBox.Text         = "";
            ProjectCustomerComboBox.SelectedText = "Choise...";
            StatusComboBox.Text         = "";
            StatusComboBox.SelectedText = "Choise...";
        }
コード例 #3
0
        private void buttonCreate_Click(object sender, EventArgs e)
        {
            if (!IsValidInput(ProjectIdTextBox) ||
                !IsValidInput(PayPerHourTextBox) ||
                !IsNotNull(ProjectNameTextBox) ||
                !IsNotNull(ProjectDescriptionTextBox) ||
                !IsValidSelection(ProjectClientComboBox)
                )
            {
                // MessageBox.Show("Грешка");
                return;
            }
            if (ProjectStartDateDatePicker.Value.Date < DateTime.Now.Date ||
                ProjectEndDatePicker.Value.Date < DateTime.Now.Date ||
                ProjectEndDatePicker.Value < ProjectStartDateDatePicker.Value)
            {
                MessageBox.Show("Невалидна дата!");
                return;
            }
            if (RegisterNewClientBtn.Text == "Запази клиент")
            {
                MessageBox.Show("Моля запазете регистрирането на клиент!");
                return;
            }

            var projectId = decimal.Parse(ProjectIdTextBox.Text);

            if (context.PROJECTS.Any(o => o.PROJECT_ID == projectId))
            {
                MessageBox.Show("Вече съществува проект с този код!");
                return;
            }
            if (context.PROJECTS.Any(o => o.PROJECT_NAME == ProjectNameTextBox.Text))
            {
                MessageBox.Show("Вече съществува проект с това име!");
                return;
            }
            var project = new PROJECT();

            project.PROJECT_ID           = projectId;
            project.PROJECT_NAME         = ProjectNameTextBox.Text;
            project.PROJECT_DESCRIPTION  = ProjectDescriptionTextBox.Text;
            project.CLIENT_ID            = decimal.Parse(ProjectClientComboBox.SelectedValue.ToString()); //TODO: FIX
            project.PROJECT_BEGIN        = ProjectStartDateDatePicker.Value;
            project.PROJECT_END          = ProjectEndDatePicker.Value;
            project.PROJECT_STATUS       = Constants.ProjectStatusNewId;
            project.PROJECT_PAY_PER_HOUR = decimal.Parse(PayPerHourTextBox.Text);

            context.PROJECTS.Add(project);
            context.SaveChanges();

            MessageBox.Show("Проектът е създаден.");

            ProjectIdTextBox.Clear();
            ProjectNameTextBox.Clear();
            ProjectDescriptionTextBox.Clear();
            ProjectClientComboBox.SelectedIndex = -1;
            ProjectStartDateDatePicker.Value    = DateTime.Now.Date;
            ProjectEndDatePicker.Value          = DateTime.Now.Date;
            PayPerHourTextBox.Clear();
        }