예제 #1
0
        private void sellingUpdateButton_Click(object sender, EventArgs e)
        {
            try
            {
                var    id      = new Guid(DatabaseWorker.getWordFromListBox(sellingListBox, 0));
                string address = DatabaseWorker.getWordFromListBox(sellingListBox, 1);
                string flavor  = DatabaseWorker.getWordFromListBox(sellingListBox, 2);
                using (var db = new IceCreamContext())
                {
                    var updateSelling = (from selling in db.IceCreamSelling
                                         where selling.SellingId == id
                                         select selling).First();

                    var newStore = (from store in db.IceCreamStores
                                    where store.Address == address
                                    select store).First();

                    var newIceCream = (from iceCream in db.IceCreamFlavors
                                       where iceCream.Flavor == flavor
                                       select iceCream).First();

                    string updateInfo = "update IceCreamSelling set Store='" + newStore + "',IceCreamFlavor='"
                                        + newIceCream + "' where SellingId='" + updateSelling.SellingId + "';";
                    DatabaseWorker.ConnectionSQL(updateInfo);
                    DatabaseWorker.updateSellingListBox(sellingListBox);
                }
            }
            catch (Exception ex)
            {
                sellingErrorLabel.Text = ex.Message;
            }
        }
예제 #2
0
        private void sellerUpdateNumber_Click(object sender, EventArgs e)
        {
            try
            {
                string keyText = DatabaseWorker.getWordFromListBox(sellersListBox, 0);
                string work    = DatabaseWorker.getWordFromListBox(sellersListBox, 4);
                using (var db = new IceCreamContext())
                {
                    var updateSeller = (from seller in db.IceCreamSellers
                                        where seller.PersonalId == keyText
                                        select seller).First();

                    var iceCreamStore = (from store in db.IceCreamStores
                                         where store.Address == work
                                         select store).First();

                    string updateInfo = "update IceCreamSellers set PersonalId='" + sellerPersonalIdTextBox.Text + "',FirstName='"
                                        + sellerFirstNameTextBox.Text + "',LastName='" + sellerLastNameTextBox.Text + "',Salary='" + sellerSalaryTextBox.Text
                                        + "',IceCreamStore='" + iceCreamStore + "' where Address='" + updateSeller.PersonalId + "';";
                    DatabaseWorker.ConnectionSQL(updateInfo);
                    DatabaseWorker.updateSellersListBox(sellersListBox);
                }
            }
            catch (Exception ex)
            {
                sellerErrorLabel.Text = ex.Message;
            }
        }
예제 #3
0
        private void updateIceCreamButton_Click(object sender, EventArgs e)
        {
            try
            {
                string keyText = DatabaseWorker.getWordFromListBox(IceCreamListBox, 0);
                string makerId = DatabaseWorker.getWordFromListBox(IceCreamListBox, 2);

                using (var db = new IceCreamContext())
                {
                    var updateIceCream = (from iceCream in db.IceCreamFlavors
                                          where iceCream.Flavor == keyText
                                          select iceCream).First();

                    var iceCreamMaker = (from maker in db.IceCreamMakers
                                         where maker.MakersPersonalId == makerId
                                         select maker).First();

                    string updateInfo = "update IceCreamFlavors set Flavor='" + flavorTextBox.Text + "',PricePerKilo='" + pricePerKiloTextBox.Text
                                        + "',IceCreamMaker='" + iceCreamMaker + "' where Flavor='" + updateIceCream.Flavor + "';";
                    DatabaseWorker.ConnectionSQL(updateInfo);
                    DatabaseWorker.updateIceCreamListBox(IceCreamListBox);
                }
            }
            catch (Exception ex)
            {
                iceCreamErrorLabel.Text = ex.Message;
            }
        }
예제 #4
0
 public IceCreamDatabaseForm()
 {
     InitializeComponent();
     DatabaseWorker.updateStoreListBox(StoreListBox);
     DatabaseWorker.updateMakersListBox(makersListBox);
     DatabaseWorker.updateIceCreamListBox(IceCreamListBox);
     DatabaseWorker.updateSellersListBox(sellersListBox);
     DatabaseWorker.updateSellingListBox(sellingListBox);
 }
예제 #5
0
        private void StoreDeleteButton_Click(object sender, EventArgs e)
        {
            try
            {
                string keyText = DatabaseWorker.getWordFromListBox(StoreListBox, 0);
                using (var db = new IceCreamContext())
                {
                    var deleteStore = (from store in db.IceCreamStores
                                       where store.Address == keyText
                                       select store).First();

                    db.IceCreamStores.Remove(deleteStore);
                    db.SaveChanges();
                    StoreListBox.Items.Remove(StoreListBox.SelectedItem);
                }
            }
            catch (Exception ex)
            {
                storeErrorLabel.Text = ex.Message;
            }
        }
예제 #6
0
        private void sellingDeleteButton_Click(object sender, EventArgs e)
        {
            try
            {
                var id = new Guid(DatabaseWorker.getWordFromListBox(sellingListBox, 0));

                using (var db = new IceCreamContext())
                {
                    var deleteSelling = (from selling in db.IceCreamSelling
                                         where selling.SellingId == id
                                         select selling).First();

                    db.IceCreamSelling.Remove(deleteSelling);
                    db.SaveChanges();
                    sellingListBox.Items.Remove(sellingListBox.SelectedItem);
                }
            }
            catch (Exception ex)
            {
                sellingErrorLabel.Text = ex.Message;
            }
        }
예제 #7
0
        private void sellerDeleteButton_Click(object sender, EventArgs e)
        {
            try
            {
                string keyText = DatabaseWorker.getWordFromListBox(sellersListBox, 0);

                using (var db = new IceCreamContext())
                {
                    var deleteSeller = (from seller in db.IceCreamSellers
                                        where seller.PersonalId == keyText
                                        select seller).First();

                    db.IceCreamSellers.Remove(deleteSeller);
                    db.SaveChanges();
                    sellersListBox.Items.Remove(sellersListBox.SelectedItem);
                }
            }
            catch (Exception ex)
            {
                sellerErrorLabel.Text = ex.Message;
            }
        }
예제 #8
0
        private void deleteIceCreamButton_Click(object sender, EventArgs e)
        {
            try
            {
                string keyText = DatabaseWorker.getWordFromListBox(IceCreamListBox, 0);

                using (var db = new IceCreamContext())
                {
                    var deleteIceCream = (from iceCream in db.IceCreamFlavors
                                          where iceCream.Flavor == keyText
                                          select iceCream).First();

                    db.IceCreamFlavors.Remove(deleteIceCream);
                    db.SaveChanges();
                    IceCreamListBox.Items.Remove(IceCreamListBox.SelectedItem);
                }
            }
            catch (Exception ex)
            {
                iceCreamErrorLabel.Text = ex.Message;
            }
        }
예제 #9
0
        private void StoreUpdateButton_Click(object sender, EventArgs e)
        {
            try
            {
                string keyText = DatabaseWorker.getWordFromListBox(StoreListBox, 0);

                using (var db = new IceCreamContext())
                {
                    var updateStore = (from store in db.IceCreamStores
                                       where store.Address == keyText
                                       select store).First();

                    string updateInfo = "update IceCreamStores set Adress='" + AddressTextBox.Text + "',WorkingHours='" + workingHoursTextBox.Text
                                        + "' where Adress='" + updateStore.Address + "';";
                    DatabaseWorker.ConnectionSQL(updateInfo);
                    DatabaseWorker.updateStoreListBox(StoreListBox);
                }
            }
            catch (Exception ex)
            {
                storeErrorLabel.Text = ex.Message;
            }
        }
예제 #10
0
        private void makerUpdateButton_Click(object sender, EventArgs e)
        {
            try
            {
                string keyText = DatabaseWorker.getWordFromListBox(makersListBox, 0);
                using (var db = new IceCreamContext())
                {
                    var updateMaker = (from maker in db.IceCreamMakers
                                       where maker.MakersPersonalId == keyText
                                       select maker).First();


                    string updateInfo = "update IceCreamMakers set MakersPersonalID='" + makerIdTextBox.Text + "',FirstName='"
                                        + makerFirstNameTextBox.Text + "',LastName='" + makerLastNameTextBox.Text + "',Salary='" + MakerSalaryTextBox.Text
                                        + "',PhoneNumber='" + MakerPhoneNumberTextBox.Text + "' where makersPersonalID='" + updateMaker.MakersPersonalId + "';";
                    DatabaseWorker.ConnectionSQL(updateInfo);
                    DatabaseWorker.updateMakersListBox(makersListBox);
                }
            }
            catch (Exception ex)
            {
                makerErrorLabel.Text = ex.Message;
            }
        }
예제 #11
0
 private void workPlaceButton_Click(object sender, EventArgs e)
 {
     DatabaseWorker.ShowSellersWorks(worksListBox);
 }