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; } }
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; }
public BILL_BillQuotation CreateBillQutotation(BILL_BillQuotation billQuotationToAdd) { using (SUPERPEntities context = new SUPERPEntities(false)) { var b = context.BILL_BillQuotation.Add(billQuotationToAdd); context.SaveChanges(); return b; } }
public COMPTA_ChartOfAccounts CreateAccountingAccount(COMPTA_ChartOfAccounts accountingAccountToAdd) { using(SUPERPEntities context = new SUPERPEntities(false)) { var accountingAccount = context.COMPTA_ChartOfAccounts.Add(accountingAccountToAdd); context.SaveChanges(); return accountingAccount; } }
public COMPTA_BankAccount CreateBankAccount(COMPTA_BankAccount bankAccountToAdd) { using(SUPERPEntities context = new SUPERPEntities(false)) { var bankAccount = context.COMPTA_BankAccount.Add(bankAccountToAdd); context.SaveChanges(); return bankAccount; } }
public COMPTA_Bank CreateBank(COMPTA_Bank bankToAdd) { using(SUPERPEntities context = new SUPERPEntities(false)) { var bank = context.COMPTA_Bank.Add(bankToAdd); context.SaveChanges(); return bank; } }
public COMPTA_BankJournalLine CreateBankJournalLine(COMPTA_BankJournalLine bankJournalLineToAdd) { using(SUPERPEntities context = new SUPERPEntities(false)) { var bankJournalLine = context.COMPTA_BankJournalLine.Add(bankJournalLineToAdd); context.SaveChanges(); return bankJournalLine; } }
public COMPTA_Currency CreateCurrency(COMPTA_Currency currencyToAdd) { using(SUPERPEntities context = new SUPERPEntities(false)) { var currency = context.COMPTA_Currency.Add(currencyToAdd); context.SaveChanges(); return currency; } }
public BILL_Product CreateBillProduct(BILL_Product billProductToAdd) { using (SUPERPEntities context = new SUPERPEntities(false)) { var p = context.BILL_Product.Add(billProductToAdd); context.SaveChanges(); return p; } }
public COMPTA_ClassOfAccounts CreateAccountingClass(COMPTA_ClassOfAccounts accountingClassToAdd) { using(SUPERPEntities context = new SUPERPEntities(false)) { var accountingClass = context.COMPTA_ClassOfAccounts.Add(accountingClassToAdd); context.SaveChanges(); return accountingClass; } }
public COMPTA_AccountingEntries CreateAccountingEntry(COMPTA_AccountingEntries accountingEntryToAdd) { using(SUPERPEntities context = new SUPERPEntities(false)) { var accountingEntry = context.COMPTA_AccountingEntries.Add(accountingEntryToAdd); context.SaveChanges(); return accountingEntry; } }
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; } }
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; }
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; } }
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; } }
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; } }
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; }
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; } }
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; } } }
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; } }
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; } } }
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; } } }
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; } } }
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; } } }
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; } } }
public COMPTA_ExchangeRate CreateExchangeRate(COMPTA_ExchangeRate exchangeRateToAdd) { using(SUPERPEntities context = new SUPERPEntities(false)) { var exchangeRate = context.COMPTA_ExchangeRate.Add(exchangeRateToAdd); context.SaveChanges(); return exchangeRate; } }
public COMPTA_CustomerJournalLine CreateCustomerJournalLine(COMPTA_CustomerJournalLine customerJournalLineToAdd) { using(SUPERPEntities context = new SUPERPEntities(false)) { var customerJournalLine = context.COMPTA_CustomerJournalLine.Add(customerJournalLineToAdd); context.SaveChanges(); return customerJournalLine; } }
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; } }
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; } }
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; } }