Esempio n. 1
0
        /// <summary>
        /// Vindt een personeelslid via pincode
        /// </summary>
        /// <param name="pincode">De pincode waarop gezocht wordt</param>
        /// <returns>Een Personeel object</returns>
        public Personeel GetByPincode(string pincode)
        {
            dbConnection.Open();

            var command = new SqlCommand("SELECT * FROM personeel WHERE pincode=@pincode", dbConnection);

            command.Parameters.AddWithValue("@pincode", pincode);

            var reader = command.ExecuteReader();

            Personeel werknemer = null;

            while (reader.Read())
            {
                // Creeer een nieuw werknemer model
                werknemer = ReadPersoneel(reader);
            }

            //Voorkomt error bij verkeerde input
            try { personeelId = werknemer.Id; }
            catch { personeelId = 1; }

            //sluit de connectie
            dbConnection.Close();

            return(werknemer);
        }
Esempio n. 2
0
        /// <summary>
        /// Event voor de Button om personeel toe te voegen, roept InputForm_AddUser
        /// </summary>
        /// <param name="sender">De Button waar op gedrukt is</param>
        /// <param name="e"></param>
        private void btnAddEmployee_Click(object sender, EventArgs e)
        {
            Personeel p = new Personeel();

            if (InputForm_AddUser(ref p) == DialogResult.OK)
            {
                dao.AddEmployee(p.Username, p.Pincode, p.Functie);
                CreateList();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Genereert een lijst van al het personeel in de database
        /// </summary>
        /// <returns>List met objecten van type Personeel</returns>
        public List <Personeel> GetAll()
        {
            dbConnection.Open();

            SqlCommand command = new SqlCommand("SELECT * FROM personeel", dbConnection);

            SqlDataReader reader = command.ExecuteReader();

            List <Personeel> allePersoneel = new List <Personeel>();

            while (reader.Read())
            {
                Personeel personeel = ReadPersoneel(reader);
                allePersoneel.Add(personeel);
            }

            dbConnection.Close();

            return(allePersoneel);
        }
Esempio n. 4
0
        /// <summary>
        /// Pop-up dialog voor het toevoegen van personeel
        /// </summary>
        /// <param name="personeel"></param>
        /// <returns>De waarde van de gekozen DialogResult</returns>
        private DialogResult InputForm_AddUser(ref Personeel personeel)
        {
            Form     form       = new Form();
            Label    lblNaam    = new Label();
            Label    lblPin     = new Label();
            Label    lblFunctie = new Label();
            TextBox  tbNaam     = new TextBox();
            TextBox  tbPin      = new TextBox();
            ComboBox cbFunctie  = new ComboBox();
            Button   btnOk      = new Button();
            Button   btnCancel  = new Button();

            form.Text = "Personeel toevoegen";

            lblNaam.Text    = "Naam";
            lblPin.Text     = "Pincode";
            lblFunctie.Text = "Functie";

            tbNaam.Text = "";
            tbPin.Text  = "";

            cbFunctie.Items.Add("Manager");
            cbFunctie.Items.Add("Keuken");
            cbFunctie.Items.Add("Bar");
            cbFunctie.Items.Add("Bediening");
            cbFunctie.SelectedIndex = 3;

            btnOk.Text             = "Toevoegen";
            btnCancel.Text         = "Annuleren";
            btnOk.DialogResult     = DialogResult.OK;
            btnCancel.DialogResult = DialogResult.Cancel;

            lblNaam.SetBounds(9, 3, 372, 13);
            tbNaam.SetBounds(12, 17, 372, 20);

            lblPin.SetBounds(9, 49, 372, 13);
            tbPin.SetBounds(12, 63, 372, 20);

            lblFunctie.SetBounds(9, 95, 372, 13);
            cbFunctie.SetBounds(12, 109, 372, 20);
            cbFunctie.DropDownStyle = ComboBoxStyle.DropDownList;

            btnOk.SetBounds(182, 141, 100, 25);
            btnCancel.SetBounds(285, 141, 100, 25);

            tbNaam.MaxLength = 15;
            tbPin.MaxLength  = 4;

            lblNaam.AutoSize    = true;
            lblPin.AutoSize     = true;
            lblFunctie.AutoSize = true;

            tbNaam.Anchor    = tbNaam.Anchor | AnchorStyles.Right;
            tbPin.Anchor     = tbPin.Anchor | AnchorStyles.Right;
            cbFunctie.Anchor = cbFunctie.Anchor | AnchorStyles.Right;
            btnOk.Anchor     = AnchorStyles.Bottom | AnchorStyles.Right;
            btnCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 169);
            form.Controls.AddRange(new Control[] { lblNaam, lblPin, lblFunctie,
                                                   tbNaam, tbPin, cbFunctie, btnOk, btnCancel });
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition   = FormStartPosition.CenterScreen;
            form.MinimizeBox     = false;
            form.MaximizeBox     = false;
            form.AcceptButton    = btnOk;
            form.CancelButton    = btnCancel;

            DialogResult result = form.ShowDialog();

            if (result == DialogResult.OK)
            {
                personeel.Username = tbNaam.Text;
                personeel.Pincode  = tbPin.Text;
                personeel.Functie  = cbFunctie.Text;
            }
            return(result);
        }