Пример #1
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;
            }
        }
Пример #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;
        }
Пример #3
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;
     }
 }
Пример #4
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;
     }
 }
Пример #5
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;
     }
 }
Пример #6
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;
     }
 }
Пример #7
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;
     }
 }
Пример #8
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;
     }
 }
Пример #9
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;
     }
 }
Пример #10
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;
     }
 }
Пример #11
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;
     }
 }
Пример #12
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;
     }
 }
Пример #13
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;
 }
Пример #14
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;
            }
        }
Пример #15
0
        public User CreateUser(User userToAdd)
        {
            if (userToAdd == null)
                return null;

            using (SUPERPEntities context = new SUPERPEntities(false))
            {
                userToAdd.Passwordhash = Encrypt.hashSHA256(userToAdd.Passwordhash);
                var u = context.Users.Add(userToAdd);
                context.SaveChanges();
                return u;
            }
        }
Пример #16
0
 public List<BILL_LineBillQuotation> CreateLineBillQuotation(List<BILL_LineBillQuotation> billLineToAdd)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         var listLine = new List<BILL_LineBillQuotation>();
         foreach (var line in billLineToAdd)
         {
             var s = context.BILL_LineBillQuotation.Add(line);
             listLine.Add(line);
         }
         context.SaveChanges();
         return listLine;
     }
 }
Пример #17
0
        public bool EditCompany(Company company)
        {
            using (SUPERPEntities sup = new SUPERPEntities(false))
            {
                Company contactBdd = sup.Companies.Where(p => p.id == company.id).FirstOrDefault();
                if (contactBdd != null)
                {
                    sup.Entry(contactBdd).CurrentValues.SetValues(company);
                    sup.SaveChanges();
                }

            }
            return true;
        }
Пример #18
0
 public List<BILL_LineBillQuotation> EditLineBillQuotation(List<BILL_LineBillQuotation> LineBillQuotationToEdit)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         var listLine = new List<BILL_LineBillQuotation>();
         foreach (var line in LineBillQuotationToEdit)
         {
             var l = context.BILL_LineBillQuotation.Find(line.LineBillQuotation_Id);
             l = line;
             listLine.Add(l);
         }
         context.SaveChanges();
         return listLine;
     }
 }
Пример #19
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;
         }
     }
 }
Пример #20
0
 public BILL_BillQuotation EditBillQuotation(BILL_BillQuotation billQuotationToEdit)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         var b = context.BILL_BillQuotation.Find(billQuotationToEdit.BillQuotation_Id);
         if (b != null)
         {
             b.AmountDF = billQuotationToEdit.AmountDF;
             b.Company_Id = billQuotationToEdit.Company_Id;
             b.Transmitter_Id = billQuotationToEdit.Transmitter_Id;
             b.Vat = billQuotationToEdit.Vat;
             context.SaveChanges();
         }
         return b;
     }
 }
Пример #21
0
 public bool DeleteBillQuotation(long id)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         try
         {
             var b = context.BILL_BillQuotation.Find(id);
             context.BILL_BillQuotation.Remove(b);
             context.SaveChanges();
             return true;
         }
         catch (Exception)
         {
             return false;
         }
     }
 }
Пример #22
0
 public bool DeleteBillProduct(long billProduct_id)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         try
         {
             var p = context.BILL_Product.Find(billProduct_id);
             context.BILL_Product.Remove(p);
             context.SaveChanges();
             return true;
         }
         catch (Exception)
         {
             return false;
         }
     }
 }
Пример #23
0
 public bool DeleteRole(int roleId)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         try
         {
             context.Roles.Remove(context.Roles.Find(roleId));
             context.SaveChanges();
             return true;
         }
         catch (Exception e)
         {
             Debug.WriteLine("Echec de suppression des roles. Message : " + e.Message);
             return false;
         }
     }
 }
Пример #24
0
 public bool DeleteUser(int userId)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         try
         {
             context.Users.Remove(context.Users.Find(userId));
             context.SaveChanges();
             return true;
         }
         catch (Exception e )
         {
             Debug.WriteLine("Echec de suppression de l'utilisateur. Message : " + e.Message);
             return false;
         }
     }
 }
Пример #25
0
 public bool DeleteLineBillQuotation(List<long> listID)
 {
     using (SUPERPEntities context = new SUPERPEntities(false))
     {
         try
         {
             foreach (var id in listID)
             {
                 var l = context.BILL_LineBillQuotation.Find(id);
                 context.BILL_LineBillQuotation.Remove(l);
             }
             context.SaveChanges();
             return true;
         }
         catch (Exception)
         {
             return false;
         }
     }
 }
Пример #26
0
 public COMPTA_ExchangeRate CreateExchangeRate(COMPTA_ExchangeRate exchangeRateToAdd)
 {
     using(SUPERPEntities context = new SUPERPEntities(false))
     {
         var exchangeRate = context.COMPTA_ExchangeRate.Add(exchangeRateToAdd);
         context.SaveChanges();
         return exchangeRate;
     }
 }
Пример #27
0
 public COMPTA_CustomerJournalLine CreateCustomerJournalLine(COMPTA_CustomerJournalLine customerJournalLineToAdd)
 {
     using(SUPERPEntities context = new SUPERPEntities(false))
     {
         var customerJournalLine = context.COMPTA_CustomerJournalLine.Add(customerJournalLineToAdd);
         context.SaveChanges();
         return customerJournalLine;
     }
 }
Пример #28
0
        public COMPTA_CustomerJournalLine EditCustomerJournalLine(COMPTA_CustomerJournalLine customerJournalLineToEdit)
        {
            using(SUPERPEntities context = new SUPERPEntities(false))
            {
                var customerJournalLine = context.COMPTA_CustomerJournalLine.Find(customerJournalLineToEdit.id);

                if (customerJournalLine == null)
                    return null;

                customerJournalLine = customerJournalLineToEdit;
                context.SaveChanges();
                return customerJournalLine;
            }
        }
Пример #29
0
        public COMPTA_ExchangeRate EditExchangeRate(COMPTA_ExchangeRate exchangeRateToEdit)
        {
            using(SUPERPEntities context = new SUPERPEntities(false))
            {
                var exchangeRate = context.COMPTA_ExchangeRate.Find(exchangeRateToEdit.id);

                if (exchangeRate == null)
                    return null;

                exchangeRate = exchangeRateToEdit;
                context.SaveChanges();
                return exchangeRate;
            }
        }
Пример #30
0
        public COMPTA_SupplierJournalLine EditSupplierJournalLine(COMPTA_SupplierJournalLine supplierJournalLineToEdit)
        {
            using(SUPERPEntities context = new SUPERPEntities(false))
            {
                var supplierJournalLine = context.COMPTA_SupplierJournalLine.Find(supplierJournalLineToEdit.id);

                if (supplierJournalLine == null)
                    return null;

                supplierJournalLine = supplierJournalLineToEdit;
                context.SaveChanges();
                return supplierJournalLine;
            }
        }