Ejemplo n.º 1
0
 public static void saveUsers(userModel newbs)
 {
     using (IDbConnection cnn = new SQLiteConnection(loadConnectionString()))
     {
         cnn.Execute("insert into users (userid, password, status, firstname, lastname, mail, address ) values(@userid, @password, @status, @firstname, @lastname, @mail, @address)", newbs);
     }
 }
Ejemplo n.º 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            userModel p = new userModel();

            if (loginWindow.userLevel == "2" && ComboBox.SelectedItem != "1")
            {
                this.Title = "manager can only add workers, correct your input please";
            }
            else
            {
                p.status = ComboBox.SelectedIndex.ToString();
                if (useridTextBox.Text != "")
                {
                    p.userid = useridTextBox.Text;
                }
                if (userpasswordTextBox.Text != "")
                {
                    p.password = userpasswordTextBox.Text;
                }
                try
                {
                    SqliteDataAccess.saveUsers(p);
                }
                catch
                {
                    pepegaWait();
                }
            }


            useridTextBox.Text       = "";
            userpasswordTextBox.Text = "";
            users = SqliteDataAccess.loadUsers();
        }
Ejemplo n.º 3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string login    = loginBox.Text;
            string password = passwordBox.Text;

            if (string.IsNullOrEmpty(login))
            {
                MessageBox.Show("Uzupełnij login"); return;
            }
            if (string.IsNullOrEmpty(password))
            {
                MessageBox.Show("Uzupełnij hasło"); return;
            }

            users      = SqliteDataAccess.loadUsers();
            items      = SqliteDataAccess.loadItems();
            userLogged = users.FirstOrDefault(x => x.userid.Equals(login));

            if (userLogged != null && userLogged.password.Equals(password))
            {
                Hide();
                if (userLogged.status.Equals("0"))
                {
                    userLevel = "0";
                    CustomerWindow window = new CustomerWindow();
                    window.Show();
                    window.Focus();
                }
                else if (userLogged.status.Equals("1"))
                {
                    userLevel = "1";
                    MainWindow window = new MainWindow();
                    window.Show();
                    window.Focus();
                }
                else if (userLogged.status.Equals("2"))
                {
                    userLevel = "2";
                    MainWindow window = new MainWindow();
                    window.Show();
                    window.Focus();
                }
                else if (userLogged.status.Equals("3"))
                {
                    userLevel = "3";
                    MainWindow window = new MainWindow();
                    window.Show();
                    window.Focus();
                }
            }
            else
            {
                loginInfo.Text = "Nieprawidłowy login i/lub hasło";
            }
        }
Ejemplo n.º 4
0
        private void ButtonAddClick(object sender, RoutedEventArgs e)
        {
            userModel newCustomer = new userModel();

            newCustomer.firstname = FirstnameTextBox.Text;
            newCustomer.lastname  = LastnameTextBox.Text;
            newCustomer.userid    = LoginTextBox.Text;
            newCustomer.password  = PasswordTextBox.Text;
            newCustomer.status    = "0";
            newCustomer.mail      = EmailTextBox.Text;
            newCustomer.address   = AddressTextBox.Text;

            if (string.IsNullOrEmpty(newCustomer.firstname))
            {
                MessageBox.Show("Uzupełnij imię"); return;
            }
            if (string.IsNullOrEmpty(newCustomer.lastname))
            {
                MessageBox.Show("Uzupełnij nazwisko"); return;
            }
            if (string.IsNullOrEmpty(newCustomer.userid))
            {
                MessageBox.Show("Uzupełnij login"); return;
            }
            if (string.IsNullOrEmpty(newCustomer.password))
            {
                MessageBox.Show("Uzupełnij hasło"); return;
            }
            if (string.IsNullOrEmpty(newCustomer.mail))
            {
                MessageBox.Show("Uzupełnij mail"); return;
            }
            if (string.IsNullOrEmpty(newCustomer.address))
            {
                MessageBox.Show("Uzupełnij adres"); return;
            }

            SqliteDataAccess.saveUsers(newCustomer);
            users = SqliteDataAccess.loadUsers();
            MessageBox.Show($"Popawnie dodano: {newCustomer.userid}");
            Close();
        }
Ejemplo n.º 5
0
        public static void addInvoice(List <itemModel> koszyk, userModel customer)
        {
            using (IDbConnection cnn = new SQLiteConnection(loadConnectionString()))
            {
                int newInvoiceId = 1;

                try
                {
                    var result = cnn.Query <int>("select max(id) + 1 from invoices", new DynamicParameters());
                    newInvoiceId = result.ToArray()[0];
                }
                catch (Exception ex) { }

                cnn.Execute($"insert into invoices (id, customerid) values({newInvoiceId}, @id)", customer);

                foreach (var item in koszyk)
                {
                    cnn.Execute($"insert into invoices_details (invoiceid, itemid, itemqty) values({newInvoiceId}, {item.idTow}, {item.ilosc})");
                }
            }
        }