Example #1
0
 public IEnumerable<BILL_Product> GetProductCategory(long idCategory)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         return context.BILL_Product.Include("BILL_Vat").Include("BILL_Category").Where(p => p.Category_Id == idCategory);
     }
 }
Example #2
0
        private void CalculateTTC()
        {
            var htRef = 0.00;
            var context = new SUPERPEntities();
            var lstLine = context.BILL_LineBillQuotation.Where(l => l.BillQuotation_Id == BillQuotation_Id);

            foreach (var line in lstLine)
            {
                var tvaRate = (line.BILL_Product.BILL_Vat.Rate == null) ? 0.00 : Convert.ToDouble(line.BILL_Product.BILL_Vat.Rate);

                double priceProductTTC = (tvaRate * line.BILL_Product.Price) + line.BILL_Product.Price;
                htRef += line.BILL_Product.Price * line.Quantite;
                AmountTTC += priceProductTTC * line.Quantite;
            }

            /* Check if amountHT is valid */
            if (htRef != AmountDF)
            {
                var b = context.BILL_BillQuotation.Find(BillQuotation_Id);
                b.AmountDF = htRef;
                context.SaveChanges();
            }

            /* Check if VAT is affected */
            if (!Vat) AmountTTC = AmountDF;
        }
Example #3
0
 public List<BILL_Status> GetStatus()
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         return context.BILL_Status.ToList();
     }
 }
Example #4
0
 public BILL_Product GetProductByName(string nameProduct)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         return context.BILL_Product.Include("BILL_Vat").Include("BILL_Category").SingleOrDefault(p => p.Name == nameProduct);
     }
 }
 public List<BILL_BillQuotationStatus> GetBillQuotationStatusByBillQuotation(long billQuotation_id)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         return context.BILL_BillQuotationStatus.Where(bqs => bqs.BillQuotation_Id == billQuotation_id).ToList();
     }
 }
Example #6
0
        public static string getMaxNum()
        {
            var numStr = "000000001";

            try
            {
                using (SUPERPEntities context = new SUPERPEntities(false))
                {
                    var num = Convert.ToInt32(numStr);
                    var billQuotation = context.BILL_BillQuotation.OrderByDescending(b => b.NBill);
                    if (billQuotation != null && billQuotation.Count() > 0)
                    {
                        var nbill = billQuotation.First().NBill;
                        if (nbill != null)
                        {
                            var intNum = Convert.ToInt32(nbill) + 1;
                            numStr = intNum.ToString();
                        }
                    }

                    while (numStr.Length < 9)
                    {
                        numStr = "0" + numStr;
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return numStr;
        }
Example #7
0
 public BILL_Product GetProductByID(long id)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         return context.BILL_Product.Include("BILL_Vat").Include("BILL_Category").SingleOrDefault(p => p.Product_Id == id);
     }
 }
Example #8
0
 public List<BILL_Transmitter> GetBillTrans()
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         return context.BILL_Transmitter.ToList();
     }
 }
Example #9
0
        public Role CreateRole(Role roleToAdd)
        {
            if (roleToAdd == null)
                return null;

            using (SUPERPEntities context = new SUPERPEntities(false))
            {
                var r = context.Roles.Add(new Role()
                    {
                        Label = roleToAdd.Label,
                        Users = new List<User>(),
                        RoleModules = new List<RoleModule>()
                    });
                context.SaveChanges();

                foreach(RoleModule rm in roleToAdd.RoleModules)
                {
                    context.RoleModules.Add(new RoleModule() {
                        Role_id = r.Id,
                        Module_id = rm.Module_id
                    });
                }

                context.SaveChanges();
                return r;
            }
        }
Example #10
0
 public List<BILL_Product> GetBillProduct()
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         return context.BILL_Product.Include("BILL_Vat").Include("BILL_Category").ToList();
     }
 }
Example #11
0
 public List<BILL_Status> GetStatusChain(long status_id)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         var res = context.BILL_StatusChain.Include("BILL_Status").Include("BILL_Status1").Where(s => s.Status_Id == status_id).Select(s => s.BILL_Status1).ToList();
         return res;
     }
 }
Example #12
0
 public COMPTA_ClassOfAccounts CreateAccountingClass(COMPTA_ClassOfAccounts accountingClassToAdd)
 {
     using(SUPERPEntities context = new SUPERPEntities(false))
     {
         var accountingClass = context.COMPTA_ClassOfAccounts.Add(accountingClassToAdd);
         context.SaveChanges();
         return accountingClass;
     }
 }
Example #13
0
 public COMPTA_ChartOfAccounts CreateAccountingAccount(COMPTA_ChartOfAccounts accountingAccountToAdd)
 {
     using(SUPERPEntities context = new SUPERPEntities(false))
     {
         var accountingAccount = context.COMPTA_ChartOfAccounts.Add(accountingAccountToAdd);
         context.SaveChanges();
         return accountingAccount;
     }
 }
Example #14
0
 public List<Company_Contact> GetListCompanyContact()
 {
     List<Company_Contact> lcontact;
     using (SUPERPEntities sup = new SUPERPEntities(false))
     {
         lcontact = sup.Company_Contact.ToList(); ;
     }
     return lcontact;
 }
Example #15
0
 public COMPTA_BankAccount CreateBankAccount(COMPTA_BankAccount bankAccountToAdd)
 {
     using(SUPERPEntities context = new SUPERPEntities(false))
     {
         var bankAccount = context.COMPTA_BankAccount.Add(bankAccountToAdd);
         context.SaveChanges();
         return bankAccount;
     }
 }
Example #16
0
 public IEnumerable<BILL_Product> productsIncludedInBill(long billquotation_id)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         return context.BILL_LineBillQuotation.Include("BILL_Product").Include("BILL_Product.BILL_Vat")
                 .Include("BILL_Product.BILL_Category")
             .Where(line => line.BillQuotation_Id == billquotation_id).Select(l => l.BILL_Product);
     }
 }
Example #17
0
 public IEnumerable<BILL_LineBillQuotation> GetLineBillQuotation(long billQuotation_id)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         return context.BILL_LineBillQuotation.Include("BILL_Product").Include("BILL_Product.BILL_Vat")
                 .Include("BILL_Product.BILL_Category")
             .Where(line => line.BillQuotation_Id == billQuotation_id).ToList();
     }
 }
Example #18
0
 public BILL_BillQuotation CreateBillQutotation(BILL_BillQuotation billQuotationToAdd)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         var b = context.BILL_BillQuotation.Add(billQuotationToAdd);
         context.SaveChanges();
         return b;
     }
 }
Example #19
0
 public COMPTA_AccountingEntries CreateAccountingEntry(COMPTA_AccountingEntries accountingEntryToAdd)
 {
     using(SUPERPEntities context = new SUPERPEntities(false))
     {
         var accountingEntry = context.COMPTA_AccountingEntries.Add(accountingEntryToAdd);
         context.SaveChanges();
         return accountingEntry;
     }
 }
Example #20
0
 public COMPTA_Bank CreateBank(COMPTA_Bank bankToAdd)
 {
     using(SUPERPEntities context = new SUPERPEntities(false))
     {
         var bank = context.COMPTA_Bank.Add(bankToAdd);
         context.SaveChanges();
         return bank;
     }
 }
Example #21
0
 public COMPTA_Currency CreateCurrency(COMPTA_Currency currencyToAdd)
 {
     using(SUPERPEntities context = new SUPERPEntities(false))
     {
         var currency = context.COMPTA_Currency.Add(currencyToAdd);
         context.SaveChanges();
         return currency;
     }
 }
Example #22
0
 public COMPTA_BankJournalLine CreateBankJournalLine(COMPTA_BankJournalLine bankJournalLineToAdd)
 {
     using(SUPERPEntities context = new SUPERPEntities(false))
     {
         var bankJournalLine = context.COMPTA_BankJournalLine.Add(bankJournalLineToAdd);
         context.SaveChanges();
         return bankJournalLine;
     }
 }
Example #23
0
 public List<Company_Contact> GetListCompanyContact(int idCompany)
 {
     List<Company_Contact> lcontact;
     using (SUPERPEntities sup = new SUPERPEntities(false))
     {
         lcontact = sup.Company_Contact.Where(o => o.company_id == idCompany).ToList(); ;
     }
     return lcontact;
 }
Example #24
0
 public BILL_Product CreateBillProduct(BILL_Product billProductToAdd)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         var p = context.BILL_Product.Add(billProductToAdd);
         context.SaveChanges();
         return p;
     }
 }
Example #25
0
 public List<Company> GetListCompany()
 {
     List<Company> com1 = new List<Company>();
      using (SUPERPEntities sup = new SUPERPEntities(false))
     {
         com1 = sup.Companies.ToList();
     }
     return com1;
 }
Example #26
0
 public Company GetCompany(int idCompany)
 {
     Company com = new Company();
     using (SUPERPEntities sup = new SUPERPEntities(false))
     {
         com = sup.Companies.Where(o => o.id == idCompany).FirstOrDefault();
     }
     return com;
 }
Example #27
0
 public Company_Contact GetCompany_Contact(int idContact)
 {
     Company_Contact contact;
     using (SUPERPEntities sup = new SUPERPEntities(false))
     {
         contact = sup.Company_Contact.Where(o => o.id == idContact).FirstOrDefault(); ;
     }
     return contact;
 }
Example #28
0
 public bool DeleteCompany(int id)
 {
     using (SUPERPEntities sup = new SUPERPEntities(false))
     {
         Company contact = sup.Companies.Where(p => p.id == id).FirstOrDefault();
         sup.Entry(contact).State = System.Data.Entity.EntityState.Deleted;
         sup.SaveChanges();
     }
     return true;
 }
Example #29
0
 public BILL_Product EditBillProduct(BILL_Product billProductToEdit)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         var p = context.BILL_Product.Find(billProductToEdit.Product_Id);
         p = billProductToEdit;
         context.SaveChanges();
         return p;
     }
 }
Example #30
0
        public int CreateCompany(Company compa)
        {
            using (SUPERPEntities sup = new SUPERPEntities(false))
            {
                sup.Companies.Add(compa);
                sup.SaveChanges();

                Company cont = sup.Companies.OrderByDescending(p => p.id).First();
                return (int)cont.id;
            }
        }