Exemplo n.º 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);
            }
        }
Exemplo n.º 2
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.");
            }
        }
Exemplo n.º 3
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++;
            }
        }
Exemplo n.º 4
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.");
            }
        }
Exemplo n.º 5
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++;
            }
        }
Exemplo n.º 6
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ę.");
        }
Exemplo n.º 7
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.");
                }
            }
        }
Exemplo n.º 8
0
        private void existingAccountsListBox_SelectedIndexChanged(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);

            List <string>[] list = dBConnection.CheckLogin();
            id = list[8].ElementAt(existingAccountsListBox.SelectedIndex).ToString();
        }
Exemplo n.º 9
0
        private void financialOperationsListBox_SelectedIndexChanged(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);

            List <string>[] list = dBConnection.CheckFinancialOperations();
            receiverTextBox.Text = list[0].ElementAt(financialOperationsListBox.SelectedIndex).ToString();
            amountTextBox.Text   = list[1].ElementAt(financialOperationsListBox.SelectedIndex).ToString();
            categoryTextBox.Text = list[2].ElementAt(financialOperationsListBox.SelectedIndex).ToString();
            id = list[3].ElementAt(financialOperationsListBox.SelectedIndex).ToString();
        }
Exemplo n.º 10
0
        public invoicesForm()
        {
            InitializeComponent();
            IFormatter          formatter = new BinaryFormatter();
            Stream              stream    = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
            DBDataSerialization dbds      = (DBDataSerialization)formatter.Deserialize(stream);

            string[] filePaths = Directory.GetFiles(dbds.path + "\\");
            foreach (string asd in filePaths)
            {
                invoicesListBox.Items.Add(asd);
            }
        }
Exemplo n.º 11
0
        private void inventoryListBox_SelectedIndexChanged(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);

            List <string>[] list = dBConnection.CheckInventory();
            id = int.Parse(list[0].ElementAt(inventoryListBox.SelectedIndex));
            inventoryCodeTextBox.Text = list[1].ElementAt(inventoryListBox.SelectedIndex).ToString();
            nameTextBox.Text          = list[2].ElementAt(inventoryListBox.SelectedIndex).ToString();
            amountTextBox.Text        = list[3].ElementAt(inventoryListBox.SelectedIndex).ToString();
        }
Exemplo n.º 12
0
        public editCompanyDetailsForm()
        {
            InitializeComponent();

            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>[] list = dBConnection.CheckCompany();
            companyNameTextBox.Text  = list[1].ElementAt(0);
            companyNIPTextBox.Text   = list[2].ElementAt(0);
            companyREGONTextBox.Text = list[3].ElementAt(0);
            companyKRSTextBox.Text   = list[4].ElementAt(0);
        }
Exemplo n.º 13
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ę.");
        }
Exemplo n.º 14
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.");
        }
Exemplo n.º 15
0
        public void SerializeIt(string host, string name, string login, string password, string path)
        {
            DBDataSerialization dbds = new DBDataSerialization();

            dbds.dbhost     = host;
            dbds.dbname     = name;
            dbds.dblogin    = login;
            dbds.dbpassword = password;
            dbds.path       = path;

            IFormatter formatter = new BinaryFormatter();
            Stream     stream    = new FileStream("conf.bin", FileMode.Create, FileAccess.Write);

            formatter.Serialize(stream, dbds);
            stream.Close();
        }
Exemplo n.º 16
0
        private void modifyFilesServerLocalisationButton_Click(object sender, EventArgs e)
        {
            folderBrowserDialog1.ShowDialog();
            var                 path      = folderBrowserDialog1.SelectedPath;
            IFormatter          formatter = new BinaryFormatter();
            Stream              stream    = new FileStream("conf.bin", FileMode.Open, FileAccess.Read);
            DBDataSerialization dbds      = (DBDataSerialization)formatter.Deserialize(stream);
            var                 dbhost    = dbds.dbhost;
            var                 dbname    = dbds.dbname;
            var                 dblogin   = dbds.dblogin;
            var                 dbpwd     = dbds.dbpassword;

            stream.Close();
            DBDataSerialization bwr = new DBDataSerialization();

            bwr.SerializeIt(dbhost, dbname, dblogin, dbpwd, path);
        }
Exemplo n.º 17
0
        private void existingAccountsListBox_SelectedIndexChanged(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);

            List <string>[] list = dBConnection.CheckLogin();
            firstNameTextBox.Text    = list[3].ElementAt(existingAccountsListBox.SelectedIndex).ToString();
            lastNameTextBox.Text     = list[4].ElementAt(existingAccountsListBox.SelectedIndex).ToString();
            loginTextBox.Text        = list[0].ElementAt(existingAccountsListBox.SelectedIndex).ToString();
            passwordTextBox.Text     = list[1].ElementAt(existingAccountsListBox.SelectedIndex).ToString();
            emailAddressTextBox.Text = list[5].ElementAt(existingAccountsListBox.SelectedIndex).ToString();
            birthdayTextBox.Text     = list[7].ElementAt(existingAccountsListBox.SelectedIndex).ToString();
            employmentTextBox.Text   = list[6].ElementAt(existingAccountsListBox.SelectedIndex).ToString();
            id = list[8].ElementAt(existingAccountsListBox.SelectedIndex).ToString();
        }
Exemplo n.º 18
0
        public deleteAccountForm()
        {
            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);

            InitializeComponent();
            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++;
            }
        }
Exemplo n.º 19
0
        private void financialOperationsForm_Activated(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);

            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++;
            }
        }
Exemplo n.º 20
0
        public generateFilesSingleForm()
        {
            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);

            InitializeComponent();

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

            foreach (var item in list[0])
            {
                employeesListBox.Items.Add(list[0].ElementAt(index).ToString() + " " + list[1].ElementAt(index).ToString());
                index++;
            }
        }
Exemplo n.º 21
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.");
            }
        }
Exemplo n.º 22
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ę.");
            }
        }
Exemplo n.º 23
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++;
                }
            }
        }
Exemplo n.º 24
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ę.");
        }
Exemplo n.º 25
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ą.");
            }
        }
Exemplo n.º 26
0
        private void employeesListBox_SelectedIndexChanged(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);

            List <string>[] list = dBConnection.EmployeesList();
            firstNameTextBox.Text             = list[0].ElementAt(employeesListBox.SelectedIndex).ToString();
            lastNameTextBox.Text              = list[1].ElementAt(employeesListBox.SelectedIndex).ToString();
            fathersNameTextBox.Text           = list[2].ElementAt(employeesListBox.SelectedIndex).ToString();
            mothersNameTextBox.Text           = list[3].ElementAt(employeesListBox.SelectedIndex).ToString();
            birthdayTextBox.Text              = list[4].ElementAt(employeesListBox.SelectedIndex).ToString();
            placeOfResidenceTextBox.Text      = list[5].ElementAt(employeesListBox.SelectedIndex).ToString();
            correspondenceAddressTextBox.Text = list[6].ElementAt(employeesListBox.SelectedIndex).ToString();
            educationTextBox.Text             = list[7].ElementAt(employeesListBox.SelectedIndex).ToString();
            historyOfEmploymentTextBox.Text   = list[8].ElementAt(employeesListBox.SelectedIndex).ToString();
            peselTextBox.Text              = list[9].ElementAt(employeesListBox.SelectedIndex).ToString();
            childrensNamesTextBox.Text     = list[10].ElementAt(employeesListBox.SelectedIndex).ToString();
            childrensBirthdaysTextBox.Text = list[11].ElementAt(employeesListBox.SelectedIndex).ToString();
            id = int.Parse(list[12].ElementAt(employeesListBox.SelectedIndex).ToString());
        }
Exemplo n.º 27
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++;
                }
            }
        }
Exemplo n.º 28
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++;
            }
        }
Exemplo n.º 29
0
        private void installButton_Click(object sender, EventArgs e)
        {
            string adminLogin       = adminLoginTextBox.Text;
            string adminFirstName   = adminFirstNameTextBox.Text;
            string adminLastName    = adminLastNameTextBox.Text;
            string adminEmail       = adminEmailTextBox.Text;
            string databaseHost     = databaseHostTextBox.Text;
            string databasePassword = databasePasswordTextBox.Text;
            string databaseName     = databaseNameTextBox.Text;
            string databaseLogin    = databaseLoginTextBox.Text;

            var dayOfBirth    = adminBirthdayDatePicker.Value.Day.ToString();
            var monthOfBirth  = adminBirthdayDatePicker.Value.Month.ToString();
            var yearOfBirth   = adminBirthdayDatePicker.Value.Year.ToString();
            var adminBirthday = dayOfBirth + "/" + monthOfBirth + "/" + yearOfBirth;
            var workgroup     = "administrator";

            var monthOfEmployment = employmentMonthDatePicker.Value.Month.ToString();

            progressBar.Visible = true;
            progressBar.Value   = 0;
            DBConnection dBConnection = new DBConnection(databaseHost, databaseName, databaseLogin, databasePassword);

            if (!dBConnection.ConnectionTest())
            {
                databaseHostTextBox.Text     = null;
                databasePasswordTextBox.Text = null;
                databaseNameTextBox.Text     = null;
                databaseLoginTextBox.Text    = null;
                progressBar.Value            = 0;
            }
            else if (string.IsNullOrWhiteSpace(adminLoginTextBox.Text))
            {
                MessageBox.Show("Login administratora nie może być pusty!", "Pusty login administratora", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(adminPasswordTextBox.Text))
            {
                MessageBox.Show("Hasło administratora nie może być puste!", "Puste hasło administratora", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(adminFirstNameTextBox.Text))
            {
                MessageBox.Show("Imię administratora nie może być puste!", "Puste imię administratora", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(adminLastNameTextBox.Text))
            {
                MessageBox.Show("Nazwisko administratora nie może być puste!", "Puste nazwisko administratora", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(adminEmailTextBox.Text))
            {
                MessageBox.Show("Adres e-mail administratora nie może być pusty!", "Pusty adres e-mail administratora", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(databaseHostTextBox.Text))
            {
                MessageBox.Show("Host bazy danych nie może być pusty!", "Pusty host bazy danych", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(databasePasswordTextBox.Text))
            {
                MessageBox.Show("Hasło do bazy danych nie może być puste!", "Puste hasło do bazy danych", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(databaseNameTextBox.Text))
            {
                MessageBox.Show("Nazwa bazy danych nie może być pusta!", "Pusta nazwa bazy danych", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(databaseLoginTextBox.Text))
            {
                MessageBox.Show("Login do bazy danych nie może być pusty!", "Pusty login do bazy danych", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(companyNameTextBox.Text))
            {
                MessageBox.Show("Nazwa firmy nie może być pusta!", "Pusta nazwa firmy", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(companyNIPTextBox.Text))
            {
                MessageBox.Show("NIP nie może być pusty!", "Pusty NIP", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(companyREGONTextBox.Text))
            {
                MessageBox.Show("REGON nie może być pusty!", "Pusty REGON", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrWhiteSpace(companyKRSTextBox.Text))
            {
                MessageBox.Show("KRS nie może być pusty!", "Pusty KRS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                createTable();
                dBConnection.CreateTable();

                PwdEncryption pwde          = new PwdEncryption();
                string        adminPassword = pwde.GenerateHash(adminPasswordTextBox.Text);
                string        adminPwdSalt  = File.ReadAllText("salt.txt");
                File.Delete("salt.txt");

                insertDataIntoSQLFiles(adminLogin, adminPassword, adminPwdSalt, adminFirstName, adminLastName, adminEmail, adminBirthday, workgroup, monthOfEmployment);
                dBConnection.CreateAdmin();

                progressBar.Value = 20;

                var companyName  = companyNameTextBox.Text;
                var companyNIP   = long.Parse(companyNIPTextBox.Text);
                var companyREGON = long.Parse(companyREGONTextBox.Text);
                var companyKRS   = long.Parse(companyKRSTextBox.Text);
                dBConnection.InsertNewCompany(companyName, companyNIP, companyREGON, companyKRS);



                progressBar.Value = 75;

                DBDataSerialization bwr = new DBDataSerialization();
                bwr.SerializeIt(databaseHostTextBox.Text, databaseNameTextBox.Text, databaseLoginTextBox.Text, databasePasswordTextBox.Text, path);

                progressBar.Value = 100;

                MessageBox.Show("Wszystko w porządku. Można używać programu.", "OK");
                loginForm loginForm = new loginForm();
                loginForm.Show();
                loginForm.Activate();
                this.Hide();
            }
        }
Exemplo n.º 30
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);
                }
            }
        }