Esempio n. 1
0
        public static DateTime GetSystemSettingDateTime(ModelTMSContainer Context, string PropertyName, DateTime DefaultValue)
        {
            DateTime retVal = DefaultValue;
            string   DefVal = DefaultValue.ToString(Common.constDateTimeFormatString);

            string ToParse = SystemSettingSet.GetSystemSettingValue(Context, PropertyName, DefVal);

            retVal = DateTime.ParseExact(ToParse, Common.constDateTimeFormatString, CultureInfo.InvariantCulture);
            return(retVal);
        }
Esempio n. 2
0
        public static void CheckMaterialClosures(ModelTMSContainer Context, System.Web.UI.Page PageX)
        // Note : in contrast to regular application architecture this method uses its own transactions !!!
        {
            bool     Success             = true;
            DateTime LastClosureDateTime = SystemSettingSet.GetLastMaterialClosureDateTime(Context);

            // start the closure process until we are at today
            while ((LastClosureDateTime < DateTime.Today.AddDays(-1)) && (Success))
            {
                // start transaction
                using (TransactionScope TS = new TransactionScope())
                {
                    try
                    {
                        foreach (Material mat in Context.MaterialSet.Where <Material>(m => m.IsActive))
                        {
                            //if ((mat.IsActive) && (mat.GetMaterialStockPosition(Context) == mat))
                            if (mat.IsActive)
                            {
                                MaterialClosure mc = new MaterialClosure();

                                mc.Material        = mat;
                                mc.Description     = mat.Description;
                                mc.ClosureDateTime = LastClosureDateTime;
                                mc.RecalcTotals(Context);

                                Context.AddToMaterialClosureSet(mc);
                            }
                        }     //foreach

                        // next closure date please
                        LastClosureDateTime = LastClosureDateTime.AddDays(1);
                        SystemSettingSet.SetLastMaterialClosureDateTime(Context, LastClosureDateTime);

                        // commit the transaciton
                        Context.SaveChanges();
                        TS.Complete();
                    }
                    catch (Exception ex)     // commit or procedure failed somewhere
                    {
                        // rollback transaction
                        TS.Dispose();

                        // inform user
                        Common.InformUserOnTransactionFail(ex, PageX);

                        Success = false;
                    }
                }     //using
            } // while
        }
Esempio n. 3
0
        public static void CheckLedgerBookingCodeClosures(ModelTMSContainer Context, System.Web.UI.Page PageX)
        // Note : in contrast to regular application architecture this method uses its own transactions !!!
        {
            bool     Success             = true;
            DateTime LastClosureDateTime = SystemSettingSet.GetLastLedgerClosureDateTime(Context, "LedgerBookingCode");

            // start the closure process until we are at today
            while ((LastClosureDateTime < DateTime.Today.AddDays(-1)) && (Success))
            {
                // start transaction
                using (TransactionScope TS = new TransactionScope())
                {
                    try
                    {
                        foreach (LedgerBookingCode led in Context.LedgerBookingCodeSet.Where <LedgerBookingCode>(m => m.IsActive))
                        {
                            LedgerClosure lc = new LedgerClosure();
                            lc.ClosureDate       = LastClosureDateTime;
                            lc.LedgerBookingCode = led;
                            lc.Description       = "Sluitstand " + led.Description;

                            lc.RecalcTotals(Context, true, true);
                        }

                        // next closure date please
                        LastClosureDateTime = LastClosureDateTime.AddDays(1);
                        SystemSettingSet.SetLastLedgerClosureDateTime(Context, LastClosureDateTime, "LedgerBookingCode");

                        // commit the transaciton
                        Context.SaveChanges();
                        TS.Complete();
                    }
                    catch (Exception ex) // commit or procedure failed somewhere
                    {
                        // rollback transaction
                        TS.Dispose();

                        // inform user
                        Common.InformUserOnTransactionFail(ex, PageX);

                        Success = false;
                    }
                } //using
            }     // while
        }
Esempio n. 4
0
 public static void SetLastLedgerClosureDateTime(ModelTMSContainer Context, DateTime LastClosure, string LedgerDescription)
 {
     LastClosure = new DateTime(LastClosure.Year, LastClosure.Month, LastClosure.Day, 23, 59, 59);
     SystemSettingSet.SetSystemSettingDateTime(Context, "Last" + LedgerDescription + "ClosureDateTime", LastClosure, "The last closure date for the ledger.");
 }
Esempio n. 5
0
 public static void SetLastMaterialClosureDateTime(ModelTMSContainer Context, DateTime LastClosure)
 {
     LastClosure = new DateTime(LastClosure.Year, LastClosure.Month, LastClosure.Day, 23, 59, 59);
     SystemSettingSet.SetSystemSettingDateTime(Context, "LastMaterialClosureDateTime", LastClosure, "The last closure date for the Materials (stock).");
 }
Esempio n. 6
0
 public static void SetSystemSettingDateTime(ModelTMSContainer Context, string PropertyName, DateTime PropertyValue, string PropertyDescription)
 {
     SystemSettingSet.SetSystemSettingValue(Context, PropertyName, PropertyValue.ToString(Common.constDateTimeFormatString), PropertyDescription);
 }
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            // save the role memberships into the staffmember
            StaffMember sm = (DataItem as StaffMember);

            sm.SecurityRole.Load();
            if (sm != null)
            {
                foreach (SecurityRole sr in sm.SecurityRole.ToArray <SecurityRole>())
                {
                    sm.SecurityRole.Remove(sr);
                }

                foreach (ListItem ListI in CheckBoxListRoleMemberships.Items)
                {
                    if (ListI.Selected)
                    {
                        SecurityRole sr = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.SecurityRoleSet", "Id", new Guid(ListI.Value))) as SecurityRole;
                        sm.SecurityRole.Add(sr);
                    }
                }
            }


            // check if the nr of staffmembers does not exceed the max amount of allowed staff members
            if ((CheckBox_HasVMSAccount_Checked.Checked) && (CheckBoxOldVMSAccount.Checked != CheckBox_HasVMSAccount_Checked.Checked) &&
                ((StaffMemberSet.AmountOfStaffMembersWithTMSLogin(ControlObjectContext) + 1) > SystemSettingSet.GetAmountOfUserLicenses(ControlObjectContext)))
            {
                Common.InformUser(Page, "Het maximale aantal TMS logins is opgebruikt. U kunt niet nog een TMS gebruiker toevoegen. Breidt uw licentie uit of ontneem de TMS licentie van een bestaande gebruiker.");
                CheckBox_HasVMSAccount_Checked.Checked = false;
            }

            StandardButtonSaveClickHandler(sender, e);
        }
Esempio n. 8
0
        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();
            }
        }