Ejemplo n.º 1
0
        private void SaveHeader_Click(object sender, EventArgs e)
        {
            if (HeaderTitleText.Text.Length <= 0)
            {
                MessageBox.Show("Please fill in the title");
                return;
            }


            _header.Title = HeaderTitleText.Text;
            _header.Desc  = HeaderDescText.Text;



            MySql sql = new MySql();

            sql.OpenConnection();
            if (sql.SaveHeader(_header))
            {
                MessageBox.Show("Header Successfully Saved");
                this.DialogResult = DialogResult.OK;
                sql.CloseConnection();
                Close();
            }
            sql.CloseConnection();
        }
        public GenerateFeedback()
        {
            InitializeComponent();

            SectionTable.VerticalScroll.Enabled   = false;
            ContentTable.VerticalScroll.Enabled   = true;
            SectionTable.HorizontalScroll.Enabled = false;

            AddSectionBtn.Visible   = false;
            SetTemplateBtn.Enabled  = false;
            SaveTemplateBtn.Enabled = false;

            ContentTable.Padding = new Padding(0, 0, SystemInformation.VerticalScrollBarWidth, 0);

            MySql sql = new MySql();

            sql.OpenConnection();

            ApplicantList.ValueMember = "Name";

            //get the list of position from the database
            List <Position> positions = sql.GetPositions();

            foreach (Position p in positions)
            {
                PositionList.Items.Add(p);
            }

            PositionList.ValueMember = "_positionName";

            sql.CloseConnection();
        }
Ejemplo n.º 3
0
        public HeaderItemDisplay(string id)
        {
            InitializeComponent();

            MySql sql = new MySql();

            sql.OpenConnection();

            _header = sql.GetHeader(id);
            _header.HeaderItems.Clear();
            List <HeaderItem> items = sql.GetHeaderItems(id);

            foreach (HeaderItem item in items)
            {
                _header.addHeaderItem(item);
            }

            HeaderTitleText.Text = _header.Title;
            HeaderDescText.Text  = _header.Desc;

            ItemDVG.DataSource = _header.HeaderItems;

            for (int a = 0; a < ItemDVG.ColumnCount - 2; a++)
            {
                ItemDVG.Columns[a].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
            }

            ItemDVG.Columns[ItemDVG.ColumnCount - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

            sql.CloseConnection();

            SaveHeader.Click -= SaveHeader_Click;
            SaveHeader.Click += UpdateHeader_Click;
            SaveHeader.Text   = "Update Header";
        }
Ejemplo n.º 4
0
        //constructor used to initialise the template with the passed in id
        public TemplateCreator(string id)
        {
            InitializeComponent();

            MySql sql = new MySql();

            sql.OpenConnection();

            _currentTemplate = sql.GetTemplate(id);

            TitleText.Text = _currentTemplate.Title;
            DescText.Text  = _currentTemplate.Desc;

            //place in the header
            HeaderPlacement place = new HeaderPlacement();

            HeaderPanel.Controls.Clear();
            foreach (HeaderItem item in _currentTemplate.Header.HeaderItems)
            {
                place.AddItem(item);
            }

            HeaderPanel.Controls.Add(place);

            ChangeHeader.Enabled   = true;
            HorizontalLine.Visible = true;
            TextLabel.Visible      = true;

            Sections.UpdateSelectedSections(_currentTemplate.Sections);

            sql.CloseConnection();

            SaveTemplate.Text = "Update Template";
            isUpdate          = true;
        }
Ejemplo n.º 5
0
        private void UpdateBtn_Click(object sender, EventArgs e)
        {
            string id = Dgv.SelectedRows[0].Cells[0].Value.ToString();

            if (!String.IsNullOrEmpty(RowTitleText.Text))
            {
                MySql sql = new MySql();
                sql.OpenConnection();

                if (sql.EditComponent(ControlType, id, RowTitleText.Text, RowDescText.Text))
                {
                    MessageBox.Show("Successfully Updated!\n For advanced updates please click the Edit " + ControlType + " button. ");
                }
                else
                {
                    MessageBox.Show("No updates detected!\n For advanced updates please click the Edit " + ControlType + " button. ");
                }

                sql.CloseConnection();
            }
            else
            {
                MessageBox.Show(ControlType + " Title must not be empty!", "Missing attributes");
                return;
            }

            setDgv();
            RowTitleText.Clear();
            RowDescText.Clear();
            UpdateBtn.Visible = false;
        }
        private void setHeader()
        {
            using (SelectControl form = new SelectControl("Header"))
            {
                var result = form.ShowDialog();

                if (result == DialogResult.OK)
                {
                    MySql sql = new MySql();
                    sql.OpenConnection();

                    _currentFeed.Header             = sql.GetHeader(form._ids[0]);
                    _currentFeed.Header.HeaderItems = sql.GetHeaderItems(_currentFeed.Header.HeaderId);

                    FillHeader();

                    sql.CloseConnection();
                }
                else
                {
                    /*
                     * To prevent the continuation of the method calls to setSection in setTemplate
                     * when the user did not select any header (direct close window)
                     */
                    throw new Exception();
                }
            }
        }
        private void PositionList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (PositionList.SelectedIndex != -1)
            {
                ChangeHeader.Visible    = false;
                AddSectionBtn.Visible   = false;
                SetTemplateBtn.Enabled  = false;
                SaveTemplateBtn.Enabled = false;

                MySql sql = new MySql();
                sql.OpenConnection();
                Position pos = (Position)PositionList.SelectedItem;
                _currentFeed.Position = pos;
                List <Applicant> app = sql.GetAppByPosition(pos._positionId);

                ApplicantList.Items.Clear();

                foreach (Applicant p in app)
                {
                    ApplicantList.Items.Add(p);
                }

                sql.CloseConnection();

                _currentFeed.Applicant = null;
                _currentFeed.Header    = null;
                _currentFeed.Sections.Clear();
                ContentTable.Controls.Remove(ContentTable.GetControlFromPosition(0, 0));
                SectionTable.Controls.Clear();
                PDFDisplay.DocumentText = "";

                SaveFeedbackBtn.Text = "Save Feedback";
            }
        }
Ejemplo n.º 8
0
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(CodeBox.Text) || String.IsNullOrEmpty(SectionTitleText.Text))
            {
                MessageBox.Show(@"Title or Codes cannot be empty.");
            }
            else
            {
                MySql sql = new MySql();
                sql.OpenConnection();

                List <string> codes = new List <string>(CodeBox.Lines);
                codes.RemoveAll(item => item.Length == 0);

                _section.Title = SectionTitleText.Text;
                _section.Desc  = SectionDescText.Text;
                _section.Codes = new List <string>();
                _section.Codes.Clear();
                _section.Codes.AddRange(codes);

                if (!_update)
                {
                    if (!sql.SaveSection(new Section(SectionTitleText.Text, SectionDescText.Text, codes)))
                    {
                        return;
                    }
                    MessageBox.Show("Section succesfully saved");
                    sql.CloseConnection();

                    //after the saving is done, go back to the home page showing the list of available sections
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    //This part updates the section
                    if (sql.UpdateSection(_section))
                    {
                        MessageBox.Show("Section successfully saved");
                        sql.CloseConnection();
                        DialogResult = DialogResult.OK;
                        Close();
                    }
                }
            }
        } //end save button
Ejemplo n.º 9
0
        private void SaveTemplateBtn_Click(object sender, EventArgs e)
        {
            if (TitleText.Text.Length <= 0)
            {
                MessageBox.Show("Please insert the title", "Missing Field");
                return;
            }

            if (object.ReferenceEquals(_currentTemplate.Header, null))
            {
                MessageBox.Show("Please choose the header to be included in the template.", "Missing Header");
                return;
            }

            _currentTemplate.Sections = Sections.SelectedSections;

            if (_currentTemplate.Sections.Count <= 0)
            {
                MessageBox.Show("Please choose the sections to be included in the template.", "Missing Sections");
                return;
            }
            //end of field checkers

            MySql sql = new MySql();

            sql.OpenConnection();

            try
            {
                if (!isUpdate)
                {
                    if (sql.SaveTemplate(_currentTemplate.Header, _currentTemplate.Sections, TitleText.Text, DescText.Text))
                    {
                        MessageBox.Show("Template successfully saved!");
                    }
                }
                else
                {
                    if (sql.UpdateTemplate(_currentTemplate.Header, _currentTemplate.Sections, TitleText.Text, DescText.Text, _currentTemplate.Id))
                    {
                        MessageBox.Show("Template successfully updated!");
                    }
                }


                this.DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.ToString(), "Ops! Error occured!");
            }
            finally
            {
                sql.CloseConnection();
            }
        }
Ejemplo n.º 10
0
        public void Dispose()
        {
            if (!disposed)
            {
                if (database != null)
                {
                    database.CloseConnection();
                }

                disposed = true;
            }
        }
Ejemplo n.º 11
0
        private void SetDgv()
        {
            MySql sql = new MySql();

            sql.OpenConnection();
            DataTable Dt = new DataTable();

            try
            {
                switch (ControlType)
                {
                case "Header":
                    Dt = sql.GetDataSet("SELECT header.HeaderID, header.Name, header.Desc, " +
                                        "group_concat(headeritem.Title order by headercontains.PositionIndex ASC SEPARATOR \' | \') as Items " +
                                        "FROM header, headeritem, headercontains " +
                                        "WHERE header.Archived = 0 and header.HeaderID = headercontains.HeaderID AND headeritem.HeaderItemID = headercontains.HeaderItemID " +
                                        "GROUP BY header.HeaderID ORDER BY header.HeaderID");
                    Dt.Columns["HeaderId"].ColumnName = "Header ID";
                    Dt.Columns["Desc"].ColumnName     = "Description";
                    break;

                case "Template":
                    Dt = sql.GetDataSet("SELECT template.TemplateID AS 'Template ID', template.TemplateTitle AS 'Template Title', " +
                                        "template.TemplateDesc AS 'Template Description', header.Name as 'Header Name', " +
                                        "GROUP_CONCAT(section.Title order by section.SectionID SEPARATOR ' | ') as Sections , " +
                                        "CONCAT(reviewer.FirstName,' ', reviewer.LastName) AS 'Author Name' " +
                                        "FROM template, template_section, reviewer, header, section " +
                                        "WHERE template.Archived = 0 and template.TemplateID = template_section.TemplateID " +
                                        "AND template_section.SectionID = section.SectionID " +
                                        "AND template.HeaderID = header.HeaderID " +
                                        "AND template.TemplateAuthor = reviewer.ReviewerID " +
                                        "GROUP BY template.TemplateID " +
                                        "ORDER BY template.TemplateID; ");
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            Dgv.DataSource = Dt;
            sql.CloseConnection();

            for (int a = 0; a < Dgv.ColumnCount - 2; a++)
            {
                Dgv.Columns[a].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
            }

            Dgv.Columns[Dgv.ColumnCount - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
        }
Ejemplo n.º 12
0
        private void ConectarDataBaseBtn_Click(object sender, EventArgs e)
        {
            string connectionString = "Server=localhost;Database=mydb;Uid=root;Pwd=sebas1995;";

            MySql mySql = new MySql();

            mySql.ConnectionString = connectionString;
            mySql.OpenConnection();
            mySql.BeginTransaction();
            dataGridView1.DataSource = mySql.QuerySQL("Select * from Clientes");
            mySql.CommitTransaction();
            mySql.CloseConnection();
            MessageBox.Show("Conexión exitosa");
        }
Ejemplo n.º 13
0
        private void AddUserBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (FirstName.Text.Length <= 0)
                {
                    throw new Exception();
                }

                if (LastName.Text.Length <= 0)
                {
                    throw new Exception();
                }

                if (Password.Text.Length <= 0)
                {
                    throw new Exception();
                }

                if (AdminPrivilege.SelectedIndex == -1)
                {
                    throw new Exception();
                }

                if (EmailText.Text.Length <= 0)
                {
                    throw new Exception();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Please Complete all the information");
                return;
            }

            bool admin = AdminPrivilege.SelectedItem.ToString().Equals("Yes");

            MySql sql = new MySql();

            sql.OpenConnection();

            if (sql.AddUser(FirstName.Text, LastName.Text, Password.Text, admin, EmailText.Text))
            {
                MessageBox.Show("User Successfully Added");
                sql.CloseConnection();
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Ejemplo n.º 14
0
        private void loginBtn_Click(object sender, EventArgs e)
        {
            MySql sql = new MySql();

            sql.OpenConnection();

            if (sql.VerifyPassword(username.Text, password.Text))
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show(@"Invalid Username/Password", @"An Error has Occur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            sql.CloseConnection();
        }
Ejemplo n.º 15
0
        private void UpdateUserList()
        {
            MySql sql = new MySql();

            sql.OpenConnection();

            DataTable users =
                sql.GetDataSet(
                    "SELECT ReviewerID, FirstName, LastName, Email, IF(AdminAccess = 1, \'yes\', \'no\') as AdminAccess FROM feedbacksystem.reviewer where Archived = 0;");

            UserDGV.DataSource = users;

            for (int a = 0; a < UserDGV.ColumnCount - 2; a++)
            {
                UserDGV.Columns[a].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
            }

            UserDGV.Columns[UserDGV.ColumnCount - 2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

            sql.CloseConnection();
        }
        private void SaveTemplateBtn_Click(object sender, EventArgs e)
        {
            using (SaveBox save = new SaveBox())
            {
                var result = save.ShowDialog();

                if (result == DialogResult.OK)
                {
                    MySql sql = new MySql();

                    sql.OpenConnection();

                    if (sql.SaveTemplate(_currentFeed.Header, _currentFeed.Sections, save.Title, save.Desc))
                    {
                        MessageBox.Show("Template successfully saved");
                    }

                    sql.CloseConnection();
                }
            }
        }
Ejemplo n.º 17
0
        public SectionCreator(string id)
        {
            _update = true;

            InitializeComponent();
            MySql sql = new MySql();

            sql.OpenConnection();

            _section = sql.GetSection(id);

            SectionTitleText.Text = _section.Title;
            SectionDescText.Text  = _section.Desc;

            foreach (string c in _section.Codes)
            {
                CodeBox.AppendText(c + Environment.NewLine);
            }


            sql.CloseConnection();
        }
Ejemplo n.º 18
0
        private void AddHeaderBtn_Click(object sender, EventArgs e)
        {
            using (SelectControl form = new SelectControl("Header"))
            {
                var result = form.ShowDialog();

                if (result == DialogResult.OK)
                {
                    MySql sql = new MySql();
                    sql.OpenConnection();
                    Header selectedHeader = sql.GetHeader(form._ids[0]);

                    selectedHeader.HeaderItems.Clear();
                    foreach (HeaderItem i in sql.GetHeaderItems(selectedHeader.HeaderId))
                    {
                        selectedHeader.addHeaderItem(i);
                    }

                    sql.CloseConnection();

                    HeaderPlacement place = new HeaderPlacement();

                    HeaderPanel.Controls.Clear();

                    foreach (HeaderItem item in selectedHeader.HeaderItems)
                    {
                        place.AddItem(item);
                    }

                    HeaderPanel.Controls.Add(place);

                    ChangeHeader.Enabled   = true;
                    HorizontalLine.Visible = true;
                    TextLabel.Visible      = true;

                    _currentTemplate.Header = selectedHeader;
                }
            }
        }
Ejemplo n.º 19
0
        public SectionSelection()
        {
            InitializeComponent();

            MySql sql = new MySql();

            sql.OpenConnection();

            AvailableSections = sql.GetSectionsList();

            AvailableSectionDGV.DataSource = AvailableSections;

            for (int a = 0; a < AvailableSectionDGV.ColumnCount - 2; a++)
            {
                AvailableSectionDGV.Columns[a].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
                SelectedSectionDGV.Columns[a].AutoSizeMode  = DataGridViewAutoSizeColumnMode.DisplayedCells;
            }

            AvailableSectionDGV.Columns[AvailableSectionDGV.ColumnCount - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            SelectedSectionDGV.Columns[AvailableSectionDGV.ColumnCount - 1].AutoSizeMode  = DataGridViewAutoSizeColumnMode.Fill;

            sql.CloseConnection();
        }
Ejemplo n.º 20
0
        private void SaveUserBtn_Click(object sender, EventArgs e)
        {
            bool changePass = false;

            try
            {
                if (FirstName.Text.Length <= 0)
                {
                    throw new Exception();
                }

                if (LastName.Text.Length <= 0)
                {
                    throw new Exception();
                }

                if (Password.Text.Length > 0)
                {
                    changePass = true;
                }

                if (AdminPrivilege.SelectedIndex == -1)
                {
                    throw new Exception();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Please Complete all the information");
                return;
            }

            bool admin = AdminPrivilege.SelectedItem.ToString().Equals("Yes");

            MySql sql = new MySql();

            sql.OpenConnection();

            if (changePass)
            {
                if (!sql.EditUser(id, FirstName.Text, LastName.Text, admin, Password.Text))
                {
                    return;
                }
                MessageBox.Show("User Information Successfully Changed");
                sql.CloseConnection();
                DialogResult = DialogResult.OK;
                Close();
            }
            else
            {
                if (!sql.EditUser(id, FirstName.Text, LastName.Text, admin))
                {
                    return;
                }
                MessageBox.Show("User Information Successfully Changed");
                sql.CloseConnection();
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Ejemplo n.º 21
0
 protected void Page_Unload(object sender, EventArgs e)
 {
     mysqlconnection.CloseConnection();
 }
        private void SetTemplateBtn_Click(object sender, EventArgs e)
        {
            var result = MessageBox.Show("[Yes] To load template.\n[No] To select header and sections separately."
                                         , "Choose Loading Method", MessageBoxButtons.YesNoCancel);

            if (result == DialogResult.Cancel)
            {
                return;
            }
            else
            {
                if (result == DialogResult.Yes)
                {
                    ChangeHeader.Visible    = false;
                    AddSectionBtn.Visible   = false;
                    SaveTemplateBtn.Enabled = false;

                    using (SelectControl form = new SelectControl("Template"))
                    {
                        var selectResult = form.ShowDialog();

                        if (selectResult == DialogResult.OK)
                        {
                            MySql sql = new MySql();
                            sql.OpenConnection();

                            string       sqlStatement = "select * from template where TemplateID = @id";
                            MySqlCommand cmd          = new MySqlCommand(sqlStatement);
                            cmd.Parameters.AddWithValue("@id", form._ids[0]);
                            DataTable template = sql.GetDataSetCmd(cmd);

                            _currentFeed.Header             = sql.GetHeader(template.Rows[0][1].ToString());
                            _currentFeed.Header.HeaderItems = sql.GetHeaderItems(_currentFeed.Header.HeaderId);
                            _currentFeed.Template           = sql.GetTemplate(form._ids[0]);

                            FillHeader();

                            _currentFeed.Sections.Clear();
                            cmd.Parameters.Clear();

                            sqlStatement = "SELECT * FROM template_section WHERE TemplateID = @id";
                            cmd          = new MySqlCommand(sqlStatement);
                            cmd.Parameters.AddWithValue("@id", form._ids[0]);
                            DataTable templateSections = sql.GetDataSetCmd(cmd);

                            foreach (DataRow row in templateSections.Rows)
                            {
                                _currentFeed.Sections.Add(sql.GetSection(row["SectionID"].ToString()));
                            }
                            FillSection();

                            sql.CloseConnection();
                        }
                    }
                }
                else //Will default to select header and sections
                {
                    try
                    {
                        setHeader();
                        ChangeHeader.Visible = true;
                        setSection();
                        AddSectionBtn.Visible   = true;
                        AddSectionBtn.Text      = "Change Section";
                        SaveTemplateBtn.Enabled = true;
                    } catch (Exception ex)
                    {
                        return;
                    }
                }
            }
        }
        private void ApplicantList_SelectedIndexChanged(object sender, EventArgs e)
        {
            SaveTemplateBtn.Enabled = false;
            ChangeHeader.Visible    = false;
            AddSectionBtn.Visible   = false;

            if (ApplicantList.SelectedIndex != -1)
            {
                PDFDisplay.DocumentText = "<HTML><CENTER>Loading...</CENTER></HTML>";

                Applicant app = (Applicant)ApplicantList.SelectedItem;
                _currentFeed.Applicant = app;

                if (app.Pdf != null)
                {
                    string tempFile = TempFileHandler.MakeTempFile(app.Pdf);
                    PDFDisplay.Navigate(tempFile);
                }
                else
                {
                    PDFDisplay.DocumentText = "<HTML><CENTER>No PDF found</CENTER></HTML>";
                }

                MySql sql = new MySql();
                sql.OpenConnection();

                DataTable Dt = sql.GetDataSet("SELECT * FROM feedbacksystem.feedback WHERE feedback.PositionID = " + _currentFeed.Position._positionId + " AND feedback.AppID = " + _currentFeed.Applicant.Id);
                if (Dt != null && Dt.Rows.Count > 0)
                {
                    Feedback tmpFeedback = sql.GetFeedback(Dt.Rows[0]["FeedbackID"].ToString());
                    _currentFeed.FeedbackID = Dt.Rows[0]["FeedbackID"].ToString();
                    _currentFeed.Header     = tmpFeedback.Header;
                    _currentFeed.Sections   = tmpFeedback.Sections;
                    FillHeader();
                    FillSection();

                    ChangeHeader.Visible  = !CheckPositionIsCompleted();
                    AddSectionBtn.Visible = !CheckPositionIsCompleted();

                    SaveFeedbackBtn.Text = "Update Feedback";
                }
                else
                {
                    SaveFeedbackBtn.Text    = "Save Feedback";
                    _currentFeed.FeedbackID = "";
                    if (_currentFeed.Header != null)
                    {
                        _currentFeed.Header.HeaderItems.Clear();
                        //in order to reset the header items value for the cascading
                        _currentFeed.Header.HeaderItems = sql.GetHeaderItems(_currentFeed.Header.HeaderId);
                        ChangeHeader.Visible            = true;

                        FillHeader();
                    }

                    if (_currentFeed.Sections.Count > 0)
                    {
                        foreach (Section sec in _currentFeed.Sections)
                        {
                            sec.Comment    = null;
                            sec.CodeChosen = null;
                            sec.IsChecked  = false;
                        }
                        AddSectionBtn.Visible = true;

                        FillSection();
                    }
                }

                sql.CloseConnection();
                SetTemplateBtn.Enabled = !CheckPositionIsCompleted();
            }
        }
        private void SaveFeedbackBtn_Click(object sender, EventArgs e)
        {
            if (PositionList.SelectedIndex == -1)
            {
                MessageBox.Show("Select a position", "Missing attributes!");
                return;
            }

            if (ApplicantList.SelectedIndex == -1)
            {
                MessageBox.Show("Select an applicant", "Missing attributes!");
                return;
            }

            if (_currentFeed.Header == null)
            {
                MessageBox.Show("Please select the header before proceeding", "Missing component!");
                return;
            }

            if (_currentFeed.Sections.Count <= 0)
            {
                MessageBox.Show("Please select the sections before proceeding", "Missing component!");
                return;
            }

            _currentFeed.ReviewerId = Reviewer.Id.ToString();

            //check if there are null values in the header
            foreach (HeaderItem item in _currentFeed.Header.HeaderItems)
            {
                Control control = Controls.Find("header" + item.Id, true)[0];

                try
                {
                    switch (control.GetType().Name)
                    {
                    case "TextBox":
                    case "Label":
                        item.ValueChosen = ((TextBox)control).Text;
                        break;

                    case "ComboBox":
                        item.ValueChosen = ((ComboBox)control).SelectedItem.ToString();
                        break;

                    case "DateTimePicker":
                        item.ValueChosen = ((DateTimePicker)control).Value.ToString("dd/MM/yyyy");
                        break;
                    }

                    if (item.ValueChosen.Length <= 0)
                    {
                        throw new NullReferenceException();
                    }
                }
                catch (NullReferenceException)
                {
                    MessageBox.Show("Please complete the header before proceeding", "Missing attributes!");
                    return;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error!");
                    return;
                }
            }

            bool sectionChecked = false;

            //check if there is null values in the sections
            foreach (Section s in _currentFeed.Sections)
            {
                RichTextBox text    = (RichTextBox)Controls.Find("comment" + s.SectionId, true)[0];
                ComboBox    codes   = (ComboBox)Controls.Find("codes" + s.SectionId, true)[0];
                CheckBox    checker = (CheckBox)Controls.Find("checker" + s.SectionId, true)[0];


                if (codes.SelectedIndex == -1)
                {
                    MessageBox.Show("Please complete the sections before proceeding -> Codes", "Missing attributes!");
                    return;
                }

                //Assign values to section object
                s.Comment    = text.Text;
                s.CodeChosen = codes.SelectedItem.ToString();
                s.IsChecked  = checker.Checked;

                if (s.Comment.Length <= 0)
                {
                    MessageBox.Show("Please complete the sections before proceeding -> Comment", "Missing attributes!");
                    return;
                }

                if (s.IsChecked)
                {
                    sectionChecked = true;
                }
            }

            if (!sectionChecked)
            {
                MessageBox.Show("Please check at least one section!", "Missing attributes!");
                return;
            }

            //end of field checkers

            MySql sql = new MySql();

            sql.OpenConnection();
            try
            {
                //update or insert the feedback
                if (String.IsNullOrEmpty(_currentFeed.FeedbackID))
                {
                    if (sql.SaveFeedback(_currentFeed))
                    {
                        MessageBox.Show("Feedback successfully saved.");
                    }
                }
                else
                {
                    if (sql.UpdateFeedback(_currentFeed))
                    {
                        MessageBox.Show("Feedback successfully updated.");
                    }
                }

                //checks whether is all the applications for the position is completed

                if (CheckPositionIsCompleted()) //means all of the applications have generated the feedback
                {
                    var result = MessageBox.Show("All the feedbacks for this current position: " + _currentFeed.Position._positionName + " is completed. \n Please choose the file name of the attachehment to be send to the applicants. \n Yes for Applicant name or No for Applicant code"
                                                 , "Select file name", MessageBoxButtons.YesNo);

                    //true for name false for code
                    bool filename = (result == DialogResult.Yes ? true : false);

                    try
                    {
                        int count = 0;

                        SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");


                        foreach (Applicant app in sql.GetEmailList(_currentFeed.Position._positionId))
                        {
                            string      currentFilename = (filename ? app.Name : app.Id);
                            MailMessage mail            = new MailMessage(new MailAddress("*****@*****.**"), new MailAddress(app.Email));
                            mail.Subject = "Application feedback for " + _currentFeed.Position._positionName + " in HappyTech.";
                            mail.Body    = "Hi " + app.Name + ",\nPlease find the attached file as the feedback from us regarding your application at HappyTech. \n\nRegards,\nHappy Tech HR";

                            System.Net.Mail.Attachment attachment;
                            attachment = new System.Net.Mail.Attachment(TempFileHandler.MakeTempFilePdf(app.Pdf, currentFilename));
                            mail.Attachments.Add(attachment);

                            SmtpServer.Port                  = 587;
                            SmtpServer.DeliveryMethod        = SmtpDeliveryMethod.Network;
                            SmtpServer.UseDefaultCredentials = false;
                            SmtpServer.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "happytech123");
                            SmtpServer.EnableSsl             = true;

                            SmtpServer.Send(mail);
                            count++;
                        }
                        MessageBox.Show("Total of " + count + " emails are sent.");
                    } catch (Exception exc)
                    {
                        throw exc;
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.ToString(), "Ops! Error occured!");
            }
            finally
            {
                sql.CloseConnection();
            }
        }