Esempio n. 1
0
        public void onProcediClick(object sender, EventArgs e)
        {
            try
            {
                if ((View.MostraSubject.SubjectGridView.SelectedRows[0].DataBoundItem as Customer).Reliable)
                {
                    double   sconto          = double.Parse(View.Sconto.Text);
                    Customer selectedSubject = View.MostraSubject.SubjectGridView.SelectedRows[0].DataBoundItem as Customer;
                    Invoice  generated       = FGManager.Instance.InvoiceGenerator(new Sell(new List <Product>(FGManager.Instance.ShoppingCart.ProductsList), DateTime.Now), View.Pagato.Checked, sconto, selectedSubject, FGManager.Instance.Logged, View.ScontoPercentuale.Checked);

                    FGManager.Instance.InvoicesRiepilogue.Add(generated);

                    foreach (Product p in FGManager.Instance.ShoppingCart.ProductsList)
                    {
                        FGManager.Instance.Warehouse.RemoveProduct(p);
                    }

                    FGManager.Instance.ShoppingCart.EmptyShoppingCart();

                    MessageBox.Show(generated.toFullString());
                    MessageBox.Show("Inserimento andato a buon fine");

                    GestoreView.GetInstance().MostraView(typeof(MainPage), typeof(MainPagePresenter));
                    GestoreView.GetInstance().ChiudiView(typeof(MostraSubAfterShoppingVendita));
                }
                else
                {
                    MessageBox.Show("Impossibile servire dei servizi a questo cliente");
                }
            } catch (Exception)
            {
                MessageBox.Show("Errore nella generazione della fattura");
            }
        }
Esempio n. 2
0
        private void tornaIndietro()
        {
            bool           inMain = true;
            FormCollection fc     = Application.OpenForms;

            foreach (Form fm in fc)
            {
                if (fm is MostraSubAfterShoppingNolo)
                {
                    GestoreView.GetInstance().MostraView(typeof(MostraSubAfterShoppingNolo), typeof(MostraSubjectFromShoppingNoloPresenter));
                    GestoreView.GetInstance().ChiudiView(typeof(InsertNewCustumer));
                    inMain = false;
                    break;
                }
                else if (fm is MostraSubAfterShoppingVendita)
                {
                    GestoreView.GetInstance().MostraView(typeof(MostraSubAfterShoppingVendita), typeof(MostraSubjectFromShoppingPresenterVendita));
                    GestoreView.GetInstance().ChiudiView(typeof(InsertNewCustumer));
                    inMain = false;
                    break;
                }
            }

            if (inMain)
            {
                GestoreView.GetInstance().MostraView(typeof(MainPage), typeof(MainPagePresenter));
                GestoreView.GetInstance().ChiudiView(typeof(InsertNewCustumer));
            }
        }
Esempio n. 3
0
        public void onProcediClick(object sender, EventArgs e)
        {
            try
            {
                if ((View.MostraSubject.SubjectGridView.SelectedRows[0].DataBoundItem as Customer).Reliable)
                {
                    double         sconto          = double.Parse(View.ScontoTextBox.Text);
                    Customer       selectedSubject = View.MostraSubject.SubjectGridView.SelectedRows[0].DataBoundItem as Customer;
                    List <Product> shoppingcart    = new List <Product>(FGManager.Instance.ShoppingCart.ProductsList);

                    Rent generated = new Rent(shoppingcart, View.InizioTime.Value.Date, View.FineTime.Value.Date, Services.CalculateRentCode(), selectedSubject);

                    FGManager.Instance.RentsRiepilogue.Add(generated);


                    FGManager.Instance.ShoppingCart.EmptyShoppingCart();

                    MessageBox.Show(generated.toFullString());
                    MessageBox.Show("Noleggio andato a buon fine");



                    GestoreView.GetInstance().MostraView(typeof(MainPage), typeof(MainPagePresenter));
                    GestoreView.GetInstance().ChiudiView(typeof(MostraSubAfterShoppingNolo));
                }
                else
                {
                    MessageBox.Show("Impossibile offire dei servizi a questo cliente");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Errore nella generazione del noleggio");
            }
        }
Esempio n. 4
0
        public void OnConfermaClick(object sender, EventArgs e)
        {
            if (FGManager.Instance.ShoppingCart.ProductsList.Count > 0)
            {
                bool isVendita = true;
                if (View.Vendita.Checked)
                {
                    isVendita = true;
                }
                else if (View.Noleggio.Checked)
                {
                    isVendita = false;
                }

                if (isVendita) //fai partire gestore view per la venditaForm
                {
                    GestoreView.GetInstance().MostraView(typeof(MostraSubAfterShoppingVendita), typeof(MostraSubjectFromShoppingPresenterVendita));
                    GestoreView.GetInstance().ChiudiView(typeof(ShopppingCartForm));
                    GestoreView.GetInstance().NascondiView(typeof(MainPage));
                }
                else //gestore view NoleggioForm
                {
                    GestoreView.GetInstance().MostraView(typeof(MostraSubAfterShoppingNolo), typeof(MostraSubjectFromShoppingNoloPresenter));
                    GestoreView.GetInstance().ChiudiView(typeof(ShopppingCartForm));
                    GestoreView.GetInstance().NascondiView(typeof(MainPage));
                }
            }
            else
            {
                MessageBox.Show("Carrello Vuoto non puoi procedere");
            }
        }
Esempio n. 5
0
        public void onIndietroClick(object sender, EventArgs e)
        {
            foreach (Product p in FGManager.Instance.ShoppingCart.ProductsList)
            {
                FGManager.Instance.Warehouse.ProductList.Where(pr => pr.ProductCode == p.ProductCode).First().IsAvailable = true;
            }
            FGManager.Instance.ShoppingCart.EmptyShoppingCart();

            GestoreView.GetInstance().MostraView(typeof(MainPage), typeof(MainPagePresenter));
            GestoreView.GetInstance().ChiudiView(typeof(MostraSubAfterShoppingVendita));
        }
Esempio n. 6
0
 public void onMostraClick(object sender, EventArgs e)
 {
     if (FGManager.Instance.ShoppingCart.ProductsList.Count == 0)
     {
         MessageBox.Show("Carrello vuoto!", "SHOPPING CART", MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
     else
     {
         GestoreView.GetInstance().MostraView(typeof(ShopppingCartForm), typeof(ShoppingCartPresenter));
     }
 }
Esempio n. 7
0
 public void CheckLogin()
 {
     if (FGManager.Instance.Login(LoginForm.Username.Text, LoginForm.Password.Text))
     {
         GestoreView.GetInstance().RimuoviView(typeof(MainPage));
         GestoreView.GetInstance().MostraView(typeof(MainPage), typeof(MainPagePresenter));
         GestoreView.GetInstance().NascondiView(typeof(LoginForm));
     }
     else
     {
         MessageBox.Show("Username oppure password non validi", "Login Perform", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 8
0
 private void populateView()
 {
     if (FGManager.Instance.ShoppingCart.ProductsList.ToList().Count > 0)
     {
         View.ShoppingCartDataGrid.DataSource = null;
         View.ShoppingCartDataGrid.Rows.Clear();
         View.ShoppingCartDataGrid.DataSource = FGManager.Instance.ShoppingCart.ProductsList.ToList();
     }
     else
     {
         GestoreView.GetInstance().ChiudiView(typeof(ShopppingCartForm));
     }
 }
Esempio n. 9
0
        private void onConfirmClick(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(View.DescrizioneText.Text.Trim()) && String.IsNullOrWhiteSpace(View.MarcaText.Text.Trim()) && String.IsNullOrWhiteSpace(View.NoleggioText.Text.Trim()) && String.IsNullOrWhiteSpace(View.VenditaText.Text.Trim()))
            {
                MessageBox.Show("Inserire tutti i campi del prodotto", "INSERIMENTO PRODOTTO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                try
                {
                    string productType = View.TipologiaCombo.SelectedItem.ToString();
                    productType = productType.Replace("Product", String.Empty);
                    Type     enumType        = typeof(Product).Assembly.GetTypes().Where(t => t.IsEnum && t.Name.Contains("Category") && t.Name.Contains(productType)).First();
                    string   category        = View.CategoryCombo.SelectedItem.ToString();
                    object[] constructorArgs = new object[8];



                    constructorArgs[1] = View.DescrizioneText.Text;
                    constructorArgs[2] = Services.RoundToTwo(double.Parse(View.VenditaText.Text));
                    constructorArgs[3] = Services.RoundToTwo(double.Parse(View.NoleggioText.Text));
                    constructorArgs[4] = true;
                    constructorArgs[5] = true;
                    constructorArgs[6] = View.MarcaText.Text;
                    constructorArgs[7] = Enum.Parse(enumType, category);
                    constructorArgs[0] = FGManager.Instance.ProductNumberGenerator(productType, constructorArgs[6].ToString());


                    Type selected = typeof(Product).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(Product)) && !t.IsAbstract && t.Name == View.TipologiaCombo.SelectedItem.ToString()).First();

                    Product result = Activator.CreateInstance(selected, constructorArgs) as Product;


                    FGManager.Instance.Warehouse.AddProduct(result);

                    MessageBox.Show("Prodotto inserito con successo");

                    GestoreView.GetInstance().MostraView(typeof(MainPage), typeof(MainPagePresenter));
                    GestoreView.GetInstance().ChiudiView(typeof(InsertNewProductForm));
                } catch (Exception)
                {
                    MessageBox.Show("Errore nell'inserimento dei parametri");
                }
            }
        }
Esempio n. 10
0
 private void onBackClick(object sender, EventArgs e)
 {
     GestoreView.GetInstance().MostraView(typeof(MainPage), typeof(MainPagePresenter));
     GestoreView.GetInstance().ChiudiView(typeof(InsertNewProductForm));
 }
Esempio n. 11
0
 public void OnAddSubject(object sender, EventArgs e)
 {
     GestoreView.GetInstance().MostraView(typeof(InsertNewCustumer), typeof(InsertNewCostumerPresenter));
     GestoreView.GetInstance().NascondiView(typeof(MainPage));
 }
Esempio n. 12
0
 public void onAggiungiClick(object sender, EventArgs e)
 {
     GestoreView.GetInstance().MostraView(typeof(InsertNewCustumer), typeof(InsertNewCostumerPresenter));
     GestoreView.GetInstance().NascondiView(typeof(MostraSubAfterShoppingVendita));
 }
Esempio n. 13
0
 private void onAddClick(object sender, EventArgs args)
 {
     GestoreView.GetInstance().MostraView(typeof(InsertNewProductForm), typeof(InsertNewProductPresenter));
     GestoreView.GetInstance().NascondiView(typeof(MainPage));
 }
Esempio n. 14
0
 private void Logout()
 {
     GestoreView.GetInstance().NascondiView(typeof(MainPage));
     GestoreView.GetInstance().MostraView(typeof(LoginForm), typeof(LoginPresenter));
 }
Esempio n. 15
0
 public void OnIndietroClick(object sender, EventArgs e)
 {
     GestoreView.GetInstance().ChiudiView(typeof(ShopppingCartForm));
 }