示例#1
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            dtStart = DateTime.Now;
            WriteLog("ABDC Start");

            try
            {
                WriteLog("Fetching Fund List");
                var lstFund = dbOld.ViewLedgerGroups.Select(x => x.Fund).Distinct().Where(x => !string.IsNullOrEmpty(x)).ToList();
                var lstUserTypeFormDetail = dbNew.UserTypeFormDetails.ToList();
                pbrFund.Maximum = lstFund.Count();
                pbrFund.Value   = 0;
                WriteLog("Creating Company from Fund List");
                foreach (var f in lstFund)
                {
                    pbrPayment.Value = 0;
                    pbrReceipt.Value = 0;
                    pbrJournal.Value = 0;

                    DALNewNUBE.FundMaster fm = new DALNewNUBE.FundMaster()
                    {
                        FundName = f, IsActive = true
                    };
                    DALNewNUBE.ACYearMaster acym = new DALNewNUBE.ACYearMaster()
                    {
                        ACYear = "2016 - 2017", ACYearStatusId = 1
                    };


                    fm.ACYearMasters.Add(acym);
                    dbNew.FundMasters.Add(fm);
                    dbNew.SaveChanges();

                    pbrFund.Value += 1;
                    DALNewNUBE.UserType ut = new DALNewNUBE.UserType()
                    {
                        TypeOfUser = DataKeyValueNUBE.Administrator_Key
                    };
                    fm.UserTypes.Add(ut);

                    foreach (var utfd in lstUserTypeFormDetail)
                    {
                        var ud = new DALNewNUBE.UserTypeDetail()
                        {
                            UserTypeFormDetailId = utfd.Id,
                            IsViewForm           = true,
                            AllowInsert          = true,
                            AllowUpdate          = true,
                            AllowDelete          = true
                        };
                        ut.UserTypeDetails.Add(ud);
                    }

                    DALNewNUBE.UserAccount ua = new DALNewNUBE.UserAccount()
                    {
                        LoginId = "Admin", UserName = "******", Password = "******"
                    };
                    ut.UserAccounts.Add(ua);
                    WriteLog(string.Format("Stored User Account : {0}, Id : {1}", ua.UserName, ua.Id));

                    DALNewNUBE.CustomFormat cf = new DALNewNUBE.CustomFormat()
                    {
                        CurrencyNegativeSymbolPrefix = "[RM] ",
                        CurrencyPositiveSymbolPrefix = "RM ",
                        CurrencyToWordPrefix         = "Ringgit Malaysia ",
                        DecimalToWordPrefix          = "Cents ",
                        DecimalSymbol             = ".",
                        DigitGroupingSymbol       = ",",
                        IsDisplayWithOnlyOnSuffix = true,
                        NoOfDigitAfterDecimal     = 2,
                        FundMasterId = fm.Id
                    };
                    dbNew.CustomFormats.Add(cf);
                    WriteAccountGroup(fm, 1, null, acym); dbNew.SaveChanges();

                    lstLedgerNew  = dbNew.Ledgers.Where(x => x.AccountGroup.FundMasterId == fm.Id).ToList();
                    lstPaymentNew = new List <DALNewNUBE.Payment>();
                    lstReceiptNew = new List <DALNewNUBE.Receipt>();
                    lstJournalNew = new List <DALNewNUBE.Journal>();

                    WritePayment(fm);
                    dbNew.Payments.AddRange(lstPaymentNew);
                    dbNew.SaveChanges();

                    WriteReceipt(fm);
                    dbNew.Receipts.AddRange(lstReceiptNew);
                    dbNew.SaveChanges();

                    WriteJournal(fm);
                    dbNew.Journals.AddRange(lstJournalNew);
                    dbNew.SaveChanges();

                    WriteDataKey(fm);
                    WriteLogData(fm);
                }
            }
            catch (Exception ex)
            {
                WriteLog(ex.Message);
            }

            WriteLog("ABDC End");
            MessageBox.Show("Finished");
        }
示例#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");
        }