Exemplo n.º 1
0
        private void AddCategoryButton_Click(object sender, EventArgs e)
        {
            var DBContext = new SimpleWarehousContext();

            var temp = new Category {
                Name = textBox1.Text
            };

            DBContext.Categories.Add(temp);
            DBContext.SaveChanges();

            RefreshData();
        }
        private void AddButton_Click(object sender, EventArgs e)
        {
            var DBContext = new SimpleWarehousContext();

            Address temp = new Address {
                Street = StreetBox.Text, StreetNumber = (int)NumberBox.Value, City = CityBox.Text, Zipcode = ZipBox.Text
            };

            MessageBox.Show("Dodawanie klienta " + (int)NumberBox.Value + " " + StreetBox.Text);
            DBContext.Adresses.Add(temp);
            DBContext.SaveChanges();

            RefreshData();
        }
Exemplo n.º 3
0
        private void ProductsAdd_Click(object sender, EventArgs e)
        {
            var DBContext = new SimpleWarehousContext();

            Category tempCat = (Category)ProductsAddCat.SelectedItem;
            Product  temp    = new Product {
                DisplayName = ProductsAddName.Text, Price = (double)ProductsAddPrice.Value, Description = ProductsAddDesc.Text, CategoryId = tempCat.CategoryId
            };

            MessageBox.Show("Dodawanie produktu " + ProductsAddName.Text);
            DBContext.Produts.Add(temp);
            DBContext.SaveChanges();

            RefreshData();
        }
Exemplo n.º 4
0
        private void WarehousesAdd_Click(object sender, EventArgs e)
        {
            var DBContext = new SimpleWarehousContext();

            Company  tempComp = (Company)WarehousesAddCompany.SelectedItem;
            Warehous temp     = new Warehous {
                WarehouseName = WarehousesAddName.Text, AddressId = AdId, CompanyId = tempComp.CompanyId
            };

            MessageBox.Show("Dodawanie magazynu " + WarehousesAddName.Text);
            DBContext.Warehouses.Add(temp);
            DBContext.SaveChanges();

            RefreshData();
        }
        private void AddButton_Click(object sender, EventArgs e)
        {
            var DBContext = new SimpleWarehousContext();

            CompanyRole tempRole = (CompanyRole)CompanyRoleId.SelectedItem;
            User        temp     = new User {
                Name = NameBox.Text, Surename = SurnameBox.Text, Phone = PhoneBox.Text, Email = EmailBox.Text, AddressId = AdId, CompanyRoleId = tempRole.CompanyRoleId
            };

            MessageBox.Show("Dodawanie klienta " + NameBox.Text);
            DBContext.Users.Add(temp);
            DBContext.SaveChanges();

            RefreshData();
        }
Exemplo n.º 6
0
        private void ProductsDelete_Click(object sender, EventArgs e)
        {
            var DBContext = new SimpleWarehousContext();

            Product temp = new Product();

            foreach (DataGridViewRow row in productsGridView.SelectedRows)
            {
                MessageBox.Show("USUWANIE: Index " + row.Index.ToString() + " ID: " + row.Cells[0].Value.ToString());
                temp.ProductId = (int)row.Cells[0].Value;
                DBContext.Produts.Remove(temp);
                DBContext.SaveChanges();
            }

            RefreshData();
        }
Exemplo n.º 7
0
        private void DeleteCategoryButton_Click(object sender, EventArgs e)
        {
            var DBContext = new SimpleWarehousContext();

            Category temp = new Category();

            foreach (DataGridViewRow row in categoriesGridView.SelectedRows)
            {
                MessageBox.Show("USUWANIE: Index " + row.Index.ToString() + " ID: " + row.Cells[0].Value.ToString());
                temp.CategoryId = (int)row.Cells[0].Value;
                DBContext.Categories.Remove(temp);
                DBContext.SaveChanges();
            }

            RefreshData();
        }
        private void AddButton_Click(object sender, EventArgs e)
        {
            var DBContext = new SimpleWarehousContext();

            User        tempUser = (User)UserID.SelectedItem;
            Company     tempComp = (Company)CompanyID.SelectedItem;
            OrderStatus tempStat = (OrderStatus)StatusID.SelectedItem;
            Order       temp     = new Order {
                Subotal = SubtotalBox.Value, AdditionalInformations = InfoBox.Text, OrderAddressId = AdId, UserId = tempUser.UserId, CompanyId = tempComp.CompanyId, OrderStatusId = tempStat.OrderStatusId
            };

            MessageBox.Show("Dodawanie Zamowinia ");
            DBContext.Orders.Add(temp);
            DBContext.SaveChanges();

            RefreshData();
        }
Exemplo n.º 9
0
 public void AddEntity(Entity entity)
 {
     simpleWarehousContext.Set <Entity>().Add(entity);
     simpleWarehousContext.SaveChanges();
 }