Ejemplo n.º 1
0
        private void btnHandleStaff_Click(object sender, RoutedEventArgs e)
        {
            Staffwindow win = new Staffwindow();

            win.Show();
            this.Close();
        }
Ejemplo n.º 2
0
        private void buttonExit_Click(object sender, RoutedEventArgs e)
        {
            Staffwindow win = new Staffwindow();

            win.Show();
            this.Close();
        }
Ejemplo n.º 3
0
        private void buttonUpdate_Click(object sender, RoutedEventArgs e)
        {
            DbOperations db = new DbOperations();

            int    staffid   = int.Parse(textBoxID.Text);
            string fname     = textBoxFirstname.Text;
            string lname     = textBoxLastname.Text;
            string prof      = textBoxProfession.Text;
            int    sectionid = int.Parse(textBoxSection.Text);

            try
            {
                if (fname == "" || lname == "" || prof == "")
                {
                    MessageBox.Show("Vänligen ange både förnamn, efternamn och roll.");
                    return;
                }
                else if (sectionid == 0 || sectionid > 4)
                {
                    MessageBox.Show("Felaktigt avdelnings-id.");
                    return;
                }
                else
                {
                    db.UpdateStaff(staffid, fname, lname, prof, sectionid);
                    Staffwindow win = new Staffwindow();
                    EmptyTextBoxes();
                    MessageBox.Show($"Personalregistret uppdaterat", "Lyckad inmatning");

                    win.Show();
                    this.Close();
                }
            }
            catch (PostgresException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 4
0
        private void buttonAdd_Click(object sender, RoutedEventArgs e)
        {
            DbOperations db         = new DbOperations();
            string       fname      = textBoxFirstname.Text;
            string       lname      = textBoxLastname.Text;
            string       profession = textBoxProfession.Text;

            if (textBoxSection.Text == "")
            {
                MessageBox.Show("Vänligen ange ett avdelnings-id");
                return;
            }

            int section = int.Parse(textBoxSection.Text); //Lägg till en check som kollar om inmatningen har bokstäver

            if (fname == null || lname == null || profession == null)
            {
                MessageBox.Show("Vänligen ange ett förnamn, efternamn, roll samt en avdelning");
                return;
            }

            try
            {
                db.AddNewStaff(fname, lname, profession, section);
                MessageBox.Show($"{fname} {lname} är nu tillagd i personalregistret", "Titel");
                EmptyTextboxes();

                Staffwindow win = new Staffwindow();
                win.Show();
                this.Close();
            }
            catch (PostgresException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }