public static void Write(String Key, int Value) { using (var db = new DALNewNUBE.nube_new_01Entities()) { var dv = new DALNewNUBE.DataKeyValue() { DataKey = Key, DataValue = Value, FundMasterId = CompanyId }; db.DataKeyValues.Add(dv); db.SaveChanges(); } }
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"); }