Beispiel #1
0
 private Acc_BudgetsDtl BuildDBRecordForDetails(Acc_BudgetsDtl _Acc_BudgetsDtl, Budget _Budget, Acc_Budgets _Acc_Budgets)
 {
     _Acc_BudgetsDtl.BudgetDtlId = _Budget.BudgetDtlId;
     _Acc_BudgetsDtl.BudgetId = _Acc_Budgets.BudgetId;
     _Acc_BudgetsDtl.BudgetYearId = _Acc_Budgets.BudgetYearId;
     _Acc_BudgetsDtl.BudgetYear = _Budget.BudgetYear;
     _Acc_BudgetsDtl.BudgetAccountId = _Budget.BudgetAccountId;
     _Acc_BudgetsDtl.BudgetCostCenterId = _Budget.BudgetCostCenterId;
     _Acc_BudgetsDtl.BudgetLocationId = _Budget.BudgetLocationId;
     _Acc_BudgetsDtl.BdgtDepitAmount = _Budget.BdgtDepitAmount;
     _Acc_BudgetsDtl.BdgtCreditAmount = _Budget.BdgtCreditAmount;
     _Acc_BudgetsDtl.BdgttBalance = _Budget.BdgttBalance;
     _Acc_BudgetsDtl.BdgtFrom = _Budget.BdgtFrom;
     _Acc_BudgetsDtl.BdgtTo = _Budget.BdgtTo;
     return _Acc_BudgetsDtl;
 }
Beispiel #2
0
        public DataSaveResult Save(Budget _Budget)
        {
            try
            {
                Acc_Budgets Acc_Budgets;
                NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);

                Acc_Budgets = newAppsCnn.Acc_Budgets.Where(a => a.BudgetId == _Budget.BudgetId && a.BudgetYearId == _Budget.BudgetYearId).FirstOrDefault();
                if (Acc_Budgets != null)
                {
                    BuildDBRecord(Acc_Budgets, _Budget);
                }

                else
                {

                    Acc_Budgets = new Acc_Budgets();
                    Acc_Budgets = BuildDBRecord(Acc_Budgets, _Budget);
                    newAppsCnn.Acc_Budgets.Add(Acc_Budgets);
                }
                newAppsCnn.SaveChanges();

                var BudgetDetails = newAppsCnn.Acc_BudgetsDtl.Where(a => a.BudgetDtlId == _Budget.BudgetDtlId && a.BudgetId == _Budget.BudgetId && a.BudgetYearId == _Budget.BudgetYearId).ToList();
                if (BudgetDetails.Count !=0)
                {
                    foreach (Acc_BudgetsDtl _Acc_BudgetsDtl in BudgetDetails)
                    {

                        foreach (Budget bdgt in _Budget.BudgetDetails)
                        {
                            if (_Acc_BudgetsDtl.BudgetDtlId == bdgt.BudgetDtlId)
                            {
                                BuildDBRecordForDetails(_Acc_BudgetsDtl, bdgt,Acc_Budgets);
                                newAppsCnn.SaveChanges();
                            }
                        }
                    }
                }
                else
                {
                    foreach (Budget bdgt in _Budget.BudgetDetails)
                    {
                        Acc_BudgetsDtl _Acc_BudgetsDtl = new Acc_BudgetsDtl();
                        _Acc_BudgetsDtl = BuildDBRecordForDetails(_Acc_BudgetsDtl, bdgt, Acc_Budgets);
                        newAppsCnn.Acc_BudgetsDtl.Add(_Acc_BudgetsDtl);
                        newAppsCnn.SaveChanges();
                    }

                }

                //   Audit.AddDataAudit(Audit.AuditActionTypes.AddNew, "Acc_VouchersType", this);

                return new DataSaveResult() { SaveStatus = true };
            }
            catch (Exception ex)
            {
                return new DataSaveResult() { SaveStatus = false };
            }
        }