Ejemplo n.º 1
0
        // create project (edit mode)
        public frmCreateProject(ProjectManagerDB PM, int projectID, ref Tuple<string, string, DateTime, DateTime, DateTime, bool> project)
        {
            InitializeComponent();
            this.PM = PM;

            txtNewProjectName.Text = project.Item1;
            txtNewProjectDesc.Text = project.Item2;
            dtProjectStart.Value = project.Item3;
            dtProjectEnd.Value = project.Item5;
            cbOpenEnd.Checked = project.Item6;

            this.Text = "Updating Project";

            btnCreateProject.Text = "Update Project";
                
            btnCreateProject.Click += new EventHandler(delegate(object sender, EventArgs e)
            {
                try
                {
                    string pName = txtNewProjectName.Text.ToString();
                    string pDesc = txtNewProjectDesc.Text.ToString();

                    if (string.IsNullOrWhiteSpace(pName) || string.IsNullOrWhiteSpace(pDesc))
                    {
                        throw new Exception("Please add a name and description to this project.");

                    }

                    DateTime ps = dtProjectStart.Value;
                    DateTime pu = DateTime.Today;
                    DateTime pe = dtProjectEnd.Value;

                    if (pe < ps)
                    {
                        throw new Exception("the deadline can't be earlier than the start time.");
                    }

                    bool phd = cbOpenEnd.Checked;
                    PM.UpdateProject(projectID, pName, pDesc, ps, pu, pe, phd);
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            });

           
        }