public FactureViewModel()
        {
            // Fill Factures
            FactureModel facture = new FactureModel();

            Factures = facture.GiveCollection(facture.All());
        }
Example #2
0
        // GET: AchatController/Details/5
        public ActionResult Details(int id)
        {
            FactureModel model = new FactureModel();

            model.utilisateur = GetChefFromCookie();
            model.document    = documentBusiness.getDocumentById(id);
            model.achatList   = achatBusiness.getAchatByDocumentId(id);
            return(View(model));
        }
Example #3
0
        public void CreateFacture()
        {
            FactureModel facture = new FactureModel
            {
                Customer = Customer.Id
            };

            ActivateItem(new CreateFactureViewModel(facture));
        }
        public void Search()
        {
            FactureModel fm = new FactureModel();

            fm = fm.GetMeByNumber(SearchNumber);
            if (fm != null)
            {
                View(fm);
            }
            else
            {
                MessageBox.Show("Number not found.", "Wrong Number", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 public void Save()
 {
     if (Enabled == false)
     {
         MainButtonText = "Update Receipt";
         Enabled        = true;
     }
     else
     if (CheckForm())
     {
         ReceiptModel rm = Receipt;
         rm.Number   = Number;
         rm.Customer = Customer.Id;
         rm.Amount   = (decimal)Amount;
         rm.Currency = Currency.Id;
         rm.Delivery = Delivery;
         if (Details != null && Details.Trim() != string.Empty)
         {
             rm.Details = Details.Trim();
         }
         if (Season != null)
         {
             rm.Season = Season.Id;
         }
         if (Facture != null)
         {
             rm.Facture = Facture.Id;
         }
         if (Cheque != null && Cheque.Trim() != string.Empty)
         {
             rm.Cheque = Cheque.Trim();
         }
         rm = rm.UpdateThis();
         if (rm.Facture != null && rm.Facture.ToString() != "0")
         {
             if (OldFacture != null)
             {
                 FactureModel fm = new FactureModel();
                 fm = fm.Get((int)OldFacture);
                 fm.ClearUnclear(false);
             }
             rm.ClearFacture();
         }
         System.Windows.MessageBox.Show("Receipt created successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
     }
 }
Example #6
0
        public void Save()
        {
            // Create Facture and Save it
            FactureModel NewFacture = CreateFacture();

            if (NewFacture != null)
            {
                NewFacture = NewFacture.SaveThis();
                // Get Facture Id
                int NewFactureId = NewFacture.Id;
                // Loop over Details List and Save FactureDetails
                foreach (FactureDetailsModel facture_detail in FactureDetailsList)
                {
                    facture_detail.Facture = NewFactureId;
                    facture_detail.SaveThis();
                }
                MessageBox.Show("Facture Created Successfully!", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        public string CreateFacture(FactureModel objCust)
        {
            try
            {
                FactureDataAccessLayer tEnregistrementFacture = new FactureDataAccessLayer();
                Int32 message = 0;

                if (objCust.RefFacture != null)
                {
                    message = tEnregistrementFacture.InsertFacture(objCust);
                }

                return(message.ToString());
            }
            catch
            {
                throw;
            }
        }
Example #8
0
 private FactureModel CreateFacture()
 {
     if (CheckData())
     {
         FactureModel facture = new FactureModel()
         {
             Number   = this.Number,
             Name     = this.Name,
             Customer = this.Customer.Id,
             Cleared  = this.Cleared,
             Delivery = this.Delivery,
         };
         if (Season != null)
         {
             facture.Season = Season.Id;
         }
         return(facture);
     }
     return(null);
 }
Example #9
0
        public ViewFactureViewModel(FactureModel facture, bool customer_fixed = false)
        {
            // Fill Customers
            CustomerModel customers = new CustomerModel();

            Customers = customers.GiveCollection(customers.All());
            // Fill Seasons
            SeasonModel sm = new SeasonModel();

            Seasons = sm.GiveCollection(sm.All());
            //Fill Sizes
            SizeModel size = new SizeModel();

            Sizes = size.GiveCollection(size.All());
            //Fill Currencies
            CurrencyModel currency = new CurrencyModel();

            Currencies = currency.GiveCollection(currency.All());
            // Fill Data
            Facture  = facture;
            Number   = facture.Number;
            Name     = facture.Name;
            Delivery = facture.Delivery;
            FillCombos();
            // Fill Details
            FactureDetailsList = facture.GetFactureDetailsList();
            FactureDetails     = new BindableCollection <FactureDetailsModel>(FactureDetailsList);
            IsEnabled          = false;
            BtnSaveText        = "Enable Editing";
            Cleared            = facture.Cleared;
            IsCustomerFixed    = customer_fixed;
            if (customer_fixed == false)
            {
                IsCustomerEnabled = IsEnabled;
            }
            else
            {
                IsCustomerEnabled = false;
            }
        }
Example #10
0
        public CreateFactureViewModel(FactureModel facture = null)
        {
            // Fill Customers
            CustomerModel customers = new CustomerModel();

            Customers = customers.GiveCollection(customers.All());
            // Fill Seasons
            SeasonModel sm = new SeasonModel();

            Seasons = sm.GiveCollection(sm.All());
            //Fill Sizes
            SizeModel size = new SizeModel();

            Sizes = size.GiveCollection(size.All());
            //Fill Currencies
            CurrencyModel currency = new CurrencyModel();

            Currencies = currency.GiveCollection(currency.All());
            Delivery   = DateTime.UtcNow.Date;
            if (facture != null)
            {
                for (int i = 0; i < Customers.Count; i++)
                {
                    int id1 = Customers[i].Id;
                    int id2 = (int)facture.Customer;
                    if (id1 == id2)
                    {
                        Customer = Customers[i];
                        break;
                    }
                }
                IsEnabled = false;
            }
            else
            {
                IsEnabled = true;
            }
        }
Example #11
0
 public void View(FactureModel facture)
 {
     ActivateItem(new ViewFactureViewModel(facture));
 }
Example #12
0
        public void FillFactures()
        {
            if (FactureNumber.ToString().Trim() != "0" && (FactureNumber % 1) == 0)
            {
                try
                {
                    FactureModel        fm   = new FactureModel();
                    List <FactureModel> list = new List <FactureModel>()
                    {
                        fm.GetMeByNumber(FactureNumber, Customer.Id)
                    };
                    if (list[0] == null)
                    {
                        throw new Exception("No facture for " + Customer.Name + " with number " + FactureNumber);
                    }
                    Factures = new BindableCollection <FactureModel>(list);
                }
                catch (Exception e)
                {
                    Factures = new BindableCollection <FactureModel>();
                }
            }
            else
            {
                switch (FactureType)
                {
                case "All":
                    switch (FacturesSeason.Id.ToString())
                    {
                    case "0":
                        if (FacturesSeason.Year == "None")
                        {
                            Factures = Customer.GetMyFactures(0);
                        }
                        else
                        {
                            Factures = Customer.GetMyFactures();
                        }
                        break;

                    default:
                        Factures = Customer.GetMyFactures(FacturesSeason.Id);
                        break;
                    }
                    break;

                case "Cleared":
                    switch (FacturesSeason.Id.ToString())
                    {
                    case "0":
                        if (FacturesSeason.Year == "None")
                        {
                            Factures = Customer.GetMyClearedFactures(0);
                        }
                        else
                        {
                            Factures = Customer.GetMyClearedFactures(FacturesSeason.Id);
                        }
                        break;

                    default:
                        Factures = Customer.GetMyClearedFactures(FacturesSeason.Id);
                        break;
                    }
                    break;

                case "Uncleared":
                    switch (FacturesSeason.Id.ToString())
                    {
                    case "0":
                        if (FacturesSeason.Year == "None")
                        {
                            Factures = Customer.GetMyUnClearedFactures(0);
                        }
                        else
                        {
                            Factures = Customer.GetMyUnClearedFactures(FacturesSeason.Id);
                        }
                        break;

                    default:
                        Factures = Customer.GetMyUnClearedFactures(FacturesSeason.Id);
                        break;
                    }
                    break;

                default:
                    break;
                }
            }
        }