Esempio n. 1
0
 public BILL_BillQuotationStatus CreateBillQuotationStatus(BILL_BillQuotationStatus billQuotationStatusToAdd)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         var exist = context.BILL_BillQuotationStatus.SingleOrDefault(x => x.BillQuotation_Id == billQuotationStatusToAdd.BillQuotation_Id
                                                             && x.BILL_Status.Status_Id == billQuotationStatusToAdd.BILL_Status.Status_Id);
         if (exist != null)
             return exist;
         else
         {
             var s = context.BILL_BillQuotationStatus.Add(billQuotationStatusToAdd);
             context.SaveChanges();
             return s;
         }
     }
 }
Esempio n. 2
0
        /******************************/
        /*    MODIFICATION FACTURE    */
        /******************************/
        public bool ModifyBillQuotation(BillQuotationComplete billQuotationComplete)
        {
            var res = true;
            try
            {
                /*** Modification de la facture/devis ***/
                BILL_BillQuotation bill = new BILL_BillQuotation
                {
                    BillQuotation_Id = billQuotationComplete.BillQuotation_Id,
                    AmountDF = billQuotationComplete.AmountDF,
                    BILL_Transmitter = billQuotationComplete.BILL_Transmitter,
                    Company = billQuotationComplete.Company,
                    DateBillQuotation = billQuotationComplete.DateBillQuotation,
                    NBill = billQuotationComplete.NBill,
                    Vat = billQuotationComplete.Vat,
                    Company_Id = billQuotationComplete.Company_Id,
                    Transmitter_Id = billQuotationComplete.Transmitter_Id
                };

                var billEdit = billQuotationBLL.EditBillQuotation(bill);

                /*** Modification du status ***/
                var status = new BILL_BillQuotationStatus { BillQuotation_Id = bill.BillQuotation_Id, DateAdvancement = DateTime.Now, Status_Id = billQuotationComplete.BillStatus.Status_Id };
                //bqsBLL.CreateBillQuotationStatus(status);

                /*** Modification des lignes de facture ***/
                var lineBDD = lineBLL.GetLineBillQuotation(billQuotationComplete.BillQuotation_Id);
                var lineModif = billQuotationComplete.BILL_LineBillQuotation;

                var listLineAModifie = new List<BILL_LineBillQuotation>();
                var listLineAAjoute = new List<BILL_LineBillQuotation>();
                /* TODO: METTRE A JOUR LES LIGNES FACTURES */
                foreach (var line in lineModif)
                {
                    if (line != null)
                    {
                        var l = new BILL_LineBillQuotation
                       {
                           BillQuotation_Id = bill.BillQuotation_Id,
                           DateLine = line.DateLine,
                           LineBillQuotation_Id = line.LineBillQuotation_Id,
                           Product_Id = line.Product_Id,
                           Quantite = line.Quantite
                       };

                        var lineExist = lineBDD.SingleOrDefault(x => x.LineBillQuotation_Id == line.LineBillQuotation_Id);
                        if (lineExist != null && lineExist.LineBillQuotation_Id != 0)
                        {
                            listLineAModifie.Add(l);
                            lineBDD.Remove(l);
                        }
                        else
                        {
                            listLineAAjoute.Add(l);
                            lineBDD.Remove(l);
                        }
                    }
                }

                lineBLL.CreateLineBillQuotation(listLineAAjoute);
                lineBLL.EditLineBillQuotation(listLineAModifie);
                lineBLL.DeleteLineBillQuotation(lineBDD);
            }
            catch (Exception)
            {
                res = false;
            }
            return res;
        }
Esempio n. 3
0
        public bool CreateBillQuotation(BillQuotationComplete billQuotationComplete)
        {
            var res = true;
            try
            {
                BILL_BillQuotation bill = new BILL_BillQuotation
                {
                    AmountDF = billQuotationComplete.AmountDF,
                    BILL_Transmitter = billQuotationComplete.BILL_Transmitter,
                    Company = billQuotationComplete.Company,
                    DateBillQuotation = billQuotationComplete.DateBillQuotation,
                    NBill = billQuotationComplete.NBill,
                    Vat = billQuotationComplete.Vat,
                    Company_Id = billQuotationComplete.Company_Id,
                    Transmitter_Id = billQuotationComplete.Transmitter_Id
                };

                //bill = billQuotationBLL.CreateBillQutotation(bill);

                var status = new BILL_BillQuotationStatus { BILL_BillQuotation = bill, BillQuotation_Id = bill.BillQuotation_Id, DateAdvancement = DateTime.Now, Status_Id = billQuotationComplete.BillStatus.Status_Id };
                bqsBLL.CreateBillQuotationStatus(status);

                billQuotationBLL.SetNumFacture();

                if (billQuotationComplete.lines == null) return res;

                var listLine = new List<BILL_LineBillQuotation>();
                foreach (var line in billQuotationComplete.lines)
                {
                    var l = new BILL_LineBillQuotation
                    {
                        BILL_BillQuotation = bill,
                        BILL_Product = line.BILL_Product,
                        BillQuotation_Id = bill.BillQuotation_Id,
                        DateLine = line.DateLine,
                        LineBillQuotation_Id = line.LineBillQuotation_Id,
                        Product_Id = line.Product_Id,
                        Quantite = line.Quantite
                    };

                    listLine.Add(l);
                }

                lineBLL.CreateLineBillQuotation(listLine);
            }
            catch (Exception)
            {
                res = false;
            }
            return res;
        }
Esempio n. 4
0
 public BILL_BillQuotationStatus CreateBillQuotationStatus(BILL_BillQuotationStatus billQuotationStatusToAdd)
 {
     return DAL.CreateBillQuotationStatus(billQuotationStatusToAdd);
 }