コード例 #1
0
 public CreatingTaskForm(decimal id)
 {
     this.context = new PmContext();
     InitializeComponent();
     currentId      = id;
     currentProject = context.PROJECTS.Find(currentId);
 }
コード例 #2
0
        public ProjectDetailsForm(string id)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            this.context = new PmContext();
            InitializeComponent();
            currentProjectId              = decimal.Parse(id);
            currentProject                = context.PROJECTS.Find(currentProjectId);
            StatusDdl.Enabled             = false;
            ClientTb.Enabled              = false;
            ClientTb.Text                 = currentProject.CLIENT.CLIENT_NAME;
            ProjectClientComboBox.Visible = false;
            RegisterNewClientBtn.Visible  = false;
            CancelNewClientBtn.Visible    = false;
        }
コード例 #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();
        }