Exemplo n.º 1
0
        public void LoadAttachments(int requestID)
        {
            ProjectRequestEntities projectRequest  = new ProjectRequestEntities();
            List <Control>         dynamicControls = new List <Control>();
            List <string>          allAttachments  = new List <string>();

            List <string> To           = new List <string>();
            List <string> Bcc          = new List <string>();
            List <string> Cc           = new List <string>();
            FieldInfo     fieldInfo    = new FieldInfo();
            List <string> attatchments = new List <string>();

            int listNum;

            if (ViewState["Attatchment"] != null)
            {
                string fileName;

                CreateDirectory(requestID);

                List <string> Attachment = new List <string>();
                Attachment = (List <string>)ViewState["Attatchment"];

                foreach (var file in Attachment)
                {
                    fileName = file;

                    Attachment attachment = new Attachment();

                    attachment.filePath  = requestID.ToString() + "/" + fileName;
                    attachment.requestID = requestID;

                    projectRequest.AddToAttachments(attachment);
                    projectRequest.SaveChanges();

                    System.IO.File.Copy(filePath + fileName, filePath + requestID.ToString() + @"\" + fileName);

                    allAttachments.Add(filePath + requestID.ToString() + @"\" + fileName);

                    deleteAttachments.Add(filePath + fileName);
                }
            }

            ViewState["allAttachments"] = allAttachments;

            projectRequest.Dispose();
        }
Exemplo n.º 2
0
        public void InsertData(Panel panel, int subRequestID)
        {
            if (panel.ID != "pnlStoryPic")
            {
                //the page is warpped in a pnael, cycle through it to get all the labels on the page
                foreach (Control control in panel.Controls)
                {
                    ProjectRequestEntities projectRequest = new ProjectRequestEntities();
                    Answer answer = new Answer();

                    answer.subrequestID = subRequestID;

                    //if the current selected control is a panel you need to cycle through this panel to get all the controls in side of it
                    if (control is Panel)
                    {
                        InsertData((Panel)control, subRequestID);
                    }

                    else if (control is TextBox || control is DropDownList || control is RadioButtonList || control is CheckBox)
                    {
                        //check to see what type of control is selected so you can get the appropiate text value
                        if (control is TextBox)
                        {
                            answer.AnswerText = ((TextBox)control).Text;
                            answer.QuestionID = control.ID;
                        }

                        else if (control is DropDownList)
                        {
                            if (((DropDownList)control).SelectedIndex > 0)
                            {
                                answer.AnswerText  = ((DropDownList)control).SelectedItem.Text;
                                answer.AnswerValue = ((DropDownList)control).SelectedValue;
                            }
                            else
                            {
                                answer.AnswerText = "No Answer";
                            }

                            answer.QuestionID = control.ID;
                        }

                        else if (control is RadioButtonList)
                        {
                            if (((RadioButtonList)control).SelectedIndex > -1)
                            {
                                answer.AnswerText  = ((RadioButtonList)control).SelectedItem.Text;
                                answer.AnswerValue = ((RadioButtonList)control).SelectedValue;
                            }
                            else
                            {
                                answer.AnswerText = "No Answer";
                            }

                            answer.QuestionID = control.ID;
                        }

                        else if (control is CheckBox)
                        {
                            if (((CheckBox)control).Checked)
                            {
                                answer.AnswerText = "Yes";
                            }
                            else
                            {
                                answer.AnswerText = "No";
                            }

                            answer.QuestionID = control.ID;
                        }

                        else
                        {
                            answer.AnswerText = "No Answer";
                            answer.QuestionID = control.ID;
                        }

                        projectRequest.AddToAnswers(answer);
                        projectRequest.SaveChanges();

                        projectRequest.Dispose();
                    }
                }
            }
        }
Exemplo n.º 3
0
        public int DataInsert()
        {
            int    requestID;
            string emailBody;

            List <string> To           = new List <string>();
            List <string> Bcc          = new List <string>();
            List <string> Cc           = new List <string>();
            FieldInfo     fieldInfo    = new FieldInfo();
            List <string> attatchments = new List <string>();

            using (ProjectRequestEntities projectRequest = new ProjectRequestEntities())
            {
                ProjectRequestEntities newCase = new ProjectRequestEntities();
                Models.Request         request = new Models.Request();

                var DOAs = newCase.DOAs.Select(d => d.doaID).ToList();

                var staffList = newCase.Staffs.Select(s => s.staffID).ToList();

                var approverList = newCase.Approvers.Select(a => a.sullivanID).ToList();

                request.name          = tbFName.Text + " " + tbLName.Text;
                request.location      = ddlLocation.SelectedItem.Text;
                request.contactInfo   = tbContact.Text;
                request.dateRequested = DateTime.Now;
                request.completed     = false;
                request.subProjects   = 1;
                request.projectName   = tbProjectName.Text;
                request.categoryID    = "multi";
                request.department    = ddlDepartment.SelectedItem.Text;

                request.email          = tbEmail.Text;
                request.additionalInfo = tbAdditionalInfo.Text;

                if (DOAs.Contains((string)ViewState["name"]) || staffList.Contains((string)ViewState["name"]) || approverList.Contains((string)ViewState["name"]))
                {
                    request.status = "Approved";
                }
                else
                {
                    request.status = "Pending";

                    var approvers = newCase.Approvers.Where(d => d.department == ddlDepartment.SelectedItem.Text);

                    string approverName = "";

                    foreach (var name in approvers)
                    {
                        approverName += name.name + ", ";
                    }

                    approverName = approverName.Trim();
                    approverName = approverName.TrimEnd(',');

                    request.doaName = approverName;
                }


                projectRequest.AddToRequests(request);
                projectRequest.SaveChanges();

                requestID = request.reuqestID;

                ViewState["RequestID"] = requestID.ToString();

                projectRequest.Dispose();

                LoadAttachments(requestID);

                //}
                //catch (Exception ex)
                //{
                //    To.Clear();
                //    Cc.Clear();
                //    To.Add("*****@*****.**");

                //    fieldInfo.SendEmail("PR Database Error for " + category, ex.ToString(), To, Bcc, Cc, "*****@*****.**", attatchments);
                //}
            }

            return(requestID);
        }