Example #1
0
        private void AddWorkerBtn_CLick(object sender, EventArgs e)
        {
            if (textBox_name.Text == "" ||
                textBox_surname.Text == "" ||
                textBox_Pesel.Text == "" ||
                textBox_street.Text == "" ||
                textBox_Code.Text == "" ||
                textBox_city.Text == "" ||
                textBox_Phone.Text == "" ||
                textBox_email.Text == "" ||
                textBox_stat.Text == "")
            {
                MessageBox.Show("Uzupełnij wszystkie pola");
            }
            else
            {
                string[] values = new string[]
                {
                    textBox_name.Text,
                    textBox_surname.Text,
                    textBox_Pesel.Text,
                    textBox_street.Text,
                    textBox_Code.Text,
                    textBox_city.Text,
                    textBox_Phone.Text,
                    textBox_email.Text,
                    textBox_stat.Text
                };

                FormIntoDatabase form;

                if (IsForEditing)
                {
                    form = new FormIntoDatabase("UPDATE Pracownicy SET Imie = $, Nazwisko = $, Pesel = $, Ulica = $, KodPocztowy = $, Miejscowosc = $,Telefon = $, Email = $," +
                                                "Stanowisko = $ WHERE Id = " + Id, values);
                }
                else
                {
                    form = new FormIntoDatabase("INSERT INTO Pracownicy VALUES($, $, $, $, $, $, $, $, $) ", values);
                }
                form.Qery();

                this.Close();
            }
        }
Example #2
0
        private void AddMainBtn_Click(object sender, EventArgs e)
        {
            if (comboBox_year.SelectedIndex == -1 || comboBox_month.SelectedIndex == -1 || comboBox_station.SelectedIndex == -1 || listView_TimeTable.Items.Count == 0)
            {
                MessageBox.Show("Nie wypełniłeś wszystkich pól");
            }
            else
            {
                string harmName;

                if (numericUpDown_Id.Value == 0)
                {
                    harmName = numericUpDown_Id.Value + "_" + comboBox_year.SelectedItem.ToString() + "_" + comboBox_month.SelectedItem.ToString();
                }
                else
                {
                    harmName = new Random().Next(0, 9999999).ToString() + "_" + comboBox_year.SelectedItem.ToString() + "_" + comboBox_month.SelectedItem.ToString();
                }

                FormIntoDatabase form = new FormIntoDatabase("ALTER TABLE Harmonogramy ADD [" + harmName + "] VARCHAR(MAX) ", new string[] { harmName });
                form.Qery();

                for (int i = 0; i < listView_TimeTable.Items.Count; i++)
                {
                    string row = "";
                    for (int j = 0; j < listView_TimeTable.Items[i].SubItems.Count; j++)
                    {
                        row += listView_TimeTable.Items[i].SubItems[j].Text + "#";
                    }
                    form = new FormIntoDatabase("UPDATE Harmonogramy SET [" + harmName + "]=$ WHERE Id = $", new string[] { row, (i + 1).ToString() });
                    form.Qery();
                }

                listView_TimeTable.Items.Clear();
                listView_TimeTable.Columns.Clear();

                this.Close();
            }
        }
Example #3
0
        private void AddResourceBtnClick(object sender, EventArgs e)
        {
            if (textBoxResName.Text == "" ||
                textBoxResDescr.Text == "")
            {
                MessageBox.Show("Uzupełnij wszystkie pola");
            }
            else
            {
                string[]         values = new string[] { textBoxResName.Text, textBoxResDescr.Text, numericUpDownResources.Value.ToString() };
                FormIntoDatabase form;
                if (IsForEditing)
                {
                    form = new FormIntoDatabase("UPDATE Zasoby SET nazwa = $, opis = $, ilosc = $ WHERE Id = " + Id, values);
                }
                else
                {
                    form = new FormIntoDatabase("INSERT INTO Zasoby VALUES($,$,$)", values);
                }
                form.Qery();

                this.Close();
            }
        }
        private void AddStationButton_Click(object sender, EventArgs e)
        {
            if (textBox_stat_descr.Text == "" ||
                textBox_stat_name.Text == "")
            {
                MessageBox.Show("Uzupełnij wszystkie pola");
            }
            else
            {
                string[]         values = new string[] { textBox_stat_name.Text, textBox_stat_descr.Text, numericUpDown_nb_workers.Value.ToString() };
                FormIntoDatabase form;
                if (IsForEditing)
                {
                    form = new FormIntoDatabase("UPDATE Stanowiska SET nazwa_stanowiska = $, opis_stanowiska = $, liczba_pracownikow = $ WHERE Id = " + Id, values);
                }
                else
                {
                    form = new FormIntoDatabase("INSERT INTO Stanowiska(nazwa_stanowiska,opis_stanowiska,liczba_pracownikow) VALUES($,$,$)", values);
                }
                form.Qery();

                this.Close();
            }
        }