protected void ButtonNew_Click(object sender, EventArgs e)
        {
            // first determine ledger & ledger booking code
            Ledger            TempLedger     = null;
            LedgerBookingCode TempLedgerCode = null;

            if (Request.Params["Id"] != null)
            {
                EntityKey TempKey = new EntityKey("ModelTMSContainer.LedgerSet", "Id", Guid.Parse(Request.Params["Id"]));
                TempLedger = ControlObjectContext.GetObjectByKey(TempKey) as Ledger;
            }
            else
            { // this must be linked to the ledgerbookingcodes ...
                EntityKey TempKey = new EntityKey("ModelTMSContainer.LedgerBookingCodeSet", "Id", Guid.Parse(Request.Params["LedgerBookingCodeId"]));
                TempLedgerCode = ControlObjectContext.GetObjectByKey(TempKey) as LedgerBookingCode;
            }

            // now create the ledger check
            LedgerCheck lc = new LedgerCheck();

            lc.Ledger            = TempLedger;
            lc.LedgerBookingCode = TempLedgerCode;
            lc.Description       = "Kascontrole " + lc.CheckDate.ToString();

            // and save
            ControlObjectContext.SaveChanges();


            // and show
            WebUserControlBookKeepingCheckBase1.KeyID   = lc.Id;
            WebUserControlBookKeepingCheckBase1.Visible = true;
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                CalendarControlStartDate.SelectedDate = Common.CurrentClientDate(Session).AddDays(-31);
                CalendarControlEndDate.SelectedDate   = Common.CurrentClientDate(Session);
                ButtonSearch_Click(null, null);

                // get the ledger description
                if (Request.Params["Id"] != null)
                {
                    EntityKey TempKey    = new EntityKey("ModelTMSContainer.LedgerSet", "Id", Guid.Parse(Request.Params["Id"]));
                    Ledger    TempLedger = ControlObjectContext.GetObjectByKey(TempKey) as Ledger;
                    LabelObjectName.Text = TempLedger.Description;

                    // check if we are actual with material closures
                    LedgerSet.CheckLedgerClosures(ControlObjectContext, Page);
                }
                else
                { // this must be linked to the ledgerbookingcodes ...
                    EntityKey         TempKey    = new EntityKey("ModelTMSContainer.LedgerBookingCodeSet", "Id", Guid.Parse(Request.Params["LedgerBookingCodeId"]));
                    LedgerBookingCode TempLedger = ControlObjectContext.GetObjectByKey(TempKey) as LedgerBookingCode;
                    LabelObjectName.Text = TempLedger.Description;

                    // check if we are actual with material closures
                    LedgerBookingCodeSet.CheckLedgerBookingCodeClosures(ControlObjectContext, Page);
                }
            }
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // get the ledger description
                if (Request.Params["Id"] != null)
                {
                    EntityKey TempKey    = new EntityKey("ModelTMSContainer.LedgerSet", "Id", Guid.Parse(Request.Params["Id"]));
                    Ledger    TempLedger = ControlObjectContext.GetObjectByKey(TempKey) as Ledger;
                    LabelLedgerName.Text = TempLedger.Description;
                }
                else
                { // this must be linked to the ledgerbookingcodes ...
                    EntityKey         TempKey    = new EntityKey("ModelTMSContainer.LedgerBookingCodeSet", "Id", Guid.Parse(Request.Params["LedgerBookingCodeId"]));
                    LedgerBookingCode TempLedger = ControlObjectContext.GetObjectByKey(TempKey) as LedgerBookingCode;
                    LabelLedgerName.Text = TempLedger.Description;
                }

                // set the correct filters
                CalendarControlStartDate.SelectedDate = new DateTime(Common.CurrentClientDate(Session).Year, 1, 1);
                CalendarControlEndDate.SelectedDate   = Common.CurrentClientDate(Session);

                DropDownListBookingType.Items.Clear();
                DropDownListBookingType.Items.Add(new ListItem("Alle", ""));
                Common.AddLedgerBookingTypeList(DropDownListBookingType.Items, false);
                DropDownListBookingType.SelectedValue = "";

                ButtonSearch_Click(sender, e);
            }
        }
Beispiel #4
0
 protected void Page_PreRender(object sender, EventArgs e)
 {
     if (DataItem != null)
     {
         LedgerBookingCode lbc = (DataItem as LedgerBookingCode);
         LabelName.Text = lbc.Description;
         LabelCurrentBookingCodeLevel.Text = lbc.LedgerLevel.ToString();
     }
 }
Beispiel #5
0
        protected void ButtonNew_Click(object sender, EventArgs e)
        {
            LedgerBookingCode NewMat = new LedgerBookingCode();
            ModelTMSContainer Temp   = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);

            NewMat.Description = "Boekingscode";

            Temp.AddToLedgerBookingCodeSet(NewMat);
            Temp.SaveChanges(SaveOptions.DetectChangesBeforeSave);

            WebUserControlBookingCodeBase1.KeyID   = NewMat.Id;
            WebUserControlBookingCodeBase1.Visible = true;
        }
Beispiel #6
0
        protected void ButtonProcess_Click(object sender, EventArgs e)
        {
            double CorrectionAmount = 0;

            try
            {
                CorrectionAmount = Convert.ToDouble(TextBoxAmount.Text);
            }
            catch
            {
            }

            if (CorrectionAmount.ToString() != TextBoxAmount.Text)
            {
                Common.InformUser(Page, "Het opgegeven correctiebedrag kan niet worden herkend. Geef aub een correct bedrag op.");
                TextBoxAmount.Text = CorrectionAmount.ToString();
            }
            else
            {
                LedgerMutation    lm  = new LedgerMutation();
                LedgerBookingCode lbc = (DataItem as LedgerBookingCode);

                lm.Description       = "CORR / Correctie " + lbc.Description;
                lm.IsCorrection      = true;
                lm.BookingType       = RadioButtonListBuyOrSell.SelectedValue;
                lm.LedgerBookingCode = lbc;

                if (lm.BookingType == "Sell")
                {
                    CorrectionAmount = -CorrectionAmount;
                }

                lm.AmountEXVat = CorrectionAmount;
                lm.VATAmount   = 0;
                lm.TotalAmount = lm.AmountEXVat;
                lm.Comments    = TextBoxComments.Text;

                lm.Process(ControlObjectContext);

                ControlObjectContext.SaveChanges();

                if (lm.BookingType == "Buy")
                {
                    CorrectionAmount = -CorrectionAmount;
                }

                Common.InformUser(Page, "U heeft de mutatie succesvol doorgevoerd. U kunt deze popup nu sluiten of nog een mutatie doorvoeren.");
            }
        }
        private void UpdateLedgerLevel()
        {
            LedgerBookingCode lbc = null;
            Ledger            lg  = null;

            // get the ledger or ledgerbookingcode we have to link to
            if (Request.Params["LedgerBookingCodeId"] != null)
            {
                lbc = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.LedgerBookingCodeSet", "Id", new Guid(Request.Params["LedgerBookingCodeId"]))) as LedgerBookingCode;
                LabelCurrentLevel.Text = String.Format(LabelCurrentLevelBase.Text, lbc.LedgerLevel);
            }
            else
            { // assume Id
                lg = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.LedgerSet", "Id", new Guid(Request.Params["Id"]))) as Ledger;
                LabelCurrentLevel.Text = String.Format(LabelCurrentLevelBase.Text, lg.LedgerLevel);
            }
        }
        protected void ButtonCorrectNow_Click(object sender, EventArgs e)
        {
            // first get the correction amount
            Double CorrectionAmount = 0;

            try
            {
                CorrectionAmount = Convert.ToDouble(TextBox_CorrectionAmount.Text);
            }
            catch
            {
            }

            // correct now
            if (CorrectionAmount.ToString() != TextBox_CorrectionAmount.Text)
            {
                Common.InformUser(Page, "Het correctiebedrag kan niet goed worden herkend. Voer dit opnieuw in en probeer het nogmaals.");
            }
            else
            {
                // start transaction
                using (TransactionScope TS = new TransactionScope())
                {
                    try
                    {
                        // save current record
                        StandardSaveHandler(null, null, false);

                        // update the ledgercheck & create the mutation
                        LedgerCheck lc = (DataItem as LedgerCheck);

                        LedgerBookingCode lbc         = null;
                        Ledger            lg          = null;
                        String            Description = "";

                        // get the ledger or ledgerbookingcode we have to link to
                        if (Request.Params["LedgerBookingCodeId"] != null)
                        {
                            lbc         = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.LedgerBookingCodeSet", "Id", new Guid(Request.Params["LedgerBookingCodeId"]))) as LedgerBookingCode;
                            Description = lbc.Description;
                        }
                        else
                        { // assume Id
                            lg          = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.LedgerSet", "Id", new Guid(Request.Params["Id"]))) as Ledger;
                            Description = lg.Description;
                        }

                        LedgerMutation lm = new LedgerMutation();
                        ControlObjectContext.AddToLedgerMutationSet(lm);

                        lm.Description       = "CORR / Correctie " + Description;
                        lm.IsCorrection      = true;
                        lm.BookingType       = "Buy";
                        lm.LedgerBookingCode = lbc;
                        lm.Ledger            = lg;
                        lm.AmountEXVat       = CorrectionAmount;
                        lm.VATAmount         = 0;
                        lm.TotalAmount       = lm.AmountEXVat;
                        lm.Process(ControlObjectContext);

                        lc.IsLedgerCorrected = true;

                        ControlObjectContext.SaveChanges();

                        TS.Complete();

                        // relado data
                        RebindControls();
                        UpdateLedgerLevel();

                        // inform user
                        Common.InformUser(Page, "De correctie is succesvol verwerkt.");
                    }
                    catch (Exception ex) // commit or procedure failed somewhere
                    {
                        // rollback transaction
                        TS.Dispose();

                        // inform user
                        Common.InformUserOnTransactionFail(ex, Page);
                    }
                }
            }
        }
Beispiel #9
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();
            }
        }