示例#1
0
 protected void btnUpload_Click(object sender, EventArgs e)
 {
     if (FileUpload3.HasFile)
     {
         if (txtFile1.Text.ToString() == "")
         {
             //Add file to text box 1 and session
             Session.Add(Global.Parameters.File3, FileUpload3);
             String tempFile3 = System.IO.Path.GetDirectoryName(System.IO.Path.GetTempFileName().ToString());
             tempFile3 = tempFile3 + "\\" + FileUpload3.FileName.ToString();
             Session.Add(Global.Parameters.tempFile3, tempFile3.ToString());
             FileUpload3.SaveAs(tempFile3);
             txtFile1.Text = FileUpload3.FileName.ToString();
         }
         else
         {
             if (txtFile2.Text.ToString() == "")
             {
                 //Add file to text box 2 and session
                 Session.Add(Global.Parameters.File4, FileUpload3);
                 String tempFile4 = System.IO.Path.GetDirectoryName(System.IO.Path.GetTempFileName().ToString());
                 tempFile4 = tempFile4 + "\\" + FileUpload3.FileName.ToString();
                 Session.Add(Global.Parameters.tempFile4, tempFile4.ToString());
                 FileUpload3.SaveAs(tempFile4);
                 txtFile2.Text = FileUpload3.FileName.ToString();
             }
             else
             {
                 //both files are full display error msg
                 ValidationSummary1.AddErrorMessage("You file limit of 2 has been reached, please delete a file before uploading another. ");
             }
         }
     }
     else
     {
         ValidationSummary1.AddErrorMessage("You must Browse to your file before uploading. ");
     }
 }
示例#2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            CheckBox        chkSelected            = new CheckBox();
            PotentialLesson LL                     = new PotentialLesson();
            bool            panel1controlsAreValid = true;
            bool            panel2controlsAreValid = true;
            bool            subjectMatterValid     = false;
            bool            stagesValid            = false;

            LL.CurrentUser = LoginName;
            LL.StatusId    = 1;  //This is to be in 'submitted' mode.
            LL.UserName    = LoginName;

            try
            {
                if (txtFirstName.Text.ToString() != "")
                {
                    LL.FirstName = txtFirstName.Text.ToString();
                }
                else
                {
                    ValidationSummary1.AddErrorMessage("Please enter First Name .");
                    panel1controlsAreValid = false;
                }

                if (txtLastName.Text.ToString() != "")
                {
                    LL.LastName = txtLastName.Text.ToString();
                }
                else
                {
                    ValidationSummary1.AddErrorMessage("Please enter Last Name .");
                    panel1controlsAreValid = false;
                }

                if (txtPhone.Text.ToString() != "")
                {
                    LL.Phone = txtPhone.Text.ToString();
                }
                else
                {
                    ValidationSummary1.AddErrorMessage("Please enter Phone # .");
                    panel1controlsAreValid = false;
                }

                if (txtLocation.Text.ToString() != "" && txtLocation.Text.Length < 50)
                {
                    LL.Location = txtLocation.Text.ToString();
                }
                else
                {
                    if (txtLocation.Text.Length > 50)
                    {
                        ValidationSummary1.AddErrorMessage("Location must be less then 50 characters.");
                        panel1controlsAreValid = false;
                    }
                }


                if (ddlSBU.SelectedIndex != 0)
                {
                    try
                    {
                        LL.SBUId = decimal.Parse(ddlSBU.SelectedItem.Value.ToString());
                    }
                    catch (SystemException ex)
                    {
                        throw new Backend.LLException("SBU ID is not numeric.", ex);
                    }
                }
                else
                {
                    ValidationSummary1.AddErrorMessage("Please choose a SBU. ");
                    panel1controlsAreValid = false;
                }

                if (ddlBU.SelectedIndex != -1 && ddlBU.SelectedIndex != 0)
                {
                    try
                    {
                        LL.BUId = decimal.Parse(ddlBU.SelectedItem.Value.ToString());
                    }
                    catch (SystemException ex)
                    {
                        throw new Backend.LLException("BU ID is not numeric.", ex);
                    }
                }
                else
                {
                    ValidationSummary1.AddErrorMessage("Please choose a Business Unit. ");
                    panel1controlsAreValid = false;
                }

                if ((ddlProject.SelectedIndex != -1 && ddlProject.SelectedIndex != 0) || txtOther.Text.ToString() != "")
                {
                    if (txtOther.Text.ToString() != "")
                    {
                        if (txtOther.Text.Length < 81)
                        {
                            LL.ProjectOther = txtOther.Text.ToString();
                        }
                        else
                        {
                            ValidationSummary1.AddErrorMessage("Project Other must be 80 Characters or less. ");
                            panel1controlsAreValid = false;
                        }
                    }

                    if (ddlProject.SelectedIndex != -1 && ddlProject.SelectedIndex != 0)
                    {
                        try
                        {
                            LL.ProjectId = decimal.Parse(ddlProject.SelectedItem.Value.ToString());
                        }
                        catch (SystemException ex)
                        {
                            throw new Backend.LLException("Project ID is not numeric.", ex);
                        }
                    }
                }
                else
                {
                    ValidationSummary1.AddErrorMessage("Please choose a Project Name or if not there, enter a value in the 'other' box. ");
                    panel1controlsAreValid = false;
                }

                if (txtTitle.Text.ToString() != "")
                {
                    LL.Title = txtTitle.Text.ToString();
                }
                else
                {
                    ValidationSummary1.AddErrorMessage("Please enter a Title less then 100 characters. ");
                    panel1controlsAreValid = false;
                }

                if (txtStatement.Text.ToString() != "")
                {
                    LL.Statement = txtStatement.Text.ToString();
                }
                else
                {
                    ValidationSummary1.AddErrorMessage("Please enter a Statement less then 300 characters. ");
                    panel1controlsAreValid = false;
                }

                if (txtRecommendations.Text.ToString() != "")
                {
                    LL.Background = txtBackground.Text.ToString();
                }

                if (ddlFinancialImpact.SelectedIndex > 0)
                {
                    try
                    {
                        LL.FinancialImpactId = decimal.Parse(ddlFinancialImpact.SelectedItem.Value.ToString());
                    }
                    catch (SystemException ex)
                    {
                        throw new Backend.LLException("Financial Impact ID is not numeric.", ex);
                    }
                }

                if (ddlType.SelectedIndex != 0 || txtTypeOther.Text.ToString() != "")
                {
                    if (txtTypeOther.Text.ToString() != "")
                    {
                        if (txtTypeOther.Text.Length < 51)
                        {
                            LL.TypeOther = txtTypeOther.Text.ToString();
                        }
                        else
                        {
                            ValidationSummary1.AddErrorMessage("Type Other must be 50 Characters or less. ");
                            panel1controlsAreValid = false;
                        }
                    }
                    if (ddlType.SelectedIndex != 0)
                    {
                        try
                        {
                            LL.TypeId = decimal.Parse(ddlType.SelectedItem.Value.ToString());
                        }
                        catch (SystemException ex)
                        {
                            throw new Backend.LLException("Type ID is not numeric.", ex);
                        }
                    }
                }
                else
                {
                    //Christian asked to make these fields NOT mandatory, Oct 10, 2008
                    //ValidationSummary1.AddErrorMessage("Please choose a Type or if not there, enter a value in the 'other' box.");
                    //panel1controlsAreValid = false;
                }

                if (ddlImpact.SelectedIndex != 0)
                {
                    try
                    {
                        LL.ImpactId = decimal.Parse(ddlImpact.SelectedItem.Value.ToString());
                    }
                    catch (SystemException ex)
                    {
                        throw new Backend.LLException("Impact ID is not numeric.", ex);
                    }
                }
                else
                {
                    //Christian asked to make these fields NOT mandatory, Oct 10, 2008
                    //ValidationSummary1.AddErrorMessage("Please choose a Impact. ");
                    //panel1controlsAreValid = false;
                }

                if (ddlFrequency.SelectedIndex != 0)
                {
                    try
                    {
                        LL.FrequencyId = decimal.Parse(ddlFrequency.SelectedItem.Value.ToString());
                    }
                    catch (SystemException ex)
                    {
                        throw new Backend.LLException("Frequency Id is not numeric.", ex);
                    }
                }
                else
                {
                    //Christian asked to make these fields NOT mandatory, Oct 10, 2008
                    // ValidationSummary1.AddErrorMessage("Please choose a Frequency. ");
                    // panel1controlsAreValid = false;
                }

                if (txtRecommendations.Text.ToString() != "")
                {
                    LL.Response = txtRecommendations.Text.ToString();
                }
                else
                {
                    ValidationSummary1.AddErrorMessage("Please enter a Recommendations less then 500 characters. ");
                    panel1controlsAreValid = false;
                }

                if (txtReference.Text.ToString() != "")
                {
                    LL.Reference = txtReference.Text.ToString();
                }

                LL.Comments = "";

                // check to see if they picked at least one Subject Matter
                foreach (DataGridItem dgItem in dgSubjectMatter.Items)
                {
                    chkSelected = (CheckBox)dgItem.FindControl("chkSelection");
                    if (chkSelected.Checked)
                    {
                        subjectMatterValid = true;
                    }
                }
                if (!subjectMatterValid)
                {
                    ValidationSummary1.AddErrorMessage("Must pick at least one Process. ");
                    panel2controlsAreValid = false;
                }

                foreach (DataGridItem dgItem in dgStages.Items)
                {
                    chkSelected = (CheckBox)dgItem.FindControl("chkSelection");
                    if (chkSelected.Checked)
                    {
                        stagesValid = true;
                    }
                }

                if (!stagesValid)
                {
                    ValidationSummary1.AddErrorMessage("Must pick at least one Project Phase. ");
                    panel2controlsAreValid = false;
                }


                if (panel1controlsAreValid)
                {
                    if (panel2controlsAreValid)
                    {
                        try
                        {
                            //This is a screen import not a Excel Import
                            LL.ImportfromExcel = "N";
                            LL.Save();
                        }
                        catch (SystemException ex)
                        {
                            throw new Backend.LLException("Failed to save document.", ex);
                        }

                        // Get the LL_ID to save any of the checkboxes picked to the xref table.
                        LL_ID = LL.LLId;

                        foreach (DataGridItem dgItem in dgSubjectMatter.Items)
                        {
                            chkSelected = (CheckBox)dgItem.FindControl("chkSelection");
                            if (chkSelected.Checked)
                            {
                                LL.SubjectMatterId = decimal.Parse(dgItem.Cells[0].Text.ToString());
                                try
                                {
                                    //Make sure some data was returned if not throw an exception
                                    LL.SaveSubjectMatterInfo();
                                }
                                catch (ApplicationException)
                                {
                                    throw new ApplicationException(string.Format("Subject Matter information Save error: ", LL_ID));
                                }
                            }
                        }

                        foreach (DataGridItem dgItem in dgCategory.Items)
                        {
                            chkSelected = (CheckBox)dgItem.FindControl("chkSelection");
                            if (chkSelected.Checked)
                            {
                                LL.CategoryId = decimal.Parse(dgItem.Cells[0].Text.ToString());
                                try
                                {
                                    //Make sure some data was returned if not throw an exception
                                    LL.SaveCategoryInfo();
                                }
                                catch (ApplicationException)
                                {
                                    throw new ApplicationException(string.Format("Discipline information Save error: ", LL_ID));
                                }
                            }
                        }

                        foreach (DataGridItem dgItem in dgStages.Items)
                        {
                            chkSelected = (CheckBox)dgItem.FindControl("chkSelection");
                            if (chkSelected.Checked)
                            {
                                LL.StageId = decimal.Parse(dgItem.Cells[0].Text.ToString());
                                try
                                {
                                    //Make sure some data was returned if not throw an exception
                                    LL.SaveStageInfo();
                                }
                                catch (ApplicationException)
                                {
                                    throw new ApplicationException(string.Format("Project Stage information Save error: ", LL_ID));
                                }
                            }
                        }
                        //Session[Global.Parameters.AmendViewEdit].ToString()
                        //if (Session[Global.Parameters.File3].ToString() != "")
                        if (txtFile1.Text.ToString() != "")
                        {
                            FileUpload3 = (FileUpload)Session[Global.Parameters.File3];
                            Session.Remove(Global.Parameters.File3);

                            if (FileUpload3.HasFile)
                            {
                                String fileName = (String)Session[Global.Parameters.tempFile3];
                                UploadtoDocumentum("Save From the WEB", fileName, FileUpload3.FileName, LL_ID.ToString());
                                Session.Remove(Global.Parameters.tempFile3);
                            }
                        }


                        //if (Session[Global.Parameters.File4].ToString() != "")
                        if (txtFile2.Text.ToString() != "")
                        {
                            FileUpload4 = (FileUpload)Session[Global.Parameters.File4];
                            Session.Remove(Global.Parameters.File4);

                            if (FileUpload4.HasFile)
                            {
                                String fileName = (String)Session[Global.Parameters.tempFile4];
                                UploadtoDocumentum("Save From the WEB", fileName, FileUpload4.FileName, LL_ID.ToString());
                                Session.Remove(Global.Parameters.tempFile4);
                            }
                        }


                        //using the Error msg to confirm the Save.
                        ValidationSummary1.AddErrorMessage("Thank you, your info has been successfully submitted to the Lesson Learned Coordinator. ");
                        //Cleare all fields and return to first page.
                        this.panel1.Visible  = true;
                        this.btnNext.Enabled = true;
                        this.btnBack.Enabled = false;
                        this.btnSave.Enabled = false;

                        this.panel2.Visible = false;
                        ClearAllControls(this);
                        PopulateName();

                        String sPathReport;
                        String sScript;

                        //call report window with their data.
                        Session.Add(Global.Parameters.SubmittedFinal, "SUBMITTED");
                        sPathReport = "window.open('" + Global.ProcessingPage.ToString() + "?" + Global.Parameters.LL_ID + "=" + LL_ID.ToString() + "');";
                        sScript     = "<script> " + sPathReport + "</script>";
                        this.ClientScript.RegisterStartupScript(this.GetType(), "START", sScript);

                        //this.RegisterStartupScript("START", sScript);
                    }
                    else
                    {
                        this.panel1.Visible = false;
                        this.panel2.Visible = true;
                    }
                }
                else
                {
                    this.panel1.Visible  = true;
                    this.btnNext.Enabled = true;
                    this.btnBack.Enabled = false;
                    this.btnSave.Enabled = false;
                    this.panel2.Visible  = false;
                }
            }
            catch (System.Exception ex)
            {
                throw new Backend.LLException("Failed to save document.", ex);
            }
        }