public static void SetSystemSettingDateTime(ModelTMSContainer Context, string PropertyName, DateTime PropertyValue, string PropertyDescription) { SystemSettingSet.SetSystemSettingValue(Context, PropertyName, PropertyValue.ToString(Common.constDateTimeFormatString), PropertyDescription); }
private void CreateAndCheckDatabase() { // check if the database is there TMSService.CheckDatabase(Session); // check if the database fillings are correct // check if all required objects are present (the database cannot be accessed and is therefore already upgraded) ModelTMSContainer TempContext = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session); // locations Location location = null; LedgerBookingCode TempLedgerBookingCode = null; // ledgerbookingcodes not present? Then init the database ... if (TempContext.LedgerBookingCodeSet.Count() == 0) { TempLedgerBookingCode = new LedgerBookingCode(); //LedgerBookingCode DebugCode = new LedgerBookingCode(); TempContext.AddToLedgerBookingCodeSet(TempLedgerBookingCode); //TempContext.AddToLedgerBookingCodeSet(DebugCode); TempLedgerBookingCode.Description = ClassTranslate.TranslateString("DBDefaults", "StandardBookingCode", "Standard booking code"); TempLedgerBookingCode.IsActive = true; TempLedgerBookingCode.IsDebugLedgerCode = false; TempLedgerBookingCode.LedgerCurrency = "Eur"; // debug code //DebugCode.Description = ClassTranslate.TranslateString("DBDefaults","StandardBookingDebugCode", "Standard book debugging code"); //DebugCode.IsActive = true; //DebugCode.IsDebugLedgerCode = true; TempContext.SaveChanges(); // location location = new Location(); TempContext.AddToLocationSet(location); location.Description = "Standard location"; location.DefaultWeighingTariffBookingCode = TempLedgerBookingCode; location.DefaultBailPriceBookingCode = TempLedgerBookingCode; TempContext.SaveChanges(); // ledgers (bank and cash MUST be present) Ledger BankLedger = new Ledger(); Ledger CashLedger = new Ledger(); //Ledger DebugLedger = new Ledger(); //TempContext.AddToLedgerSet(DebugLedger); TempContext.AddToLedgerSet(BankLedger); TempContext.AddToLedgerSet(CashLedger); BankLedger.Description = ClassTranslate.TranslateString("DBDefaults", "BankCode", "Bank"); BankLedger.Comments = ClassTranslate.TranslateString("DBDefaults", "BankCodeComment", "Automatisch aangemaakt. Vul aub de gegevens van uw bankrekening hier in."); BankLedger.LedgerCurrency = "Eur"; BankLedger.LedgerLevel = 0; BankLedger.LedgerType = "Bank"; BankLedger.IsActive = true; BankLedger.LimitToLocation = location; CashLedger.Description = ClassTranslate.TranslateString("DBDefaults", "CashCode", "Kas"); CashLedger.Comments = ClassTranslate.TranslateString("DBDefaults", "CashCodeComment", "Automatisch aangemaakt. Vul hier aub de gegevens van uw kas register in."); CashLedger.LedgerCurrency = "Eur"; CashLedger.LedgerLevel = 0; CashLedger.LedgerType = "Cash"; CashLedger.IsActive = true; CashLedger.LimitToLocation = location; /* * DebugLedger.Description = ClassTranslate.TranslateString("DBDefaults","DebugCode","Debug"); * DebugLedger.Comments = ClassTranslate.TranslateString("DBDefaults","DebugCodeComment","Auto created. Please fill in all details of your Cash account. This is the system debugging ledger for testing purposes only. Please do not use for business purposes."); * DebugLedger.LedgerCurrency = "Eur"; * DebugLedger.LedgerLevel = 0; * DebugLedger.LedgerType = "Bank"; * DebugLedger.IsActive = true; * DebugLedger.LimitToLocation = null; * DebugLedger.IsDebugLedger = true; */ location.BankLedger = BankLedger; location.CashLedger = CashLedger; TempContext.SaveChanges(); // standard material units MaterialUnit KGUnit = new MaterialUnit(); TempContext.AddToMaterialUnitSet(KGUnit); KGUnit.Description = "KG"; KGUnit.IsActive = true; KGUnit.StockKgMultiplier = 1; KGUnit.StockUnit = "KG"; TempContext.SaveChanges(); //KGUnit = new MaterialUnit(); //TempContext.AddToMaterialUnitSet(KGUnit); //KGUnit.Description = "N/A"; //KGUnit.IsActive = true; //KGUnit.StockKgMultiplier = 1; //KGUnit.StockUnit = "N/A"; //TempContext.SaveChanges(); // standard material // material Material TempMat = new Material(); // man hours Material TempHours = new Material(); // dirt / excess material Material TempDirt = new Material(); TempContext.AddToMaterialSet(TempMat); TempContext.AddToMaterialSet(TempHours); TempContext.AddToMaterialSet(TempDirt); LedgerBookingCode MatBookingCode = TempContext.LedgerBookingCodeSet.First(); TempMat.Description = ClassTranslate.TranslateString("DBDefaults", "StandardMaterial", "Standaard materiaal"); TempMat.MaterialUnit = TempContext.MaterialUnitSet.First(); TempMat.Location = TempContext.LocationSet.First(); TempMat.PurchaseLedgerBookingCode = MatBookingCode; TempMat.SalesLedgerBookingCode = MatBookingCode; TempMat.Category = "Other"; TempMat.VATPercentage = 21; TempHours.Description = ClassTranslate.TranslateString("DBDefaults", "ManHours", "Man uren"); TempHours.IsWorkInsteadOfMaterial = true; TempHours.MaterialUnit = TempContext.MaterialUnitSet.First(); TempHours.PurchaseLedgerBookingCode = MatBookingCode; TempHours.SalesLedgerBookingCode = MatBookingCode; TempHours.Location = TempContext.LocationSet.First(); TempHours.Category = "Other"; TempHours.VATPercentage = 21; TempDirt.Description = ClassTranslate.TranslateString("DBDefaults", "Dirt", "Vuil"); TempDirt.StockMayBeNegative = true; TempDirt.MaterialUnit = TempContext.MaterialUnitSet.First(); TempDirt.PurchaseLedgerBookingCode = MatBookingCode; TempDirt.SalesLedgerBookingCode = MatBookingCode; TempDirt.Location = TempContext.LocationSet.First(); TempDirt.VATPercentage = 21; TempDirt.Category = "Other"; // settings : standard dirt material, standard work material SystemSettingSet.SetSystemSettingValue(TempContext, "Standard.Material.Dirt", TempDirt.Id.ToString(), ClassTranslate.TranslateString("DBDefaults", "StandardMaterialForDirt", "Standaard materiaal voor vuil.")); SystemSettingSet.SetSystemSettingValue(TempContext, "Standard.Material.Labour", TempHours.Id.ToString(), ClassTranslate.TranslateString("DBDefaults", "StandardMaterialForLabour", "Standaard materiaal voor uren.")); // VAT percentages /* * MaterialVAT TempVAT = new MaterialVAT(); * TempContext.AddToMaterialVATSet(TempVAT); * TempVAT.Description = "19%"; * TempVAT.VATPercentage = 19; * TempVAT.Material = TempMat; * TempVAT.Location = TempContext.LocationSet.First(); * * TempVAT = new MaterialVAT(); * TempContext.AddToMaterialVATSet(TempVAT); * TempVAT.Description = "19%"; * TempVAT.VATPercentage = 19; * TempVAT.Material = TempHours; * TempVAT.Location = TempContext.LocationSet.First(); * * TempVAT = new MaterialVAT(); * TempContext.AddToMaterialVATSet(TempVAT); * TempVAT.Description = "19%"; * TempVAT.VATPercentage = 19; * TempVAT.Material = TempDirt; * TempVAT.Location = TempContext.LocationSet.First(); * * TempContext.SaveChanges(); */ // standard rental type equipment RentalType TempRental = new RentalType(); RentalTypeVAT TempRentalVAT = new RentalTypeVAT(); TempContext.AddToRentalTypeSet(TempRental); TempContext.AddToRentalTypeVATSet(TempRentalVAT); TempRental.Description = ClassTranslate.TranslateString("DBDefaults", "AnyRental", "Elke verhuur"); TempRental.LedgerBookingCode = TempContext.LedgerBookingCodeSet.First(); TempRentalVAT.VATPercentage = 21; TempRentalVAT.Description = "21%"; TempRentalVAT.RentalType = TempRental; TempRentalVAT.Location = TempContext.LocationSet.First(); TempContext.SaveChanges(); // standard truck Truck TempTruck = new Truck(); TempContext.AddToTruckSet(TempTruck); TempTruck.Description = ClassTranslate.TranslateString("DBDefaults", "Any truck", "Een vrachtwagen"); TempTruck.CurrentTruckLocation = TempContext.LocationSet.First(); TempTruck.HomeTruckLocation = TempContext.LocationSet.First(); TempContext.SaveChanges(); // standard security role SecurityRole SecRole = new SecurityRole(); TempContext.AddToSecurityRoleSet(SecRole); SecRole.Description = ClassTranslate.TranslateString("DBDefaults", "UnlimitedAccess", "Onbeperkte toegang"); SecRole.HasUnlimitedAccess = true; TempContext.SaveChanges(); // standard relations (general purchase, stock correction and general sales account) Relation Sales = new Relation(); Relation Purchase = new Relation(); Relation StockCorrection = new Relation(); TempContext.AddToRelationSet(Sales); TempContext.AddToRelationSet(Purchase); TempContext.AddToRelationSet(StockCorrection); Sales.Description = ClassTranslate.TranslateString("DBDefaults", "DirectSales", "Directe verkoop"); Sales.CustomerType = "Debtor"; Sales.IsSystemUser = true; Sales.PreferredLocation = location; Purchase.Description = ClassTranslate.TranslateString("DBDefaults", "DirectPurchase", "Directe inkoop"); Purchase.CustomerType = "Creditor"; Purchase.IsSystemUser = true; Purchase.PreferredLocation = location; StockCorrection.Description = ClassTranslate.TranslateString("DBDefaults", "StockCorrection", "Voorraad correctie"); StockCorrection.CustomerType = "Both"; StockCorrection.IsSystemUser = true; StockCorrection.PreferredLocation = location; // settings: standard sales, standard purchase, standard stock correction customer SystemSettingSet.SetSystemSettingValue(TempContext, "Standard.Relation.Purchase", Purchase.Id.ToString(), ClassTranslate.TranslateString("DBDefaults", "StandardPurchaseRelationUnnamed", "Standard relatie voor onbekende inkopers.")); SystemSettingSet.SetSystemSettingValue(TempContext, "Standard.Relation.Sales", Sales.Id.ToString(), ClassTranslate.TranslateString("DBDefaults", "StandardSalesRelationUnnamed", "Standard relatie voor onbekende kopers.")); SystemSettingSet.SetSystemSettingValue(TempContext, "Standard.Relation.StockCorrection", StockCorrection.Id.ToString(), ClassTranslate.TranslateString("DBDefaults", "StandardStockCorrectionRelation", "Standard relatie voor voorraad correcties.")); TempContext.SaveChanges(); } // standard user if there are none if (TempContext.StaffMemberSet.Count() == 0) { StaffMember TempMem = new StaffMember(); TempContext.AddToStaffMemberSet(TempMem); TempMem.Description = ClassTranslate.TranslateString("DBDefaults", "DefaultUser", "Standaard aanwezig gebruiker"); TempMem.HasVMSAccount = true; TempMem.AccountName = "Admin"; TempMem.Password = "******"; TempMem.HomeLocation = TempContext.LocationSet.First(); TempMem.SecurityRole.Add(TempContext.SecurityRoleSet.First()); TempContext.SaveChanges(); } }