コード例 #1
0
ファイル: DashForm.cs プロジェクト: BlackSun93/happyTech
        /// <summary>
        /// Constructor of the DashForm Class
        /// </summary>
        /// <param name="mode"> either "newApp" or "default"</param>
        public DashForm(Mode mode)
        {
            InitializeComponent();

            currentMode = mode;

            Clear_TemporaryFiles();

            Label_Username.Text = $"{Recruiter.GetInstance().Name}.";

            // Gets all the templates from the database
            DataSet templateDB = Connection.GetDbConn().GetDataSet(SqlQueries.SelectTemplateType());

            for (int i = 0; i < templateDB.Tables[0].Rows.Count; i++)
            {
                // Populate the tempTypeBox with the name of the Templates
                ListBox_TemplateList.Items.Add(templateDB.Tables[0].Rows[i].ItemArray.GetValue(0));
            }

            // Check if there are not templates, if so, let the user know to create one
            if (templateDB.Tables[0].Rows.Count > 0)
            {
                ListBox_TemplateList.Show();
                Label_NoTemplates.Hide();
                Label_CreateTemplate.Hide();
                Button_NewEditor.Hide();
            }
            else
            {
                ListBox_TemplateList.Hide();
                Label_NoTemplates.Show();
                Label_CreateTemplate.Show();
                Button_NewEditor.Show();
            }

            // Switch constructor checks the mode parameter: ToLower() to make it not case sensitive.
            switch (currentMode)
            {
            case Mode.Applicant:
                // Checks whether the list of the applicants is not empty
                if (Applicant.applicants.Count > 0)
                {
                    // Displays the btBack object
                    Button_Cancel.Visible = true;
                }
                break;

            case Mode.Default:
                // Deletes all the items in the applicants and templatesForApplicants lists
                // Deletes the applicants from the Database
                Applicant.applicants.Clear();
                Template.templatesForApplicants.Clear();
                Connection.GetDbConn().CreateCommand(SqlQueries.DeleteApplicant());
                break;

            default:
                // Do nothing
                break;
            }
        }
コード例 #2
0
ファイル: DashForm.cs プロジェクト: BlackSun93/happyTech
 /// <summary>
 ///
 ///     Click tigger function for the logout button.
 ///     This will remove all progress the user has
 ///     made and send them back to the login form.
 ///
 /// </summary>
 private void Button_Logout_Click(object sender, EventArgs e)
 {
     if (Button_Logout.Text.Equals("Are you sure?"))
     {
         Hide();
         Recruiter.DestroyInstance();                                        // Recruiter instance is destroied
         Applicant.applicants.Clear();                                       // Applicants list is cleared
         Template.templatesForApplicants.Clear();
         Connection.GetDbConn().CreateCommand(SqlQueries.DeleteApplicant()); // Applicants are deleted from the database
         LoginForm instance_LoginForm = new LoginForm();                     // Returns to the login form
         instance_LoginForm.Show();
     }
     else
     {
         Button_Logout.Text = "Are you sure?";
     }
 }