Ejemplo n.º 1
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            switch (tablename)
            {
            case "ProductType":
                EditProductType editpt = new EditProductType();
                if (editpt.ShowDialog() == DialogResult.OK)
                {
                    db.ProductType.Add(editpt.Result);
                }
                db.SaveChanges();
                break;

            case "Client":
                EditClient editc = new EditClient();
                if (editc.ShowDialog() == DialogResult.OK)
                {
                    db.Client.Add(editc.Result);
                }
                db.SaveChanges();
                break;

            case "Order":
                EditOrder edito = new EditOrder();
                if (edito.ShowDialog() == DialogResult.OK)
                {
                    db.Order.Add(edito.Result);
                }
                db.SaveChanges();
                break;

            case "Delivery":
                EditDelivery editd = new EditDelivery();
                if (editd.ShowDialog() == DialogResult.OK)
                {
                    db.Delivery.Add(editd.Result);
                }
                db.SaveChanges();
                break;

            case "Supplier":
                EditSupplier edits = new EditSupplier();
                if (edits.ShowDialog() == DialogResult.OK)
                {
                    db.Supplier.Add(edits.Result);
                }
                db.SaveChanges();
                break;

            case "Product":
                EditProduct editp = new EditProduct();
                if (editp.ShowDialog() == DialogResult.OK)
                {
                    db.Product.Add(editp.Result);
                }
                db.SaveChanges();
                break;
            }
            db.Dispose();
            db = new OnlineStoreEntities();
            UpdateTable();
        }
Ejemplo n.º 2
0
        private void toolStripButton1_Click_1(object sender, EventArgs e)
        {
            switch (tablename)
            {
            case "ProductType":
                ProductType     rempt  = db.ProductType.Find(dataGridView1.SelectedRows[0].Cells["ID"].Value);
                EditProductType editpt = new EditProductType(rempt);
                if (editpt.ShowDialog() == DialogResult.OK)
                {
                    rempt.Category    = editpt.Result.Category;
                    rempt.Description = editpt.Result.Description;
                    db.SaveChanges();
                }
                break;

            case "Client":
                Client     remc  = db.Client.Find(dataGridView1.SelectedRows[0].Cells["ID"].Value);
                EditClient editc = new EditClient(remc);
                if (editc.ShowDialog() == DialogResult.OK)
                {
                    remc.Fullname    = editc.Result.Fullname;
                    remc.Address     = editc.Result.Address;
                    remc.City        = editc.Result.City;
                    remc.Country     = editc.Result.Country;
                    remc.Phonenumber = editc.Result.Phonenumber;
                    db.SaveChanges();
                }
                break;

            case "Order":
                Order     remo  = db.Order.Find(dataGridView1.SelectedRows[0].Cells["ID"].Value);
                EditOrder edito = new EditOrder(remo);
                if (edito.ShowDialog() == DialogResult.OK)
                {
                    remo.ClientID   = edito.Result.ClientID;
                    remo.Date       = edito.Result.Date;
                    remo.Amount     = edito.Result.Amount;
                    remo.ProductID  = edito.Result.ProductID;
                    remo.DeliveryID = edito.Result.DeliveryID;
                    db.SaveChanges();
                }
                break;

            case "Delivery":
                Delivery     remd  = db.Delivery.Find(dataGridView1.SelectedRows[0].Cells["ID"].Value);
                EditDelivery editd = new EditDelivery(remd);
                if (editd.ShowDialog() == DialogResult.OK)
                {
                    remd.Name        = editd.Result.Name;
                    remd.Phonenumber = editd.Result.Phonenumber;
                    db.SaveChanges();
                }
                break;

            case "Supplier":
                Supplier     rems  = db.Supplier.Find(dataGridView1.SelectedRows[0].Cells["ID"].Value);
                EditSupplier edits = new EditSupplier(rems);
                if (edits.ShowDialog() == DialogResult.OK)
                {
                    rems.Name        = edits.Result.Name;
                    rems.Address     = edits.Result.Address;
                    rems.City        = edits.Result.City;
                    rems.Phonenumber = edits.Result.Phonenumber;
                    rems.Email       = edits.Result.Email;
                    db.SaveChanges();
                }
                break;

            case "Product":
                Product     rem      = db.Product.Find(dataGridView1.SelectedRows[0].Cells["ID"].Value);
                EditProduct editform = new EditProduct(rem);
                if (editform.ShowDialog() == DialogResult.OK)
                {
                    rem.Name          = editform.Result.Name;
                    rem.ProductTypeID = editform.Result.ProductTypeID;
                    rem.SupplierID    = editform.Result.SupplierID;
                    rem.Measure       = editform.Result.Measure;
                    db.SaveChanges();
                }
                break;
            }
            db.Dispose();
            db = new OnlineStoreEntities();
            UpdateTable();
        }