Ejemplo n.º 1
0
        public static async Task <IList <OrderToProduct> > getOrderToProductAsync()
        {
            StorehouseContext db = new StorehouseContext();
            var result           = OrderToProduct(db);

            return(await Task.FromResult(result));
        }
Ejemplo n.º 2
0
        public static async Task <IList <Order> > getOrderAsync()
        {
            StorehouseContext db = new StorehouseContext();
            var result           = ReadOrder(db);

            return(await Task.FromResult(result));
        }
Ejemplo n.º 3
0
 private void Authorization_Load(object sender, EventArgs e)
 {
     using (StorehouseContext db = new StorehouseContext())
     {
         db.Users.Load();
         applicationUser = db.Users.Local.ToBindingList();
     }
 }
Ejemplo n.º 4
0
 private void loadUsers()
 {
     using (StorehouseContext db = new StorehouseContext())
     {
         db.Users.Load();
         dataGridView1.DataSource = db.Users.Local.ToBindingList();
     }
 }
Ejemplo n.º 5
0
        private void AddProduct_Load(object sender, EventArgs e)
        {
            this.Text = string.Format("ID пользователя:{0}", IdUser);
            StorehouseContext db = new StorehouseContext();

            db.Products.Load();
            var bindingSource = new BindingSource(db.Products.Local.ToBindingList(), null);

            dataGridView1.DataSource = bindingSource;
        }
Ejemplo n.º 6
0
        private static IList <Order> ReadOrder(StorehouseContext db)
        {
            db.Orders.Load();
            var result = db.Orders.Local.ToBindingList();

            if (result == null)
            {
                return(result);
            }

            return(result);
        }
Ejemplo n.º 7
0
        private static IList <Product> ReadProduct(StorehouseContext db)
        {
            db.Products.Load();
            var result = db.Products.Local.ToBindingList();

            if (result == null)
            {
                return(result);
            }

            return(result);
        }
Ejemplo n.º 8
0
        public void AddUsers()
        {
            using (StorehouseContext db = new StorehouseContext())
            {
                if (txtLogin.Text != null || txtPassword != null)
                {
                    if (txtAcceptPass.Text == txtPassword.Text)
                    {
                        if (txtFiOUser.Text != null || txtAgeUser.Text != null)
                        {
                            var user = new User()
                            {
                                Login     = txtLogin.Text,
                                Password  = txtPassword.Text,
                                Prioritet = comboAccept.SelectedIndex + 1
                            };
                            db.Users.AddRange(new List <User> {
                                user
                            });
                            db.SaveChanges();

                            var profile = new UserProfile
                            {
                                Id       = user.ID,
                                FIO      = txtFiOUser.Text,
                                Age      = Convert.ToInt32(txtAgeUser.Text),
                                Position = comboAccept.Text,
                                UserId   = user.ID
                            };
                            db.UserProfiles.AddRange(new List <UserProfile> {
                                profile
                            });
                            db.SaveChanges();
                            MessageBox.Show("Пользователь добавлен");
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
0
 private void btnAddProduct_Click(object sender, EventArgs e)
 {
     //  MessageBox.Show(LoadImage+"\n" +LoadScheme);
     using (StorehouseContext db = new StorehouseContext())
     {
         if (txtFIOpvd.Text.Length > 0 && txtAdresprv.Text.Length > 0 && dateTimeGet.Value.Date != null)
         {
             var provider = new Provider()
             {
                 FIO                 = txtFIOpvd.Text,
                 Legaladdress        = txtAdresprv.Text,
                 dateProviderProduct = dateTimeGet.Value.Date,
             };
             db.Providers.Add(provider);
             db.SaveChanges();
             if (txtNameProduct.Text.Length > 0 && txtCount.Text.Length > 0 && txtPrvd.Text.Length > 0 &&
                 ComboEdSize.Text.Length > 0 && dateDid.Value.Date != null && dateTimeGet.Value.Date != null && txtPrice.Text.Length > 0)
             {
                 if (LoadImage.Length > 0 && LoadScheme.Length > 0)
                 {
                     if (richTextBox1.Text.Length > 0)
                     {
                         var product = new Product()
                         {
                             NameProduct             = txtNameProduct.Text,
                             CountProductOnStorehome = Convert.ToInt32(txtCount.Text),
                             NameFirma          = txtPrvd.Text,
                             Measure            = ComboEdSize.SelectedItem.ToString(),
                             CreateOn           = dateDid.Value.Date,
                             ReceiptDate        = dateTimeGet.Value.Date,
                             PriceProduct       = Convert.ToDecimal(txtPrice.Text),
                             ProviderId         = provider.ID,
                             Images             = LoadImage,
                             ImageScheme        = LoadScheme,
                             InformationProduct = richTextBox1.Text,
                             UserId             = IdUser
                         };
                         db.Products.AddRange(new List <Product> {
                             product
                         });
                         db.SaveChanges();
                         SaveFile();
                         MessageBox.Show("Добавлен!");
                     }
                     else
                     {
                         MessageBox.Show("Добавьте изображение!");
                     }
                 }
                 else
                 {
                     MessageBox.Show("Добавьте описание!");
                 }
             }
             else
             {
                 MessageBox.Show("Заполните все поля!");
             }
         }
     }
 }