示例#1
0
        private void okButton_Click(object sender, EventArgs e)
        {
            Client client = new Client();

            client.Name         = clientNameTextBox.Text;
            client.Region       = RegionComboBox.Text;
            client.Country      = countryComboBox.Text;
            client.StartDate    = selectedTime;
            client.BusinessType = BusinessTypeComboBox.Text;

            if (clientNameTextBox.Text == "" || RegionComboBox.Text == "" ||
                countryComboBox.Text == "" || startDateText.Text == "" || BusinessTypeComboBox.Text == "")
            {
                MessageBox.Show("All fields required. Please check fields and try again.");
                return;
            }

            if (!ClientDataControl.NewClient(client))
            {
                MessageBox.Show("Failed to create new client: " + client.Name + " already exists", "Error");
                return;
            }

            this.Close();
        }
示例#2
0
        private void LoadClientButton_Click(object sender, EventArgs e)
        {
            if (ClientDataControl.LoadClient(ChooseClientComboBox.Text))
            {
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }

            else
            {
                MessageBox.Show("Failed to load client: " + ChooseClientComboBox.Text + " does not exist", "Error");
            }
        }
示例#3
0
        private void NewClientForm_Load(object sender, EventArgs e)
        {
            this.BringToFront();
            okButton.Click          += new EventHandler(okButton_Click);
            cancelButton.Click      += new EventHandler(cancelButton_Click);
            startDateText.Click     += new EventHandler(startDateText_Click);
            startDateText.LostFocus += new EventHandler(startDateText_LostFocus);
            //countryComboBox.Items.AddRange(ClientDataControl.GetCoutnryNames());
            RegionComboBox.Items.AddRange(ClientDataControl.GetRegionNames());
            BusinessTypeComboBox.Items.AddRange(ClientDataControl.GetBusinessTypeNames());
            startDateText.ReadOnly = true;

            // make all input read only
        }
示例#4
0
        private void OnlineModeCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            if (OnlineModeCheckbox.Checked)
            {
                OnlineModeCheckbox.Text = "Connecting...";
                OnlineModeCheckbox.Update();
                OnlineModeCheckbox.Checked = ClientDataControl.LoadDatabase();
            }

            else
            {
                ClientDataControl.LoadFileSystem();
                OnlineModeCheckbox.Checked = false;
            }
            OnlineModeCheckbox.Text = "Online Mode";
        }
示例#5
0
        public ChangeCUPEDefaults()
        {
            InitializeComponent();

            List <CupeQuestionData> cupeQuestionList = ClientDataControl.GetCupeQuestionData();
            DataGridViewRow         row;

            foreach (CupeQuestionData data in cupeQuestionList)
            {
                row = CUPEQuestionDataGridView.Rows[0].Clone() as DataGridViewRow;
                row.Cells[0].Value = data.InDefault20;
                row.Cells[1].Value = data.InDefault10;
                row.Cells[2].Value = data.StringData.OriginalQuestionText;
                row.Cells[3].Value = data.StringData.ChoiceA;
                row.Cells[4].Value = data.StringData.ChoiceB;
                row.Cells[5].Value = data.StringData.ChoiceC;
                row.Cells[6].Value = data.StringData.ChoiceD;
                CUPEQuestionDataGridView.Rows.Add(row);
            }

            CUPEQuestionDataGridView.AllowUserToAddRows    = false;
            CUPEQuestionDataGridView.AllowUserToDeleteRows = false;
        }
示例#6
0
        private void SaveParticipantButton_Click(object sender, EventArgs e)
        {
            int           count    = 1;
            List <Person> tempList = new List <Person>();

            foreach (DataGridViewRow row in participantsGrid.Rows)
            {
                if (Convert.ToBoolean(row.Cells[2].Value) && Convert.ToBoolean(row.Cells[1].Value))
                {
                    MessageBox.Show("Participants must be either Business or IT", "Error");
                    return;
                }
                else if (!Convert.ToBoolean(row.Cells[2].Value) && !Convert.ToBoolean(row.Cells[1].Value))
                {
                    continue;
                }
                try
                {
                    //Create the new person
                    Person tempPerson = new Person(count++);

                    if (row.Cells[0].Value != null)
                    {
                        tempPerson.Email = row.Cells[0].Value.ToString();
                    }

                    if (Convert.ToBoolean(row.Cells[2].Value) == true)
                    {
                        tempPerson.Type     = Person.EmployeeType.IT;
                        tempPerson.CodeName = "Business" + count.ToString();
                    }
                    if (Convert.ToBoolean(row.Cells[1].Value) == true)
                    {
                        tempPerson.Type     = Person.EmployeeType.Business;
                        tempPerson.CodeName = "IT" + count.ToString();
                    }
                    //See if there are answers for the current person

                    CupeData data = null;
                    try
                    {
                        data = ClientDataControl.GetCupeAnswers().Where(x => x.ParticipantId == tempPerson.ID).Single();
                    }
                    catch
                    {
                    }
                    if (data != null)
                    {
                        tempPerson.cupeDataHolder = data;
                    }
                    //If not create new cupedata object
                    else
                    {
                        tempPerson.cupeDataHolder = new CupeData(tempPerson.ID);
                    }

                    tempList.Add(tempPerson);
                }
                catch
                {
                }
            }

            tempList.OrderBy(o => o.ID);

            ClientDataControl.SetParticipants(tempList);
            this.Close();
        }
示例#7
0
        public EditParticipants()
        {
            InitializeComponent();

            try
            {
                if (ClientDataControl.GetParticipants().Count() != 0)
                {
                    participantsGrid.Rows.Add(ClientDataControl.GetParticipants().Count());
                }

                int i = 0;
                foreach (Person person in ClientDataControl.GetParticipants())
                {
                    if (person.Type == Person.EmployeeType.IT)
                    {
                        participantsGrid.Rows[i].SetValues("",
                                                           false,
                                                           true,
                                                           true,
                                                           person.ID
                                                           );
                    }
                    else if (person.Type == Person.EmployeeType.Business)
                    {
                        participantsGrid.Rows[i].SetValues("",
                                                           true,
                                                           false,
                                                           true,
                                                           person.ID
                                                           );
                    }
                    else
                    {
                        if (person.Type == Person.EmployeeType.IT)
                        {
                            participantsGrid.Rows[i].SetValues("",
                                                               false,
                                                               false,
                                                               true,
                                                               person.ID
                                                               );
                        }
                    }
                    i++;
                }
            }
            catch
            {
            }

            if (participantsGrid.Rows.Count == 1)
            {
                participantsGrid.Rows[participantsGrid.Rows.Count - 1].Cells[4].Value = 0;
            }
            else
            {
                participantsGrid.Rows[participantsGrid.Rows.Count - 1].Cells[4].Value =
                    Convert.ToInt32(participantsGrid.Rows[participantsGrid.Rows.Count - 2].Cells[4].Value) + 1;
            }
        }
示例#8
0
 private void SendEmailButton_Click(object sender, EventArgs e)
 {
     ClientDataControl.SendEmailButton_Click();
 }
示例#9
0
        public bool CreateCupeSurvey(List <Person> people, List <string> questions, bool istwenty)
        {
            Word._Document oDoc;
            try
            {
                //Find some stats regarding the Cats, Obj, and Imperatives for later reference.
                var totalRows = questions.Count + 1;

                //Creating the document
                //
                object oMissing  = System.Reflection.Missing.Value;
                object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */

                //Start Word and create a new document.
                Word._Application oWord;
                oWord         = new Word.Application();
                oWord.Visible = false;
                oDoc          = oWord.Documents.Add(ref oMissing, ref oMissing,
                                                    ref oMissing, ref oMissing);
                //oWord.Activate();
                System.Threading.Thread.Sleep(3000);

                //Insert a paragraph at the beginning of the document.
                Word.Paragraph oPara1;
                oPara1                        = oDoc.Content.Paragraphs.Add(ref oMissing);
                oPara1.Range.Text             = "IT Provider Relationship Survey";
                oPara1.Range.Font.Bold        = 1;
                oPara1.Range.Font.Size        = 18;
                oPara1.Format.SpaceAfter      = 24; //24 pt spacing after paragraph.
                oPara1.Format.LineSpacingRule = Word.WdLineSpacing.wdLineSpaceSingle;
                oPara1.Range.InsertParagraphAfter();

                Word.Paragraph oPara2;
                oPara2                 = oDoc.Content.Paragraphs.Add(ref oMissing);
                oPara2.Alignment       = Word.WdParagraphAlignment.wdAlignParagraphLeft;
                oPara2.Range.Font.Size = 12;
                var inputText = oDoc.FormFields.Add(oPara2.Range, Word.WdFieldType.wdFieldFormDropDown);
                inputText.DropDown.ListEntries.Add("Business");
                inputText.DropDown.ListEntries.Add("IT");
                oPara2.Format.SpaceAfter = 12;    //24 pt spacing after paragraph.
                oPara2.Range.InsertBefore("Department: ");
                oPara2.Range.InsertParagraphAfter();


                Word.Paragraph oPara3;
                oPara3 = oDoc.Content.Paragraphs.Add(ref oMissing);
                oPara3.Range.Font.Size   = 12;
                oPara3.Alignment         = Word.WdParagraphAlignment.wdAlignParagraphLeft;
                oPara3.Range.Text        = "Please fill out this survey. Answers for each question are located in the correlated drop down menu. Each question requires a 'Current' answer as well as a 'Future' answer.";
                oPara3.Range.Font.Bold   = 1;
                oPara3.Format.SpaceAfter = 12;    //24 pt spacing after paragraph.
                oPara3.Range.InsertParagraphAfter();


                Word.Table oTable;
                Word.Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                oTable = oDoc.Tables.Add(wrdRng, totalRows, 3, ref oMissing, Word.WdAutoFitBehavior.wdAutoFitContent);
                oTable.Range.ParagraphFormat.SpaceAfter = 6;
                oTable.Spacing = 1;


                oTable.Cell(1, 1).Range.Text = "Question";
                oTable.Cell(1, 2).Range.Text = "Current Value";
                oTable.Cell(1, 3).Range.Text = "Future Value";

                if (!istwenty)
                {
                    questions.RemoveRange(10, 10);
                }

                System.Threading.Thread.Sleep(3000);

                //Create an array for the questions for the formfields
                string[] FormNames = new string[(totalRows - 1) * 2];

                //Current Row and Current FormName position
                int r = 2, c = 0;
                //Add the questions
                foreach (string question in questions)
                {
                    oTable.Cell(r, 1).Range.Text = question;
                    FormNames[c] = question;
                    c++;
                    FormNames[c] = question;

                    Word.Range cell2Range = oTable.Cell(r, 2).Range;
                    cell2Range.Collapse(ref oMissing);
                    //oDoc.FormFields.Add(cell2Range, Word.WdFieldType.wdFieldFormTextInput);
                    inputText = oDoc.FormFields.Add(cell2Range, Word.WdFieldType.wdFieldFormDropDown);
                    inputText.DropDown.ListEntries.Add("        ");
                    inputText.DropDown.ListEntries.Add("A");
                    inputText.DropDown.ListEntries.Add("B");
                    inputText.DropDown.ListEntries.Add("C");
                    inputText.DropDown.ListEntries.Add("D");

                    cell2Range = oTable.Cell(r, 3).Range;
                    cell2Range.Collapse(ref oMissing);
                    inputText = oDoc.FormFields.Add(cell2Range, Word.WdFieldType.wdFieldFormDropDown);
                    inputText.DropDown.ListEntries.Add("        ");
                    inputText.DropDown.ListEntries.Add("A");
                    inputText.DropDown.ListEntries.Add("B");
                    inputText.DropDown.ListEntries.Add("C");
                    inputText.DropDown.ListEntries.Add("D");

                    r++;
                    c++;
                }

                r = 2;
                //Add the question text
                foreach (CupeQuestionStringData question in ClientDataControl.GetCupeQuestions())
                {
                    oTable.Cell(r, 1).Range.Text = question.QuestionText +
                                                   Environment.NewLine + "A.) " + question.ChoiceA +
                                                   Environment.NewLine + "B.) " + question.ChoiceB +
                                                   Environment.NewLine + "C.) " + question.ChoiceC +
                                                   Environment.NewLine + "D.) " + question.ChoiceD +
                                                   Environment.NewLine + Environment.NewLine;

                    r++;
                }


                oTable.Rows[1].Range.Font.Bold   = 0;
                oTable.Rows[1].Range.Font.Italic = 1;
                oTable.Rows[1].Range.Font.Size   = 12;

                oTable.Columns[1].SetWidth(420.0f, Word.WdRulerStyle.wdAdjustNone);
                oTable.Columns[2].SetWidth(50.0f, Word.WdRulerStyle.wdAdjustNone);
                oTable.Columns[3].SetWidth(50.0f, Word.WdRulerStyle.wdAdjustNone);

                for (var i = 1; i <= oTable.Rows.Count; i++)
                {
                    oTable.Rows[i].Range.Font.Size = 8;
                    oTable.Rows[1].Range.Font.Bold = 1;
                }


                oDoc.Protect(Word.WdProtectionType.wdAllowOnlyFormFields, false, string.Empty, false, false);



                c = 0;
                r = 0;
                foreach (Word.FormField form in oDoc.FormFields)
                {
                    if (r == 0)
                    {
                        form.Name = "Name";
                        r++;
                        continue;
                    }
                    //form.Name = FormNames[c].ToString();
                    string removeChars = " ?&^$#@!()+-,:;/<>’\'-_*";

                    string name = FormNames[c];
                    foreach (char p in removeChars)
                    {
                        name = name.Replace(p.ToString(), string.Empty);
                    }



                    form.Name = name;
                    c++;
                }

                oWord.Visible = true;
            }
            catch (Exception)
            {
                return(false);
            }

            try
            {
                oDoc.SaveAs("CupeSurvey", Word.WdSaveFormat.wdFormatDocument);
            }
            catch
            {
            }
            return(true);
        }
示例#10
0
        public void ReadSurveyCUPE(List <Person> people)
        {
            int count = 1;
            var FD    = new System.Windows.Forms.FolderBrowserDialog();

            if (FD.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            var files    = Directory.EnumerateFiles(FD.SelectedPath);
            var badFiles = 0;

            foreach (var file in files)
            {
                if (file.Contains("~$"))
                {
                    badFiles++;
                    continue;
                }
                //Start Word and open the word document.
                Word._Application oWord;
                Word._Document    oDoc;
                oWord         = new Word.Application();
                oWord.Visible = false;


                oDoc = oWord.Documents.Open(file, Type.Missing, Type.Missing, Type.Missing,
                                            Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                            Type.Missing, Type.Missing, false, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                //oWord.Activate();


                //Loop through the forms. If the person doesn't exist in the participant list then create a new person
                try
                {
                    if (oDoc.Paragraphs.First.Range.Text != "IT Provider Relationship Survey\r")
                    {
                        continue;
                    }

                    //Find the person object the form is related to, otherwise create a new one
                    Person currentPerson = null;
                    foreach (Word.FormField form in oDoc.FormFields)
                    {
                        //Find the person and their type
                        if (form.Name == "Name")
                        {
                            currentPerson = new Person(count++);
                            if (form.Result.ToString() == "Business")
                            {
                                currentPerson.Type     = Person.EmployeeType.Business;
                                currentPerson.CodeName = "Business" + count.ToString();
                            }
                            else
                            {
                                currentPerson.Type     = Person.EmployeeType.IT;
                                currentPerson.CodeName = "IT" + count.ToString();
                            }
                            ClientDataControl.AddParticipant(currentPerson);
                            break;
                        }
                        else
                        {
                            break;
                        }
                    }

                    int q = 1, c = 1;
                    foreach (Word.FormField form in oDoc.FormFields)
                    {
                        if (form.Name != "Name")
                        {
                            if (c == 1)
                            {
                                currentPerson.cupeDataHolder.CurrentAnswers.Add("Question " + q, form.Result.ToCharArray()[0]);
                                c = 2;
                            }
                            else if (c == 2)
                            {
                                currentPerson.cupeDataHolder.FutureAnswers.Add("Question " + q, form.Result.ToCharArray()[0]);
                                c = 1;
                                q++;
                            }
                        }
                    }
                    ClientDataControl.AddCupeAnswers(currentPerson.cupeDataHolder);
                    oDoc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                }
                catch
                {
                    oDoc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                }
            }
        }