Esempio n. 1
0
 public Cashbox(string login)
 {
     InitializeComponent();
     db = new SilpoDBEntities();
     label_name.Text   = db.Users.Where(x => x.Login == login).First().Full_name;
     label_userid.Text = db.Users.Where(x => x.Login == login).First().ID_User.ToString(); //це сховано
 }
Esempio n. 2
0
        private void but_confirm_Click(object sender, EventArgs e)
        {
            if (text_amount.Text == "" || text_name.Text == "")
            {
                MessageBox.Show("Заповніть всі поля!!!");
            }
            else
            {
                // MessageBox.Show(combo_category.Text + "  " + combo_producer.Text + "  " + text_name.Text + " " + text_amount.Text + " " + numeric_datedie.Value);
                SilpoDBEntities db = new SilpoDBEntities();


                Product product = new Product()
                {
                    Name        = text_name.Text,
                    Expiry_time = (int)numeric_datedie.Value,
                    ID_category = db.Category.Where(x => x.Name == combo_category.Text).First().ID_category,
                    ID_producer = db.Producer.Where(x => x.Name == combo_producer.Text).First().ID_producer
                };
                db.Product.Add(product);
                db.SaveChanges();

                MessageBox.Show(text_name.Text + "  Додано");
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Esempio n. 3
0
        private void Report_salushok_Load(object sender, EventArgs e)
        {
            db = new SilpoDBEntities();
            DateTime date = DateTime.Now;

            try
            {
                var zalish = db.Storage.Where(d => d.FinalDate >= date).Where(c => c.Available_items > 0).OrderBy(x => x.Id_product);// колекцыя полів вибраних по даті
                // MessageBox.Show(zalish.ToString());
                foreach (var user in zalish)
                {
                    lv = new ListViewItem(user.ID_storage.ToString());
                    string prName = db.Product.Where(pr => pr.ID_product == user.Id_product).First().Name;

                    lv.SubItems.Add(prName.ToString());
                    lv.SubItems.Add(user.Available_items.ToString());
                    lv.SubItems.Add(user.FinalDate.ToShortDateString());

                    listView1.Items.Add(lv);
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            MessageBox.Show("ви зайшли в таблицю Залишки");
        }
Esempio n. 4
0
        private void NewUsers_Load(object sender, EventArgs e)
        {
            try
            {
                db = new SilpoDBEntities();
                var users = db.Users.Select(u => u.ID_User); // колекцыя ад юзерыв
                foreach (var item in users)                  //item- id user
                {
                    lv = new ListViewItem(item.ToString());
                    //var idd = db.Discount.Where(id => id.Id_discount == item).Select(p => p.Id_product).First();
                    //var pr = db.Discount.Where(p => p.Id_product == idd).Select(p => p.Product.Name).First();

                    var qury = db.Users.Where(u => u.ID_User == item); // колекція  полів
                    foreach (var user in qury)                         // і в кожному полі,,,
                    {
                        lv.SubItems.Add(user.Full_name);
                        lv.SubItems.Add(user.City);
                        lv.SubItems.Add(user.Role);
                        lv.SubItems.Add(user.Login);
                        lv.SubItems.Add(user.Password);
                    }
                    listView_users.Items.Add(lv);
                    // .Items.Add(lv);
                }
            }
            catch (Exception ex)

            { MessageBox.Show(ex.Message); }

            listView_users.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            MessageBox.Show("ви зайшли в таблицю Користувачі");
        }
Esempio n. 5
0
        private void button_ok_Click(object sender, EventArgs e)
        {
            try
            {
                db = new SilpoDBEntities();
                string role  = comboBox_role.SelectedItem.ToString();
                string city  = textBox_city.Text;
                string name  = textBox_name.Text;
                string login = textBox_login.Text;
                string pass  = textBox_pass.Text;

                Users newUser = new Users();
                newUser.Role      = role;
                newUser.City      = city;
                newUser.Full_name = textBox_name.Text;
                newUser.Login     = login;
                newUser.Password  = pass;
                db.Users.Add(newUser);
                db.SaveChanges();
                MessageBox.Show("зареестровані");
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 6
0
        public SupplyForm()
        {
            InitializeComponent();
            but_delete.Enabled = false;

            db = new SilpoDBEntities();
            FillDB();
        }
Esempio n. 7
0
        public ProductForm(SilpoDBEntities db1)
        {
            InitializeComponent();
            this.db = db1;


            but_delete.Enabled = false;
        }
Esempio n. 8
0
        public CategoryPanel()
        {
            InitializeComponent();
            db       = new SilpoDBEntities();
            listitem = new ListViewItem();
            FillDb();
            var skinmanager = MaterialSkinManager.Instance;

            skinmanager.AddFormToManage(this);
            skinmanager.Theme       = MaterialSkinManager.Themes.DARK;
            skinmanager.ColorScheme = new ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE);
        }
Esempio n. 9
0
        private void Admin_Load(object sender, EventArgs e)
        {
            SilpoDBEntities db = new SilpoDBEntities();

            foreach (var i in db.Category)
            {
                combo_category.Items.Add(i.Name);
            }
            foreach (var i in db.Producer)
            {
                combo_producer.Items.Add(i.Name);
            }
        }
Esempio n. 10
0
        public Add_disc()
        {
            InitializeComponent();

            db = new SilpoDBEntities();

            var nuber = db.Product.Select(n => n.Name);

            foreach (var n in nuber)
            {
                comboBox1.Items.Add(n);
            }
        }
Esempio n. 11
0
        public ProducerPanel()
        {
            InitializeComponent();
            db       = new SilpoDBEntities();
            listitem = new ListViewItem();
            //myThread = new Thread(FillDb);
            // myThread.Start();
            pictureBox1.Image = SearchImage;
            pictureBox2.Image = PlusImage;

            var skinmanager = MaterialSkinManager.Instance;

            skinmanager.AddFormToManage(this);
            skinmanager.Theme       = MaterialSkinManager.Themes.DARK;
            skinmanager.ColorScheme = new ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE);
            comboBox1.SelectedIndex = 0;
            FillCombobox();
            FillDb();
        }
Esempio n. 12
0
        private void Discount_Load(object sender, EventArgs e)
        {
            checkBox_true.Visible = false;

            db = new SilpoDBEntities();
            try
            {
                // вивід
                var category = db.Category.Select(n => n.Name);
                foreach (var n in category)
                {
                    comboBox_category.Items.Add(n);
                }
                // comboBox_category.SelectedIndex = 0;// фокусування
                var nuber = db.Discount.Select(n => n.Id_discount); // вибираемо всы ад дискаунту


                foreach (var item in nuber)  //item- id discount
                {
                    lv = new ListViewItem(item.ToString());
                    var idd = db.Discount.Where(id => id.Id_discount == item).Select(p => p.Id_product).First();
                    var pr  = db.Discount.Where(p => p.Id_product == idd).Select(p => p.Product.Name).First();

                    var qury = db.Discount.Where(u => u.Id_discount == item); // колекція  полів
                    foreach (var user in qury)                                // і в кожному полі,,,
                    {
                        lv.SubItems.Add(pr.ToString());
                        lv.SubItems.Add(user.Percent.ToString());
                        lv.SubItems.Add(user.Start.ToString());
                        lv.SubItems.Add(user.End.ToString());
                    }

                    listView1.Items.Add(lv);
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            MessageBox.Show("ви зайшли в таблицю Знижки");
        }
Esempio n. 13
0
        public AdminPanel()
        {
            InitializeComponent();
            DateTime localDate = DateTime.Now;

            String[] cultureNames = { "ru-RU" };

            foreach (var cultureName in cultureNames)
            {
                var culture = new CultureInfo(cultureName);
                label_data.Text = localDate.ToString(culture);
            }


            db = new SilpoDBEntities();
            ProductForm pf = new ProductForm(db);

            var skinmanager = MaterialSkinManager.Instance;

            skinmanager.AddFormToManage(this);
            skinmanager.Theme       = MaterialSkinManager.Themes.DARK;
            skinmanager.ColorScheme = new ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE);
        }
Esempio n. 14
0
        private void button_registration_Click(object sender, EventArgs e)
        {
            db = new SilpoDBEntities();

            try
            {
                int logins = db.Users.Where(log => log.Login == textBox_login.Text).Count(); // вибірка логіна із введеного

                //MessageBox.Show(logins.Login.ToString());
                if (logins > 0)
                {
                    MessageBox.Show("Ви зареестровані");
                }
                else if (logins == 0)
                {
                    Registration reg = new Registration(textBox_login.Text, textBox_password.Text);
                    reg.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 15
0
        public AdminPanel(string a)
        {
            InitializeComponent();
            db = new SilpoDBEntities();


            label_name.Text = db.Users.Where(x => x.Login == a).First().Full_name;
            label_who.Text  = db.Users.Where(x => x.Login == a).First().Role;
            DateTime localDate = DateTime.Now;

            String[] cultureNames = { "ru-RU" };

            foreach (var cultureName in cultureNames)
            {
                var culture = new CultureInfo(cultureName);
                label_data.Text = localDate.ToString(culture);
            }

            var skinmanager = MaterialSkinManager.Instance;

            skinmanager.AddFormToManage(this);
            skinmanager.Theme       = MaterialSkinManager.Themes.DARK;
            skinmanager.ColorScheme = new ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE);
        }
Esempio n. 16
0
 public StorageForm(SilpoDBEntities db)
 {
     InitializeComponent();
     this.db = db;
 }
Esempio n. 17
0
 public BalanceForm()
 {
     InitializeComponent();
     db = new SilpoDBEntities();
 }
Esempio n. 18
0
        private void button_signIn_Click(object sender, EventArgs e)
        {
            db = new SilpoDBEntities();


            using (new CursorEx())
            {
                try
                {
                    //var role = db.Users.Where(x => x.Login == textBox_login.Text).Where(y => y.Password == textBox_password.Text).Select(r => r.Role).First();
                    ////MessageBox.Show(role);
                    //if (role == "admin" && comboBox_role.Text == "адмін")
                    //{
                    //    AdminPanel adm = new AdminPanel(textBox_login.Text);
                    //    SignIn sn = new SignIn();
                    //    this.Hide();
                    //    Thread.Sleep(1000);
                    //    adm.ShowDialog();
                    //}

                    //else if (role == "seller" && comboBox_role.Text == "касир")
                    //{
                    //    Cashbox cashbox = new Cashbox(textBox_login.Text);
                    //    this.Hide();
                    //    cashbox.ShowDialog();
                    //}
                    //else
                    //{
                    //    MessageBox.Show("В доступі відмовлено");
                    //}
                    int logins = db.Users.Where(log => log.Login == textBox_login.Text).Count(); // вибірка логіна із введеного

                    //MessageBox.Show(logins.Login.ToString());
                    if (logins > 0)
                    {
                        var role = db.Users.Where(x => x.Login == textBox_login.Text).Where(y => y.Password == textBox_password.Text).Select(r => r.Role).First();
                        //MessageBox.Show(role);
                        if (role == "admin" && comboBox_role.Text == "адмін")
                        {
                            AdminPanel adm = new AdminPanel(textBox_login.Text);
                            SignIn     sn  = new SignIn();
                            this.Hide();
                            Thread.Sleep(1000);
                            adm.ShowDialog();
                        }

                        else if (role == "seller" && comboBox_role.Text == "касир")
                        {
                            Cashbox cashbox = new Cashbox(textBox_login.Text);
                            this.Hide();
                            cashbox.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("В доступі відмовлено введіть правильні дані");
                        }
                    }
                    else if (logins == 0)
                    {
                        MessageBox.Show("вас немає зареєструйтеся");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("ввели неправильні дані, повторіть");
                    //MessageBox.Show(ex.Message);
                }
            }
        }
Esempio n. 19
0
        private void but_ok_Click(object sender, EventArgs e)
        {
            SilpoDBEntities db = new SilpoDBEntities();
            int             id = db.Product.Where(x => x.Name == combo_prod.Text).First().ID_product;


            Supply supply = new Supply()
            {
                Id_product  = id,
                Price       = numeric_price.Value,
                MarkUp      = (int)numeric_markup.Value,
                Amount      = (int)numeric_amount.Value,
                Date_made   = dateTime_made.Value,
                Date_supply = dateTime_supply.Value
            };

            db.Supply.Add(supply);
            db.SaveChanges();
            DateTime dt   = dateTime_made.Value;
            double   days = (double)db.Product.Where(x => x.ID_product == id).First().Expiry_time;

            Storage storage = new Storage()
            {
                Id_product      = id,
                id_supply       = db.Supply.ToList().Last().ID_supply,
                Available_items = (int)numeric_amount.Value,
                FinalDate       = dt.AddDays(days)
            };

            db.Storage.Add(storage);
            db.SaveChanges();

            double price_product = (double)(numeric_price.Value + ((numeric_price.Value * numeric_markup.Value) / 100));

            foreach (var i in db.Prices)
            {
                if (id == i.idProduct)
                {
                    pr = true;
                }
            }

            if (pr == false)
            {
                Prices price = new Prices()
                {
                    idProduct = id,
                    Price     = (decimal)price_product,
                    Date      = DateTime.Now,
                };

                db.Prices.Add(price);
                db.SaveChanges();
            }
            else
            {
                //  var prs = db.Prices.Where(x => x.idProduct == id).ToArray().Last();
                Prices last_prc = db.Prices.Where(x => x.idProduct == id).ToArray().Last();
                if (price_product != (double)last_prc.Price)
                {
                    Prices price = new Prices()
                    {
                        idProduct = id,
                        Price     = (decimal)price_product,
                        Date      = DateTime.Now,
                    };

                    db.Prices.Add(price);
                    db.SaveChanges();
                }
                else
                {
                    MessageBox.Show("Ціна не змінилась");
                }
            }
            this.Hide();
        }