Exemplo n.º 1
0
        void WriteReceipt(DALNewNUBE.FundMaster cm)
        {
            WriteLog("Start to store the Receipt");
            try
            {
                var l1 = lstReceipt.Where(x => x.Fund == cm.FundName && x.ReceiptDate >= new DateTime(2016, 4, 1)).ToList();
                pbrReceipt.Maximum = l1.Count();
                pbrReceipt.Value   = 0;
                foreach (var r in l1)
                {
                    try
                    {
                        DALNewNUBE.Receipt rm = new DALNewNUBE.Receipt()
                        {
                            LedgerId     = GetLedgerId(r.Ledger.LedgerName),
                            Amount       = Convert.ToDecimal(r.ReceiptAmount),
                            ChequeDate   = r.ChequeDate,
                            ChequeNo     = r.ChequeNo,
                            CleareDate   = r.ClrDate,
                            VoucherNo    = r.VoucherNo,
                            EntryNo      = Receipt_NewRefNo(r.ReceiptDate.Value),
                            Extracharge  = Convert.ToDecimal(r.ExtraCharge),
                            Particulars  = r.Narration,
                            ReceiptDate  = r.ReceiptDate.Value,
                            ReceiptMode  = r.ReceiptMode,
                            ReceivedFrom = r.ReceivedFrom,
                            Status       = r.Status,
                            RefNo        = r.RefNo,
                            RefCode      = r.ReceiptId.ToString()
                        };

                        foreach (var rd in r.ReceiptDetails)
                        {
                            DALNewNUBE.ReceiptDetail pmd = new DALNewNUBE.ReceiptDetail()
                            {
                                LedgerId    = GetLedgerId(rd.Ledger.LedgerName),
                                Amount      = Convert.ToDecimal(rd.Amount),
                                Particulars = rd.Narration,
                            };
                            rm.ReceiptDetails.Add(pmd);
                        }

                        lstReceiptNew.Add(rm);
                        WriteLog(string.Format("Stored Receipt => Date : {0}, Entry No : {1}, Voucher No : {2}", rm.ReceiptDate, rm.EntryNo, rm.VoucherNo));
                        pbrReceipt.Value += 1;
                    }
                    catch (Exception ex)
                    {
                        WriteLog(string.Format("Error on Stored Receipt => Date : {0}, Entry No : {1}, Voucher No : {2}, Error : {3}", r.ReceiptDate, r.EntryNo, r.VoucherNo, ex.Message));
                    }
                }
            }
            catch (Exception ex)
            {
                WriteLog(string.Format("Error on Receipt: {0}", ex.Message));
            }

            WriteLog("End to Store the Receipt");
        }
Exemplo n.º 2
0
        void WriteLogData(DALNewNUBE.FundMaster fm)
        {
            var ua  = fm.UserTypes.FirstOrDefault().UserAccounts.FirstOrDefault();
            var ua1 = new DALNewNUBE.FundMaster()
            {
                Id = fm.Id, FundName = fm.FundName, IsActive = fm.IsActive
            };

            var cf  = fm.CustomFormats.FirstOrDefault();
            var cf1 = new DALNewNUBE.CustomFormat()
            {
                Id = cf.Id, CurrencyCaseSensitive = cf.CurrencyCaseSensitive, CurrencyNegativeSymbolPrefix = cf.CurrencyNegativeSymbolPrefix, CurrencyNegativeSymbolSuffix = cf.CurrencyNegativeSymbolSuffix, CurrencyPositiveSymbolPrefix = cf.CurrencyPositiveSymbolPrefix, CurrencyPositiveSymbolSuffix = cf.CurrencyPositiveSymbolSuffix, CurrencyToWordPrefix = cf.CurrencyToWordPrefix, CurrencyToWordSuffix = cf.CurrencyToWordSuffix, DecimalSymbol = cf.DecimalSymbol, DecimalToWordPrefix = cf.DecimalToWordPrefix, DecimalToWordSuffix = cf.DecimalToWordSuffix, DigitGroupingBy = cf.DigitGroupingBy, DigitGroupingSymbol = cf.DigitGroupingSymbol, FundMasterId = cf.FundMasterId, IsDisplayWithOnlyOnSuffix = cf.IsDisplayWithOnlyOnSuffix, NoOfDigitAfterDecimal = cf.NoOfDigitAfterDecimal
            };

            var ut  = fm.UserTypes.FirstOrDefault();
            var ut1 = new DALNewNUBE.UserType()
            {
                Id = ut.Id, FundMasterId = ut.FundMasterId, TypeOfUser = ut.TypeOfUser, Description = ut.Description
            };

            foreach (var utd in ut.UserTypeDetails)
            {
                ut1.UserTypeDetails.Add(new DALNewNUBE.UserTypeDetail()
                {
                    Id = utd.Id, UserTypeId = utd.UserTypeId, UserTypeFormDetailId = utd.UserTypeFormDetailId, IsViewForm = utd.IsViewForm, AllowInsert = utd.AllowInsert, AllowUpdate = utd.AllowUpdate, AllowDelete = utd.AllowDelete
                });
            }

            var acym  = fm.ACYearMasters.FirstOrDefault();
            var acym1 = new DALNewNUBE.ACYearMaster()
            {
                Id = acym.Id, ACYear = acym.ACYear, ACYearStatusId = acym.ACYearStatusId, FundMasterId = acym.FundMasterId
            };

            foreach (var acymlb in acym.ACYearLedgerBalances)
            {
                acym1.ACYearLedgerBalances.Add(new DALNewNUBE.ACYearLedgerBalance()
                {
                    Id = acymlb.Id, ACYearMasterId = acym.Id, LedgerId = acymlb.LedgerId, DrAmt = acymlb.DrAmt, CrAmt = acymlb.CrAmt
                });
            }

            var fm1 = new DALNewNUBE.FundMaster()
            {
                Id = fm.Id, FundName = fm.FundName, IsActive = fm.IsActive
            };

            LogDetailStore(fm1, ua.Id);
            LogDetailStore(cf1, ua.Id);
            LogDetailStore(ut1, ua.Id);
            LogDetailStore(ua1, ua.Id);
            var x1 = dbNew.SaveChanges();

            WriteLog("Log Data Finished of Master");
            LogDetailStore(acym1, ua.Id);
            var x2 = dbNew.SaveChanges();

            WriteLog("Log Data Finished of AccountYearMaster");
            foreach (var ag in fm.AccountGroups)
            {
                LogDetailStore(new DALNewNUBE.AccountGroup()
                {
                    Id = ag.Id, FundMasterId = fm.Id, GroupCode = ag.GroupCode, UnderGroupId = ag.UnderGroupId, GroupName = ag.GroupName
                }, ua.Id);
            }

            var x3 = dbNew.SaveChanges();

            WriteLog("Log Data Finished of AccountGroup");
            foreach (var ld in lstLedgerNew)
            {
                LogDetailStore(new DALNewNUBE.Ledger()
                {
                    Id = ld.Id, AccountGroupId = ld.AccountGroupId, LedgerCode = ld.LedgerCode, LedgerName = ld.LedgerName
                }, ua.Id);
            }
            var n0 = dbNew.SaveChanges();

            WriteLog("Log Data Finished of Ledger");
            int i = 0;

            foreach (var p in lstPaymentNew)
            {
                var p1 = new DALNewNUBE.Payment()
                {
                    Id = p.Id, Amount = p.Amount, ChequeDate = p.ChequeDate, ChequeNo = p.ChequeNo, ClearDate = p.ClearDate, EntryNo = p.EntryNo, ExtraCharge = p.ExtraCharge, LedgerId = p.LedgerId, Particulars = p.Particulars, PaymentDate = p.PaymentDate, PaymentMode = p.PaymentMode, PayTo = p.PayTo, RefCode = p.RefCode, RefNo = p.RefNo, Status = p.Status, VoucherNo = p.VoucherNo
                };
                foreach (var pd in p.PaymentDetails)
                {
                    p1.PaymentDetails.Add(new DALNewNUBE.PaymentDetail()
                    {
                        Id = pd.Id, Amount = pd.Amount, LedgerId = pd.LedgerId, Particular = pd.Particular, PaymentId = pd.PaymentId
                    });
                }

                LogDetailStore(p1, ua.Id);
                if (i++ % 1000 == 0)
                {
                    dbNew.SaveChanges();
                }
            }
            var n1 = dbNew.SaveChanges();

            WriteLog("Log Data Finished of Payment");
            foreach (var r in lstReceiptNew)
            {
                var r1 = new DALNewNUBE.Receipt()
                {
                    Id = r.Id, Amount = r.Amount, ChequeDate = r.ChequeDate, ChequeNo = r.ChequeNo, CleareDate = r.CleareDate, EntryNo = r.EntryNo, Extracharge = r.Extracharge, LedgerId = r.LedgerId, Particulars = r.Particulars, ReceiptDate = r.ReceiptDate, ReceiptMode = r.ReceiptMode, ReceivedFrom = r.ReceivedFrom, RefCode = r.RefCode, RefNo = r.RefNo, Status = r.Status, VoucherNo = r.VoucherNo
                };
                foreach (var rd in r.ReceiptDetails)
                {
                    r1.ReceiptDetails.Add(new DALNewNUBE.ReceiptDetail()
                    {
                        Id = rd.Id, Amount = rd.Amount, LedgerId = rd.LedgerId, Particulars = rd.Particulars, ReceiptId = rd.ReceiptId
                    });
                }
                LogDetailStore(r1, ua.Id);

                if (i++ % 1000 == 0)
                {
                    dbNew.SaveChanges();
                }
            }
            var n2 = dbNew.SaveChanges();

            WriteLog("Log Data Finished of Receipt");
            foreach (var j in lstJournalNew)
            {
                var j1 = new DALNewNUBE.Journal()
                {
                    Id = j.Id, Amount = j.Amount, EntryNo = j.EntryNo, HQNo = j.HQNo, JournalDate = j.JournalDate, Particular = j.Particular, RefCode = j.RefCode, Status = j.Status, VoucherNo = j.VoucherNo
                };
                foreach (var jd in j.JournalDetails)
                {
                    j1.JournalDetails.Add(new DALNewNUBE.JournalDetail()
                    {
                        Id = jd.Id, CrAmt = jd.CrAmt, DrAmt = jd.DrAmt, JournalId = jd.JournalId, LedgerId = jd.LedgerId, Particulars = jd.Particulars
                    });
                }
                LogDetailStore(j1, ua.Id);
                if (i++ % 1000 == 0)
                {
                    dbNew.SaveChanges();
                }
            }

            var n3 = dbNew.SaveChanges();

            WriteLog("Log Data Finished of Journal");
        }