Exemple #1
0
        private void addInvoiceButton_Click(object sender, EventArgs e)
        {
            IFormatter          formatter = new BinaryFormatter();
            Stream              stream    = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
            DBDataSerialization dbds      = (DBDataSerialization)formatter.Deserialize(stream);

            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                openFileDialog.Title            = "Wybierz plik PDF  z fakturą";
                openFileDialog.ShowDialog();
                File.Copy(openFileDialog.FileName, dbds.path + "\\" + openFileDialog.SafeFileName);
                invoicesListBox.Items.Clear();
                string[] filePaths = Directory.GetFiles(dbds.path + "\\");
                foreach (string asd in filePaths)
                {
                    invoicesListBox.Items.Add(asd);
                }
                logWriting logWriting = new logWriting("Użytkownik dodał fakturę.");
            }
            catch (IOException ioex)
            {
                MessageBox.Show("Plik o danej nazwie już istnieje!", "Plik nie został dodany!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
        private void modifyProductionButton_Click(object sender, EventArgs e)
        {
            var item     = itemTextBox.Text;
            var amount   = int.Parse(amountTextBox.Text);
            var position = positionTextBox.Text;
            var date     = dateTextBox.Text;

            IFormatter          formatter    = new BinaryFormatter();
            Stream              stream       = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
            DBDataSerialization dbds         = (DBDataSerialization)formatter.Deserialize(stream);
            DBConnection        dBConnection = new DBConnection(dbds.dbhost, dbds.dbname, dbds.dblogin, dbds.dbpassword);

            dBConnection.UpdateProductionPlan(id, item, amount, position, date);

            planListBox.Items.Clear();
            List <string>[] list  = dBConnection.CheckProductionPlan();
            var             index = 0;

            foreach (var i in list[0])
            {
                planListBox.Items.Add(list[1].ElementAt(index).ToString() + " | " + list[2].ElementAt(index).ToString() + " | " + list[3].ElementAt(index).ToString() + " | " + list[4].ElementAt(index).ToString());
                index++;
            }
            logWriting logWriting = new logWriting("Użytkownik zmodyfikował istniejącą produkcję.");
        }
Exemple #3
0
        private void modifyAccountButton_Click(object sender, EventArgs e)
        {
            IFormatter          formatter    = new BinaryFormatter();
            Stream              stream       = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
            DBDataSerialization dbds         = (DBDataSerialization)formatter.Deserialize(stream);
            DBConnection        dBConnection = new DBConnection(dbds.dbhost, dbds.dbname, dbds.dblogin, dbds.dbpassword);

            string        firstName       = firstNameTextBox.Text;
            string        lastName        = lastNameTextBox.Text;
            string        login           = loginTextBox.Text;
            string        emailAddress    = emailAddressTextBox.Text;
            string        birthday        = birthdayTextBox.Text;
            string        employmentMonth = employmentTextBox.Text;
            PwdEncryption pwde            = new PwdEncryption();
            string        password        = pwde.GenerateHash(passwordTextBox.Text);
            string        pwdhash         = File.ReadAllText("salt.txt");

            File.Delete("salt.txt");
            dBConnection.Update(firstName, lastName, birthday, login, employmentMonth, emailAddress, password, pwdhash, id);
            logWriting logWriting = new logWriting("Użytkownik zmodyfikował konto.");

            existingAccountsListBox.Items.Clear();
            List <string>[] list  = dBConnection.CheckLogin();
            var             index = 0;

            foreach (var item in list[3])
            {
                existingAccountsListBox.Items.Add(list[3].ElementAt(index).ToString() + " " + list[4].ElementAt(index).ToString());
                index++;
            }
        }
Exemple #4
0
        private void removeItemButton_Click(object sender, EventArgs e)
        {
            if (inventoryListBox.SelectedItems.Count < 1)
            {
                MessageBox.Show("Musisz wybrać jedną pozycję, aby móc ją usunąć.", "Nie wybrano żadnej pozycji", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                DialogResult dialogResult = MessageBox.Show("Czy na pewno chcesz usunąć wybraną pozycję?", "Usunięcie pozycji", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                if (dialogResult == DialogResult.Yes)
                {
                    IFormatter          formatter    = new BinaryFormatter();
                    Stream              stream       = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
                    DBDataSerialization dbds         = (DBDataSerialization)formatter.Deserialize(stream);
                    DBConnection        dBConnection = new DBConnection(dbds.dbhost, dbds.dbname, dbds.dblogin, dbds.dbpassword);
                    dBConnection.DeleteInventoryPosition(id);

                    inventoryListBox.Items.Clear();
                    List <string>[] list  = dBConnection.CheckInventory();
                    var             index = 0;
                    foreach (var item in list[0])
                    {
                        inventoryListBox.Items.Add(list[1].ElementAt(index).ToString() + " | " + list[2].ElementAt(index).ToString() + " | " + list[3].ElementAt(index).ToString());
                        index++;
                    }
                    logWriting logWriting = new logWriting("Użytkownik usunął przedmiot z magazynu.");
                }
            }
        }
Exemple #5
0
        private void modifyExistingItemButton_Click(object sender, EventArgs e)
        {
            if (inventoryListBox.SelectedItems.Count < 1)
            {
                MessageBox.Show("Musisz wybrać jedną pozycję, aby móc ją edytować.", "Nie wybrano żadnej pozycji", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                var inventoryCode = inventoryCodeTextBox.Text;
                var name          = nameTextBox.Text;
                var amount        = int.Parse(amountTextBox.Text);

                IFormatter          formatter    = new BinaryFormatter();
                Stream              stream       = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
                DBDataSerialization dbds         = (DBDataSerialization)formatter.Deserialize(stream);
                DBConnection        dBConnection = new DBConnection(dbds.dbhost, dbds.dbname, dbds.dblogin, dbds.dbpassword);
                dBConnection.UpdateInventory(id, inventoryCode, name, amount);

                inventoryListBox.Items.Clear();
                List <string>[] list  = dBConnection.CheckInventory();
                var             index = 0;
                foreach (var item in list[0])
                {
                    inventoryListBox.Items.Add(list[1].ElementAt(index).ToString() + " | " + list[2].ElementAt(index).ToString() + " | " + list[3].ElementAt(index).ToString());
                    index++;
                }
                logWriting logWriting = new logWriting("Użytkownik zmodyfikował przedmiot w magazynie.");
            }
        }
Exemple #6
0
        private void modifyEmployeeButton_Click(object sender, EventArgs e)
        {
            IFormatter          formatter    = new BinaryFormatter();
            Stream              stream       = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
            DBDataSerialization dbds         = (DBDataSerialization)formatter.Deserialize(stream);
            DBConnection        dBConnection = new DBConnection(dbds.dbhost, dbds.dbname, dbds.dblogin, dbds.dbpassword);

            string firstName             = firstNameTextBox.Text;
            string lastName              = lastNameTextBox.Text;
            string fathersName           = fathersNameTextBox.Text;
            string mothersName           = mothersNameTextBox.Text;
            string birthday              = birthdayTextBox.Text;
            string placeOfResidence      = placeOfResidenceTextBox.Text;
            string correspondenceAddress = correspondenceAddressTextBox.Text;
            string education             = educationTextBox.Text;
            string historyOfEmployment   = historyOfEmploymentTextBox.Text;
            int    pesel              = int.Parse(peselTextBox.Text);
            string childrensNames     = childrensNamesTextBox.Text;
            string childrensBirthdays = childrensBirthdaysTextBox.Text;

            dBConnection.UpdateEmployee(firstName, lastName, fathersName, mothersName, birthday, placeOfResidence, correspondenceAddress, education, historyOfEmployment, pesel, childrensNames, childrensBirthdays, id);
            logWriting logWriting = new logWriting("Użytkownik zmodyfikował pracownika.");

            employeesListBox.Items.Clear();
            List <string>[] list  = dBConnection.EmployeesList();
            var             index = 0;

            foreach (var item in list[3])
            {
                employeesListBox.Items.Add(list[0].ElementAt(index).ToString() + " " + list[1].ElementAt(index).ToString());
                index++;
            }
        }
Exemple #7
0
        private void modifyOrderButton_Click(object sender, EventArgs e)
        {
            if (ordersListBox.SelectedItems.Count < 1)
            {
                MessageBox.Show("Aby móc zmodyfikować pozycję, najpierw musisz jakąś wybrać.", "Nie wybrano pozycji", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                var client   = clientTextBox.Text;
                var itemname = itemNameTextBox.Text;
                var amount   = int.Parse(amountTextBox.Text);
                var date     = dateTextBox.Text;

                IFormatter          formatter    = new BinaryFormatter();
                Stream              stream       = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
                DBDataSerialization dbds         = (DBDataSerialization)formatter.Deserialize(stream);
                DBConnection        dBConnection = new DBConnection(dbds.dbhost, dbds.dbname, dbds.dblogin, dbds.dbpassword);
                dBConnection.UpdateOrders(id, client, itemname, amount, date);

                ordersListBox.Items.Clear();
                List <string>[] list  = dBConnection.CheckOrders();
                var             index = 0;
                foreach (var item in list[0])
                {
                    ordersListBox.Items.Add(list[1].ElementAt(index).ToString() + " | " + list[2].ElementAt(index).ToString() + " | " + list[3].ElementAt(index).ToString() + " | " + list[4].ElementAt(index).ToString());
                    index++;
                }
                logWriting logWriting = new logWriting("Użytkownik zmodyfikował istniejące zamówienie.");
            }
        }
Exemple #8
0
        private void modifyButton_Click(object sender, EventArgs e)
        {
            IFormatter          formatter    = new BinaryFormatter();
            Stream              stream       = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
            DBDataSerialization dbds         = (DBDataSerialization)formatter.Deserialize(stream);
            DBConnection        dBConnection = new DBConnection(dbds.dbhost, dbds.dbname, dbds.dblogin, dbds.dbpassword);

            string companyName  = companyNameTextBox.Text;
            int    companyNIP   = int.Parse(companyNIPTextBox.Text);
            int    companyREGON = int.Parse(companyREGONTextBox.Text);
            int    companyKRS   = int.Parse(companyKRSTextBox.Text);

            dBConnection.UpdateCompanyDetails(1, companyName, companyNIP, companyREGON, companyKRS);
            logWriting logWriting = new logWriting("Użytkownik zmodyfikował dane firmy.");
        }
Exemple #9
0
        private void removeInvoiceButton_Click(object sender, EventArgs e)
        {
            IFormatter          formatter = new BinaryFormatter();
            Stream              stream    = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
            DBDataSerialization dbds      = (DBDataSerialization)formatter.Deserialize(stream);

            File.Delete(invoicesListBox.SelectedItem.ToString());
            invoicesListBox.Items.Clear();
            string[] filePaths = Directory.GetFiles(dbds.path + "\\");
            foreach (string asd in filePaths)
            {
                invoicesListBox.Items.Add(asd);
            }
            logWriting logWriting = new logWriting("Użytkownik usunął fakturę.");
        }
Exemple #10
0
        private void generateNewEmployeeFiles_Click(object sender, EventArgs e)
        {
            ProcessStartInfo info = new ProcessStartInfo();

            info.Verb           = "print";
            info.FileName       = @"files\Umowa o pracę - wzór.pdf";
            info.CreateNoWindow = true;
            info.WindowStyle    = ProcessWindowStyle.Hidden;

            Process p = new Process();

            p.StartInfo = info;
            p.Start();

            p.WaitForInputIdle();
            System.Threading.Thread.Sleep(5000);
            if (false == p.CloseMainWindow())
            {
                p.Kill();
            }

            ProcessStartInfo info2 = new ProcessStartInfo();

            info2.Verb           = "print";
            info2.FileName       = @"files\Regulamin pracy.pdf";
            info2.CreateNoWindow = true;
            info2.WindowStyle    = ProcessWindowStyle.Hidden;

            Process p2 = new Process();

            p2.StartInfo = info2;
            p2.Start();

            p2.WaitForInputIdle();
            System.Threading.Thread.Sleep(5000);
            if (false == p2.CloseMainWindow())
            {
                p2.Kill();
            }

            logWriting logWriting = new logWriting("Użytkownik wydrukował pakiet nowego pracownika.");
        }
Exemple #11
0
        private void addNewProductionButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(itemTextBox.Text))
            {
                MessageBox.Show("Pole przedmiot nie może być puste. Proszę o poprawienie.", "Puste pole przedmiot", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(amountTextBox.Text))
            {
                MessageBox.Show("Pole ilość nie może być puste. Proszę o poprawienie.", "Puste pole ilość", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(positionTextBox.Text))
            {
                MessageBox.Show("Pole gdzie nie może być puste. Proszę o poprawienie.", "Puste pole gdzie", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(dateTextBox.Text))
            {
                MessageBox.Show("Pole kiedy nie może być puste. Proszę o poprawienie.", "Puste pole kiedy", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!int.TryParse(amountTextBox.Text, out var test))
            {
                var item     = itemTextBox.Text;
                var amount   = int.Parse(amountTextBox.Text);
                var position = positionTextBox.Text;
                var date     = dateTextBox.Text;

                IFormatter          formatter    = new BinaryFormatter();
                Stream              stream       = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
                DBDataSerialization dbds         = (DBDataSerialization)formatter.Deserialize(stream);
                DBConnection        dBConnection = new DBConnection(dbds.dbhost, dbds.dbname, dbds.dblogin, dbds.dbpassword);
                dBConnection.InsertNewProduction(item, amount, position, date);

                planListBox.Items.Clear();
                List <string>[] list  = dBConnection.CheckProductionPlan();
                var             index = 0;
                foreach (var i in list[0])
                {
                    planListBox.Items.Add(list[1].ElementAt(index).ToString() + " | " + list[2].ElementAt(index).ToString() + " | " + list[3].ElementAt(index).ToString() + " | " + list[4].ElementAt(index).ToString());
                    index++;
                }
                logWriting logWriting = new logWriting("Użytkownik dodał nową produkcję.");
            }
        }
Exemple #12
0
        private void addOperationButton_Click(object sender, EventArgs e)
        {
            IFormatter          formatter    = new BinaryFormatter();
            Stream              stream       = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
            DBDataSerialization dbds         = (DBDataSerialization)formatter.Deserialize(stream);
            DBConnection        dBConnection = new DBConnection(dbds.dbhost, dbds.dbname, dbds.dblogin, dbds.dbpassword);

            if (string.IsNullOrWhiteSpace(receiverTextBox.Text))
            {
                MessageBox.Show("Pole odbiorca nie może być puste. Proszę o uzupełnienie.", "Puste pole odbiorca", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(amountTextBox.Text))
            {
                MessageBox.Show("Pole wartość nie może być puste. Proszę o uzupełnienie.", "Puste pole wartość", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(categoryTextBox.Text))
            {
                MessageBox.Show("Pole kategoria nie może być puste. Proszę o uzupełnienie.", "Puste pole kategoria", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!int.TryParse(amountTextBox.Text, out var test))
            {
                MessageBox.Show("Pole wartość musi być liczbą. Proszę o poprawienie.", "Błędna zawartość pola wartość", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (dBConnection.ConnectionTest())
            {
                //List<string>[] list = dBConnection.CheckFinancialOperations();

                var receiver = receiverTextBox.Text;
                var amount   = amountTextBox.Text;
                var category = categoryTextBox.Text;
                dBConnection.InsertNewFinancialOperation(receiver, amount, category);
                logWriting logWriting = new logWriting("Użytkownik dodał nową operację finansową.");
                financialOperationsListBox.Items.Clear();
                List <string>[] list  = dBConnection.CheckFinancialOperations();
                var             index = 0;
                foreach (var item in list[0])
                {
                    financialOperationsListBox.Items.Add(list[0].ElementAt(index).ToString());
                    index++;
                }
            }
        }
Exemple #13
0
        private void addNewOrderButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(clientTextBox.Text))
            {
                MessageBox.Show("Pole klient nie może być puste. Proszę o poprawienie.", "Puste pole klient", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(itemNameTextBox.Text))
            {
                MessageBox.Show("Pole nazwa nie może być puste. Proszę o poprawienie.", "Puste pole nazwa", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(amountTextBox.Text))
            {
                MessageBox.Show("Pole ilość nie może być puste. Proszę o poprawienie.", "Puste pole ilość", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(dateTextBox.Text))
            {
                MessageBox.Show("Pole data nie może być puste. Proszę o poprawienie.", "Puste pole data", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!int.TryParse(amountTextBox.Text, out var test))
            {
                var client   = clientTextBox.Text;
                var itemname = itemNameTextBox.Text;
                var amount   = int.Parse(amountTextBox.Text);
                var date     = dateTextBox.Text;

                IFormatter          formatter    = new BinaryFormatter();
                Stream              stream       = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
                DBDataSerialization dbds         = (DBDataSerialization)formatter.Deserialize(stream);
                DBConnection        dBConnection = new DBConnection(dbds.dbhost, dbds.dbname, dbds.dblogin, dbds.dbpassword);
                dBConnection.InsertNewOrder(client, itemname, amount, date);

                ordersListBox.Items.Clear();
                List <string>[] list  = dBConnection.CheckOrders();
                var             index = 0;
                foreach (var item in list[0])
                {
                    ordersListBox.Items.Add(list[1].ElementAt(index).ToString() + " | " + list[2].ElementAt(index).ToString() + " | " + list[3].ElementAt(index).ToString() + " | " + list[4].ElementAt(index).ToString());
                    index++;
                }
                logWriting logWriting = new logWriting("Użytkownik dodał nowe zamówienie.");
            }
        }
Exemple #14
0
        private void deleteProductionButton_Click(object sender, EventArgs e)
        {
            IFormatter          formatter    = new BinaryFormatter();
            Stream              stream       = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
            DBDataSerialization dbds         = (DBDataSerialization)formatter.Deserialize(stream);
            DBConnection        dBConnection = new DBConnection(dbds.dbhost, dbds.dbname, dbds.dblogin, dbds.dbpassword);

            dBConnection.DeleteProduction(id);

            planListBox.Items.Clear();
            List <string>[] list  = dBConnection.CheckProductionPlan();
            var             index = 0;

            foreach (var item in list[0])
            {
                planListBox.Items.Add(list[1].ElementAt(index).ToString() + " | " + list[2].ElementAt(index).ToString() + " | " + list[3].ElementAt(index).ToString() + " | " + list[4].ElementAt(index).ToString());
                index++;
            }
            logWriting logWriting = new logWriting("Użytkownik usunął produkcję.");
        }
Exemple #15
0
        private void removeOperationButton_Click(object sender, EventArgs e)
        {
            var isSure = false;

            if (MessageBox.Show("Czy napewno chcesz usunąć wpis?", "Usuwanie wpisu", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                IFormatter          formatter    = new BinaryFormatter();
                Stream              stream       = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
                DBDataSerialization dbds         = (DBDataSerialization)formatter.Deserialize(stream);
                DBConnection        dBConnection = new DBConnection(dbds.dbhost, dbds.dbname, dbds.dblogin, dbds.dbpassword);
                dBConnection.DeleteFinancialOperation(id);
                financialOperationsListBox.Items.Clear();
                List <string>[] list  = dBConnection.CheckFinancialOperations();
                var             index = 0;
                foreach (var item in list[3])
                {
                    financialOperationsListBox.Items.Add(list[0].ElementAt(index).ToString());
                    index++;
                }
                logWriting logWriting = new logWriting("Użytkownik usunął operację finansową.");
            }
        }
Exemple #16
0
        private void annexChangeOfPositionButton_Click(object sender, EventArgs e)
        {
            ProcessStartInfo info = new ProcessStartInfo();

            info.Verb           = "print";
            info.FileName       = @"files\Aneks - zmiana stanowiska.pdf";
            info.CreateNoWindow = true;
            info.WindowStyle    = ProcessWindowStyle.Hidden;

            Process p = new Process();

            p.StartInfo = info;
            p.Start();

            p.WaitForInputIdle();
            System.Threading.Thread.Sleep(5000);
            if (false == p.CloseMainWindow())
            {
                p.Kill();
            }

            logWriting logWriting = new logWriting("Użytkownik wydrukował aneks - zmiana stanowiska.");
        }
Exemple #17
0
        private void deleteAccountButton_Click(object sender, EventArgs e)
        {
            var isSure = false;

            if (MessageBox.Show("Czy napewno chcesz usunąć konto?", "Usuwanie konta", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                IFormatter          formatter    = new BinaryFormatter();
                Stream              stream       = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
                DBDataSerialization dbds         = (DBDataSerialization)formatter.Deserialize(stream);
                DBConnection        dBConnection = new DBConnection(dbds.dbhost, dbds.dbname, dbds.dblogin, dbds.dbpassword);
                List <string>[]     list2        = dBConnection.CheckLogin();
                logWriting          logWriting   = new logWriting("Użytkownik usunął konto - " + list2[0].ElementAt(existingAccountsListBox.SelectedIndex).ToString());
                dBConnection.Delete(id);
                existingAccountsListBox.Items.Clear();
                List <string>[] list  = dBConnection.CheckLogin();
                var             index = 0;
                foreach (var item in list[3])
                {
                    existingAccountsListBox.Items.Add(list[3].ElementAt(index).ToString() + " " + list[4].ElementAt(index).ToString());
                    index++;
                }
            }
        }
Exemple #18
0
        private void restoreEmployeeButton_Click(object sender, EventArgs e)
        {
            IFormatter          formatter    = new BinaryFormatter();
            Stream              stream       = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
            DBDataSerialization dbds         = (DBDataSerialization)formatter.Deserialize(stream);
            DBConnection        dBConnection = new DBConnection(dbds.dbhost, dbds.dbname, dbds.dblogin, dbds.dbpassword);

            dBConnection.InsertNewEmployee(firstName, lastName, fathersName, mothersName, birthday, placeOfResidence, correspondenceAddress, education, historyOfEmployment, pesel, childrensNames, childrensBirthdays);

            List <string>[] list2      = dBConnection.DeletedEmployeesList();
            logWriting      logWriting = new logWriting("Użytkownik przywrócił pracownika - " + list2[0].ElementAt(employeesListBox.SelectedIndex));

            dBConnection.DeleteFromDeletedEmployees(id);
            employeesListBox.Items.Clear();
            List <string>[] list  = dBConnection.DeletedEmployeesList();
            var             index = 0;

            foreach (var item in list[0])
            {
                employeesListBox.Items.Add(list[0].ElementAt(index).ToString() + " " + list[1].ElementAt(index).ToString());
                index++;
            }
        }
Exemple #19
0
        private void contractWorkButton_Click(object sender, EventArgs e)
        {
            ProcessStartInfo info = new ProcessStartInfo();

            info.Verb           = "print";
            info.FileName       = @"files\Umowa o dzieło - wzór.pdf";
            info.CreateNoWindow = true;
            info.WindowStyle    = ProcessWindowStyle.Hidden;

            Process p = new Process();

            p.StartInfo = info;
            p.Start();

            p.WaitForInputIdle();
            System.Threading.Thread.Sleep(5000);
            if (false == p.CloseMainWindow())
            {
                p.Kill();
            }

            logWriting logWriting = new logWriting("Użytkownik wydrukował umowę o dzieło.");
        }
Exemple #20
0
        private void registerNewAccountButton_Click(object sender, EventArgs e)
        {
            IFormatter          formatter    = new BinaryFormatter();
            Stream              stream       = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
            DBDataSerialization dbds         = (DBDataSerialization)formatter.Deserialize(stream);
            DBConnection        dBConnection = new DBConnection(dbds.dbhost, dbds.dbname, dbds.dblogin, dbds.dbpassword);

            string checkLogin  = loginTextBox.Text;
            bool   isLoginUsed = false;

            if (dBConnection.ConnectionTest())
            {
                List <string>[] list      = dBConnection.CheckLogin();
                string          workgroup = "";
                foreach (var item in list[0])
                {
                    if (item == checkLogin)
                    {
                        MessageBox.Show("Login jest już w użyciu! Proszę wprowadzić inny login.", "Błąd dodawania użytkownika.");
                        isLoginUsed = true;
                    }
                    else
                    {
                        if (workgroupListBox.SelectedItems.Count > 0)
                        {
                            switch (workgroupListBox.SelectedItem.ToString())
                            {
                            case "Finanse i rachunkowość":
                            {
                                workgroup = "finances";
                                break;
                            }

                            case "Logistyka i magazyny":
                            {
                                workgroup = "logistics";
                                break;
                            }

                            case "Produkcja":
                            {
                                workgroup = "production";
                                break;
                            }

                            case "Właściciel":
                            {
                                workgroup = "owner";
                                break;
                            }

                            case "Zasoby ludzkie":
                            {
                                workgroup = "hr";
                                break;
                            }

                            default:
                            {
                                workgroup = "";
                                MessageBox.Show("Zła grupa robocza. Spróbuj jeszcze raz.");
                                break;
                            }
                            }
                        }
                    }
                }
                var           dayOfBirth      = birthdayDateTimePicker.Value.Day.ToString();
                var           monthOfBirth    = birthdayDateTimePicker.Value.Month.ToString();
                var           yearOfBirth     = birthdayDateTimePicker.Value.Year.ToString();
                var           firstName       = firstNameTextBox.Text;
                var           lastName        = lastNameTextBox.Text;
                var           birthday        = dayOfBirth + "/" + monthOfBirth + "/" + yearOfBirth;
                var           login           = loginTextBox.Text;
                var           employmentMonth = employmentMonthDatePicker.Value.Month.ToString();
                var           emailAddress    = emailAddressTextBox.Text;
                PwdEncryption pwde            = new PwdEncryption();
                string        password        = pwde.GenerateHash(passwordTextBox.Text);
                string        pwdhash         = File.ReadAllText("salt.txt");
                File.Delete("salt.txt");
                if (string.IsNullOrWhiteSpace(firstNameTextBox.Text))
                {
                    MessageBox.Show("Imię nie może być puste!", "Puste imię", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (string.IsNullOrWhiteSpace(lastNameTextBox.Text))
                {
                    MessageBox.Show("Nazwisko nie może być puste!", "Puste nazwisko", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (string.IsNullOrWhiteSpace(loginTextBox.Text))
                {
                    MessageBox.Show("Login nie może być pusty!", "Puste imię administratora", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (string.IsNullOrWhiteSpace(passwordTextBox.Text))
                {
                    MessageBox.Show("Hasło nie może być puste!", "Puste hasło administratora", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (string.IsNullOrWhiteSpace(emailAddressTextBox.Text))
                {
                    MessageBox.Show("Adres e-mail nie może być pusty!", "Pusty adres e-mail", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (!isLoginUsed)
                {
                    dBConnection.InsertNewAccount(firstName, lastName, birthday, workgroup, login, password, pwdhash, employmentMonth, emailAddress);
                    MessageBox.Show("Konto utworzone poprawnie.", "Tworzenie konta", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    logWriting logWriting = new logWriting("Użytkownik dodał nowe konto - " + login);
                    firstNameTextBox.Text    = "";
                    lastNameTextBox.Text     = "";
                    loginTextBox.Text        = "";
                    passwordTextBox.Text     = "";
                    emailAddressTextBox.Text = "";
                    workgroupListBox.ClearSelected();
                }
            }
        }
Exemple #21
0
 private void openInvoiceButton_Click(object sender, EventArgs e)
 {
     System.Diagnostics.Process.Start(invoicesListBox.SelectedItem.ToString());
     logWriting logWriting = new logWriting("Użytkownik otworzył fakturę.");
 }
Exemple #22
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            IFormatter          formatter = new BinaryFormatter();
            Stream              stream    = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
            DBDataSerialization dbds      = (DBDataSerialization)formatter.Deserialize(stream);

            stream.Close();
            DBConnection dBConnection = new DBConnection(dbds.dbhost, dbds.dbname, dbds.dblogin, dbds.dbpassword);

            loginForLogs = loginTextBox.Text;
            string        login = loginTextBox.Text;
            PwdEncryption pwde  = new PwdEncryption();

            if (string.IsNullOrWhiteSpace(loginTextBox.Text))
            {
                MessageBox.Show("Login nie może być pusty!", "Pusty login", MessageBoxButtons.OK, MessageBoxIcon.Error);
                loginTextBox.Clear();
            }
            else if (string.IsNullOrWhiteSpace(passwordTextBox.Text))
            {
                MessageBox.Show("Hasło nie może być puste!", "Puste hasło", MessageBoxButtons.OK, MessageBoxIcon.Error);
                loginTextBox.Clear();
            }
            else if (dBConnection.ConnectionTest())
            {
                List <string>[] list             = dBConnection.CheckLogin();
                var             indexOfLogin     = 0;
                bool            loginSuccessfull = false;
                foreach (string loginInList in list[0])
                {
                    if (loginInList == login)
                    {
                        loginSuccessfull = true;
                        break;
                    }
                    indexOfLogin++;
                }
                if (loginSuccessfull)
                {
                    string     pwdhash         = dBConnection.GetPwdHash(login);
                    byte[]     salt            = Convert.FromBase64String(pwdhash);
                    string     adminPassword   = pwde.GenerateHashOnLogin(passwordTextBox.Text, salt);
                    logWriting logWriting      = new logWriting("Użytkownik się zalogował.");
                    var        passwordFromDb  = list[1].ElementAt(indexOfLogin);
                    var        workgroupFromDb = list[2].ElementAt(indexOfLogin);
                    if (passwordFromDb == adminPassword)
                    {
                        switch (workgroupFromDb)
                        {
                        case "owner":
                        {
                            ownerForm ownerForm = new ownerForm();
                            ownerForm.Show();
                            this.Hide();
                            break;
                        }

                        case "hr":
                        {
                            hrForm hrForm = new hrForm();
                            hrForm.Show();
                            this.Hide();
                            break;
                        }

                        case "finances":
                        {
                            financesForm financesForm = new financesForm();
                            financesForm.Show();
                            this.Hide();
                            break;
                        }

                        case "logistics":
                        {
                            logisticsForm logisticsForm = new logisticsForm();
                            logisticsForm.Show();
                            this.Hide();
                            break;
                        }

                        case "production":
                        {
                            productionForm productionForm = new productionForm();
                            productionForm.Show();
                            this.Hide();
                            break;
                        }

                        case "administrator":
                        {
                            configurationForm configurationForm = new configurationForm();
                            configurationForm.Show();
                            this.Hide();
                            break;
                        }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Wprowadź poprawne hasło!", "Złe hasło", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Wprowadź poprawny login!", "Niepoprawny login", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #23
0
        private void addButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(firstNameTextBox.Text))
            {
                MessageBox.Show("Pole imię nie może być puste. Proszę o poprawienie.", "Puste pole imię", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(lastNameTextBox.Text))
            {
                MessageBox.Show("Pole nazwisko nie może być puste. Proszę o poprawienie.", "Puste pole nazwisko", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(fathersNameTextBox.Text))
            {
                MessageBox.Show("Pole imię ojca nie może być puste. Proszę o poprawienie.", "Puste pole imię ojca", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(mothersNameTextBox.Text))
            {
                MessageBox.Show("Pole imię matki nie może być puste. Proszę o poprawienie.", "Puste pole imię matki", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(placeOfResidenceTextBox.Text))
            {
                MessageBox.Show("Pole adres zamieszkania nie może być puste. Proszę o poprawienie.", "Puste pole adres zamieszkania", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(educationTextBox.Text))
            {
                MessageBox.Show("Pole wykształcenie nie może być puste. Proszę o poprawienie.", "Puste pole wykształcenie", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(correspondenceAddressTextBox.Text))
            {
                MessageBox.Show("Pole adres korespondecyjny nie może być puste. Proszę o poprawienie.", "Puste pole adres korespondecyjny", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(historyOfEmploymentTextBox.Text))
            {
                MessageBox.Show("Pole historia zatrudnienia nie może być puste. Proszę o poprawienie.", "Puste pole historia zatrudnienia", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(peselTextBox.Text))
            {
                MessageBox.Show("Pole pesel nie może być puste. Proszę o poprawienie.", "Puste pole pesel", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(childrensNamesTextBox.Text))
            {
                MessageBox.Show("Pole imiona dzieci nie może być puste. Proszę o poprawienie.", "Puste pole imiona dzieci", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(childrensBirthdaysTextBox.Text))
            {
                MessageBox.Show("Pole urodziny dzieci nie może być puste. Proszę o poprawienie.", "Puste pole urodziny dzieci", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!long.TryParse(peselTextBox.Text, out var test))
            {
                MessageBox.Show("Zawartość pola pesel musi być liczbą. Proszę o poprawienie", "Błędna wartość pola pesel", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                IFormatter          formatter    = new BinaryFormatter();
                Stream              stream       = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
                DBDataSerialization dbds         = (DBDataSerialization)formatter.Deserialize(stream);
                DBConnection        dBConnection = new DBConnection(dbds.dbhost, dbds.dbname, dbds.dblogin, dbds.dbpassword);

                var firstName             = firstNameTextBox.Text;
                var lastName              = lastNameTextBox.Text;
                var fathersName           = fathersNameTextBox.Text;
                var mothersName           = mothersNameTextBox.Text;
                var dayOfBirth            = birthdayDateTimePicker.Value.Day.ToString();
                var monthOfBirth          = birthdayDateTimePicker.Value.Month.ToString();
                var yearOfBirth           = birthdayDateTimePicker.Value.Year.ToString();
                var birthday              = dayOfBirth + "/" + monthOfBirth + "/" + yearOfBirth;
                var placeOfResidence      = placeOfResidenceTextBox.Text;
                var education             = educationTextBox.Text;
                var correspondenceAddress = correspondenceAddressTextBox.Text;
                var historyOfEmployment   = historyOfEmploymentTextBox.Text;
                var pesel              = long.Parse(peselTextBox.Text);
                var childrensNames     = childrensNamesTextBox.Text;
                var childrensBirthdays = childrensBirthdaysTextBox.Text;

                dBConnection.InsertNewEmployee(firstName, lastName, fathersName, mothersName, birthday, placeOfResidence, correspondenceAddress, education, historyOfEmployment, pesel, childrensNames, childrensBirthdays);
                logWriting logWriting = new logWriting("Użytkownik dodał nowego pracownika.");
            }
        }