Exemplo n.º 1
0
        }//заполнение формы для редачки

        public void EditFinal(employee emp, ComboBox comboBox, TextBox t1, TextBox t2, TextBox t3, MaskedTextBox m, TextBox t4, TextBox t5)
        {
            restEntities db    = new restEntities();
            var          query = (from i in db.position
                                  where i.id_post == comboBox.SelectedIndex + 1
                                  select i.id_post).ToList();

            var log    = db.users.SingleOrDefault(r => r.id_user == emp.id_user);
            var result = db.employee.SingleOrDefault(n => n.id_empl == emp.id_empl);

            result.surname_emp = ClassReports.NameNew(t1.Text.ToString());
            result.name_emp    = ClassReports.NameNew(t2.Text.ToString());
            if (t3.Text != "")
            {
                result.lastname_emp = ClassReports.NameNew(t3.Text.ToString());
            } //отчество
            else
            {
                result.lastname_emp = t3.Text.ToString();
            }
            result.id_post  = Convert.ToInt32(query[0]);
            result.date_emp = Convert.ToDateTime(m.Text);
            log.login_user  = t4.Text.ToString();
            log.pass_user   = t5.Text.ToString();

            db.SaveChanges();
        }//сохранение обновленных значений
Exemplo n.º 2
0
        }//видимость кнопок для меню

        public void Test(int i, DataGridView dataGridView, int n)
        {
            restEntities   db = new restEntities();
            List <order11> order1;

            order1 = (from or in db.order11Set
                      select or).ToList();


            order11 o1 = new order11 {
                id_position = 0, id_menu = i, data_order1 = DateTime.Now, table_n = n
            };

            db.order11Set.Add(o1);
            db.SaveChanges();

            var query = (from t in order1
                         join g in db.menu on t.id_menu equals g.id_menu
                         where t.table_n == n
                         select new { g.name_item }).ToList();


            dataGridView.DataSource            = query;
            dataGridView.Columns[0].HeaderText = "Название";
            Update(n, dataGridView);
        }
Exemplo n.º 3
0
        //public void Test(DataGridView dataGridView)
        //{
        //    restEntities db = new restEntities();
        //    List<order11> order1;

        //    order1 = (from or in db.order11Set
        //              select or).ToList();

        //    var query = (from t in order1
        //                 join g in db.menu on t.id_menu equals g.id_menu
        //                 select new { g.name_item }).ToList();

        //    dataGridView.DataSource = query;
        //    dataGridView.Columns[1].HeaderText = "Название";
        //}

        public void Drop(int n, DataGridView dataGridView)
        {
            restEntities   db = new restEntities();
            List <order11> order1;

            order1 = (from or in db.order11Set
                      select or).ToList();


            db.order11Set.RemoveRange(db.order11Set.Where(w => w.table_n == n));
            db.SaveChanges();
            Update(n, dataGridView);
        }
Exemplo n.º 4
0
        }//сохранение обновленных значений

        public void Stock(string t1, int t2, DateTime m, string c, double t3)
        {
            restEntities db = new restEntities();
            stock        st = new stock
            {
                product  = t1,
                quantity = t2,
                unit     = c,
                summ     = t3,
                date_sup = m,
                id_empl  = 2
            };

            db.stock.Add(st);
            db.SaveChanges();
        } //пополнение склада
Exemplo n.º 5
0
        }//вывод списка сотрудников

        public void Drop(string s, string n, string l)
        {
            restEntities db = new restEntities();

            var query = (from a in db.employee
                         where a.surname_emp == s && a.name_emp == n && a.lastname_emp == l
                         select a).ToList();

            if (query.Count == 1)
            {
                db.employee.RemoveRange(db.employee.Where(w => w.surname_emp == s && w.name_emp == n && w.lastname_emp == l));
                db.SaveChanges();
                MessageBox.Show("Сотрудник удален");
            }
            else
            {
                MessageBox.Show("Такого сотрудника нет в базе");
            }
        }//удалить сотрудника
Exemplo n.º 6
0
        } //менять наличие еды для true

        public void Report(int n, double SUM)
        {
            restEntities  db = new restEntities();
            List <dishes> dish;

            dish = (from or in db.dishes
                    select or).ToList();

            dishes d1 = new dishes
            {
                id_dishes  = 0,
                date_dish  = DateTime.Now,
                count_dish = Convert.ToInt32(SUM),
                id_empl    = 5,
            };

            db.dishes.Add(d1);
            db.SaveChanges();
        } //добавление заказа для отчета в dishes
Exemplo n.º 7
0
        } //менять наличие еды для false

        public void UpdateMenu2(int men)
        {
            restEntities db = new restEntities();
            List <menu>  mn;

            mn = (from m in db.menu
                  select m).ToList();

            var result = db.menu.SingleOrDefault(x => x.id_menu == men);

            if (result.active == true)
            {
                result.active = false;
                db.SaveChanges();
                MessageBox.Show("Продукт исключен из меню");
            }
            else
            {
                MessageBox.Show("Ошибка! Этого блюда уже нет в наличии");
            }
        } //менять наличие еды для true
Exemplo n.º 8
0
        }//удалить сотрудника

        public void AddJ(string f, string n, string l, DateTime date, int i, string log, string pass)
        {
            restEntities db = new restEntities();

            var query = (from e in db.employee
                         join p in db.position on e.id_post equals p.id_post
                         join u in db.users on e.id_user equals u.id_user
                         select new
            {
                e.surname_emp,
                e.name_emp,
                e.lastname_emp,
                e.date_emp,
                p.name_post,
                p.salary,
                u.login_user,
                u.pass_user
            }).ToList();
            int user = db.users.Max(us => us.id_user);



            employee e1 = new employee
            {
                surname_emp  = f,
                name_emp     = n,
                lastname_emp = l,
                date_emp     = date,
                id_user      = user + 1,
                id_post      = i + 1
            };

            string role = "";

            if (i == 0)
            {
                role = "manager";
            }
            else if (i == 1)
            {
                role = "admin";
            }
            else if (i == 2)
            {
                role = "ofic";
            }
            else if (i == 3)
            {
                role = "cook";
            }
            else if (i == 4)
            {
                role = "bar";
            }

            users u1 = new users
            {
                id_user    = user + 1,
                role_user  = role,
                login_user = log,
                pass_user  = pass
            };

            db.employee.Add(e1);
            db.users.Add(u1);
            db.SaveChanges();
            MessageBox.Show("Сотрудник добавлен");
        }//добавить нового сотрудника