public AccountGroup Save(AccountGroup cus) { var isExists = service.GetAll().Where(a => a.AccountGroupName == cus.AccountGroupName).FirstOrDefault(); var max = service.LastRow().OrderByDescending(a => a.Id).FirstOrDefault().Id; cus.Id = max + 1; if (isExists != null) { return(null); } service.Save(cus); return(cus); }
public PartyBalance Save(PartyBalance partyBalance) { var isExists = service.GetAll().Where(a => a.LedgerId == partyBalance.LedgerId).OrderByDescending(a => a.PartyBalanceId).FirstOrDefault(); var max = service.LastRow().OrderByDescending(a => a.PartyBalanceId).FirstOrDefault(); if (max == null) { partyBalance.PartyBalanceId = 1; } else { partyBalance.PartyBalanceId = max.PartyBalanceId + 1; } if (isExists != null) { if (partyBalance.Credit > 0) { var newbalance = isExists.Balance + partyBalance.Credit; partyBalance.Balance = newbalance; } if (partyBalance.Debit > 0) { var newbalance = isExists.Balance - partyBalance.Debit; partyBalance.Balance = newbalance; } } else { if (partyBalance.Credit > 0) { partyBalance.Balance = partyBalance.Credit; } if (partyBalance.Debit > 0) { partyBalance.Balance = (-1) * partyBalance.Debit; } } partyBalance.FinancialYearId = CurrentSession.GetCurrentSession().FinancialYear; partyBalance.IsLastYear = true; service.Save(partyBalance); //if (partyBalance != null) //{ // SqlParameter param = new SqlParameter("@LedgerId", partyBalance.LedgerId); // List<SqlParameter> paramss = new List<SqlParameter>(); // paramss.Add(param); // service.ExecuteProcedure("Exec BalanceReconcilation " + partyBalance.LedgerId + "",paramss,true); //} return(partyBalance); }
public Supplier Save(Supplier cus) { var max = service.LastRow().OrderByDescending(a => a.Id).FirstOrDefault(); if (max == null) { cus.Id = 1; } else { cus.Id = max.Id + 1; } return(service.Save(cus)); }
public JournalMaster Save(JournalMaster JMaster) { // var ledgerDetails = ledgerService.GetById(ledger.LedgerId); // var isExists = service.GetAll().Where(a => a.InvoiceNo == ledger.InvoiceNo && a.LedgerId == ledger.LedgerId).FirstOrDefault(); var max = journalMaster.LastRow().OrderByDescending(a => a.Id).FirstOrDefault(); if (max == null) { JMaster.Id = 1; } else { JMaster.Id = max.Id + 1; } var financialYear = CurrentSession.GetCurrentSession().FinancialYear; JMaster.YearId = CurrentSession.GetCurrentSession().FinancialYear; JMaster.VoucherTypeId = 6; JMaster.UserId = CurrentSession.GetCurrentSession().UserId; var result = journalMaster.Save(JMaster); return(result); }
public JournalDetail Save(JournalDetail JDetails) { var max = journalDetails.LastRow().OrderByDescending(a => a.Id).FirstOrDefault(); if (max == null) { JDetails.Id = 1; } else { JDetails.Id = max.Id + 1; } int value = int.Parse(journalMaster.LastRow().OrderByDescending(p => p.Id).Select(r => r.Id).First().ToString()); JDetails.JournalMasterId = value; var result = journalDetails.Save(JDetails); return(result); }
public SalaryPayment Save(SalaryPayment SP) { var max = service.LastRow().OrderByDescending(a => a.Id).FirstOrDefault(); SP.VoucherNo = max.VoucherNo; SP.LedgerId = max.LedgerId; var Max = salaryPayment.LastRow().OrderByDescending(a => a.Id).FirstOrDefault(); if (Max == null) { SP.Id = 1; } else { SP.Id = max.Id + 1; } var result = salaryPayment.Save(SP); return(result); }