protected void ButtonNew_Click(object sender, EventArgs e)
        {
            RelationContract  NewObj  = new RelationContract();
            ModelTMSContainer Temp    = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);
            EntityKey         TempKey = new EntityKey("ModelTMSContainer.RelationSet", "Id", Guid.Parse(Request.Params["Id"]));
            Relation          TempObj = Temp.GetObjectByKey(TempKey) as Relation;

            NewObj.Relation = TempObj;

            NewObj.ContractDate      = Common.CurrentClientDate(Session);
            NewObj.ContractStartDate = Common.CurrentClientDate(Session);
            NewObj.ContractEndDate   = Common.CurrentClientDate(Session).AddMonths(1);

            NewObj.ContractType     = "Buy";
            NewObj.ContractPriority = 5;
            NewObj.ContractStatus   = "Open";

            NewObj.YourReference      = "";
            NewObj.PaymentConditions  = "";
            NewObj.DeliveryConditions = "";

            NewObj.HasContractGuidance = false;

            Temp.AddToRelationContractSet(NewObj);
            Temp.SaveChanges(SaveOptions.DetectChangesBeforeSave);

            WebUserControlCustomerRelationContract1.KeyID = NewObj.Id;
            LabelContractID.Text = WebUserControlCustomerRelationContract1.KeyID.ToString();
            WebUserControlCustomerRelationContract1.Visible = true;
            DetailTable.Visible = true;
        }
Exemple #2
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            Response.Clear();
            Response.CacheControl = "no-cache";
            Response.Expires      = -1;

            Response.Write("<actioncounter>\n\r<openactions>\n\r");

            ModelTMSContainer ControlObjectContext = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);

            ObjectQuery oq = ControlObjectContext.CreateQuery <DbDataRecord>(@"select count(0) 
                from RelationContactLogSet as it inner join RelationContactSet as rcs on it.RelationContact.Id = rcs.Id 
                inner join RelationSet as rs on rcs.Relation.Id = rs.Id
                where ((it.FollowUpState = ""Unhandled"" and it.FollowUpDateTime <= @ClientDateTime) or 
                    (it.FollowUpState = ""Paused"" and it.PausedUntilDateTime <= @ClientDateTime))
                    and (it.Handler = @Handler) ",
                                                                             new ObjectParameter("ClientDateTime", Common.CurrentClientDateTime(Session)),
                                                                             new ObjectParameter("Handler", Session["CurrentUserID"]));

            int Counter = 0;

            foreach (DbDataRecord rec in oq)
            {
                Counter = rec.GetInt32(0);
            }
            Response.Write(Counter.ToString());

            Response.Write("\n\r</openactions>\n\r</actioncounter>");
            Response.End();
        }
Exemple #3
0
        public void SaveSecondWeighingData(Freight frg, ModelTMSContainer ControlObjectContext)
        {
            FreightWeighing         fgw = frg.FreightWeighing.First <FreightWeighing>();
            FreightWeighingMaterial fwm = fgw.FreightWeighingMaterial.First <FreightWeighingMaterial>();

            fgw.WeighingDateTime2 = CalendarWithTimeControl2.SelectedDateTime;
            fgw.Key2 = TextBoxKey2.Text;
            try { fgw.Weight2 = Convert.ToDouble("0" + TextBoxWeight2.Text); }  catch { };
            fwm.TarraWeight    = fgw.Weight2;
            fwm.NetWeight      = fwm.GrossWeight - fwm.TarraWeight;
            frg.TotalNetWeight = fwm.NetWeight;
            frg.Description    = TextBoxDescription.Text;
            frg.Comments       = TextBoxComments.Text;
            frg.FreightStatus  = "Done";

            frg.RecalcTotalWeightFromWeighing();

            if (CheckBoxWeighingActionSort.Checked)
            {
                frg.FreightStatus = "In sorting";
            }
            if (CheckBoxWeighingActionInvoice.Checked)
            {
                frg.FreightStatus = "To be invoiced";
            }
        }
        protected void ButtonNew_Click(object sender, EventArgs e)
        {
            RelationContact   NewObj  = new RelationContact();
            ModelTMSContainer Temp    = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);
            EntityKey         TempKey = new EntityKey("ModelTMSContainer.RelationSet", "Id", Guid.Parse(Request.Params["Id"]));
            Relation          TempObj = Temp.GetObjectByKey(TempKey) as Relation;

            NewObj.Relation = TempObj;

            NewObj.RelationType       = "Other";
            NewObj.PhoneNumber        = "";
            NewObj.PrivateEMail       = "";
            NewObj.PrivateMobilePhone = "";
            NewObj.MobilePhone        = "";
            NewObj.HomePhone          = "";
            NewObj.EMail       = "";
            NewObj.Description = "Nieuwe relatie dd " + Common.CurrentClientDateTime(Session).ToString();

            Temp.AddToRelationContactSet(NewObj);
            Temp.SaveChanges(SaveOptions.DetectChangesBeforeSave);

            WebUserControlCustomerRelationContact1.KeyID                        = NewObj.Id;
            WebUserControlCustomerRelationContact1.Visible                      = true;
            WebUserControlCustomerRelationContactLogOverview1.Visible           = true;
            WebUserControlCustomerRelationContactLogOverview1.RelationContactId = NewObj.Id;
            DetailTable.Visible = true;
            //WebUserControlCustomerRelationContactLogOverview1.Visible = false;
        }
        public static DateTime GetLastLedgerClosureDateTime(ModelTMSContainer Context, string LedgerDescription)
        {
            DateTime LastClosure = GetSystemSettingDateTime(Context, "Last" + LedgerDescription + "ClosureDateTime", new DateTime(2000, 1, 1));

            if (LastClosure.Year == 2000)
            {
                // the date has not been set

                // assume today is the last closure datetime
                LastClosure = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 23, 59, 59);

                // check if this is correct
                try
                {
                    LedgerMutation mt = Context.LedgerMutationSet.OrderBy(o => o.CreateDateTime).First <LedgerMutation>();
                    if (mt != null)
                    {
                        // there have been earlier material mutations. Use that date.
                        LastClosure = new DateTime(mt.BookingDateTime.Year, mt.BookingDateTime.Month, mt.BookingDateTime.Day, 23, 59, 59);
                    }
                }
                catch
                {
                }
            }
            LastClosure = new DateTime(LastClosure.Year, LastClosure.Month, LastClosure.Day, 23, 59, 59);
            return(LastClosure);
        }
Exemple #6
0
        protected void ButtonChangePassword_Click(object sender, EventArgs e)
        {
            ModelTMSContainer Temp = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);
            StaffMember       sm   = Common.CurrentLoggedInUser(Page.Session, Temp);

            if (sm != null)
            {
                if (sm.Password.ToLower() == TextBoxOldPassword.Text.ToLower())
                {
                    if (TextBoxNewPassword.Text == TextBoxNewPassword2.Text)
                    {
                        sm.Password = TextBoxNewPassword.Text;
                        Temp.SaveChanges();
                        Common.InformUser(Page, "Het wachtwoord is gewijzigd.");
                    }
                    else
                    {
                        Common.InformUser(Page, "Het controle wachtwoord is niet gelijk aan het nieuwe wachtwoord. Deze moeten gelijk zijn. Voer ze opnieuw in. Het wachtwoord is NIET gewijzigd.");
                        TextBoxNewPassword2.Text = "";
                        TextBoxNewPassword.Text  = "";
                    }
                }
                else
                {
                    Common.InformUser(Page, "Het oude wachtwoord is niet correct! Het wachtwoord is NIET gewijzigd.");
                }
            }
        }
        public void DisableItemsAndSendMail(ModelTMSContainer _ControlObjectContext)
        {
            // disable item
            Guid Temp;

            LabelDisabledItems.Text = "";
            foreach (GridViewRow gvr in GridViewRentedOutMaterials.Rows)
            {
                // need this item be disabled?
                if ((gvr.Cells[0].Controls[3] as RadioButtonList).SelectedIndex >= 1)
                {
                    // disable item
                    Temp = new Guid((gvr.Cells[0].Controls[1] as CheckBox).ToolTip);

                    // get the corresponding RentalItemActivitySet
//                    RentalItemActivity ria = _ControlObjectContext.RentalItemActivitySet.Where(m => m.Id == Temp).First<RentalItemActivity>();
                    RentalItemActivity ria = _ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.RentalItemActivitySet", "Id", Temp)) as RentalItemActivity;

                    // and disable
                    ria.RentalItem.SendDisabledEMail(true);

                    LabelDisabledItems.Text = ria.RentalItem.Id.ToString() + ";" + LabelDisabledItems.Text;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (_ControlObjectContext == null)
            {
                _ControlObjectContext = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);
            }

            WebUserControlEditOrderMaterials1.ControlObjectContext = _ControlObjectContext;

            if (!IsPostBack)
            {
                URLPopUpControlShowFreightData.Visible = false;

                DropDownListLocations.DataBind();
                DropDownListCustomers.DataBind();
                Common.LimitLocationList(DropDownListLocations.Items, Session, _ControlObjectContext);
                ShowCorrectPanels();
                ShowCorrectCustomer();

                ButtonRefresh_Click(sender, e);
            }


            ShowFreightButton();
        }
        public void AddRentMaterialsToRentLedgerAndRentalItemActivitySet(ModelTMSContainer ControlObjectContext, RentLedger rl)
        {
            LoadOrderLines();

            // add each rental item line
            foreach (RentalItemActivityListItem ria in OrderLines)
            {
                RentalItemActivity riaactivity = new RentalItemActivity();

                // hookup items
                riaactivity.RentalItem = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.RentalItemSet", "Id", ria.RentalItemId)) as RentalItem;

                // create rentalitemactivity line
                riaactivity.RentStartDateTime         = StartRentDate;
                riaactivity.RentEndStartDateTime      = EndRentDate;
                riaactivity.Description               = riaactivity.RentalItem.Description;
                riaactivity.InvoiceStatus             = "Open";
                riaactivity.CalculatedRentPrice       = ria.RentPrice;
                riaactivity.BaseRentPrice             = ria.RentPrice;
                riaactivity.DiscountPercentage        = ria.DiscountPercentage;
                riaactivity.VATRentPrice              = ria.Vat;
                riaactivity.TotalRentPrice            = ria.TotalRentPrice;
                riaactivity.IsTreatedAsAdvancePayment = ria.TreatAsAdvancePayment;
                riaactivity.GenerateDescription();

                riaactivity.UpdateAdvancePaymentStatus(ControlObjectContext, true, ria.TreatAsAdvancePayment);

                rl.RentalItemActivity.Add(riaactivity);
            }
        }
Exemple #10
0
        public Boolean AccessToFormAllowed(Page pg, ModelTMSContainer ControlObjectContext, string FormTitle)
        {
            _Page = pg;
            _ControlObjectContext = ControlObjectContext;
            sm = Common.CurrentLoggedInUser(_Page.Session, _ControlObjectContext);
            sm.SecurityRole.Load();

            bool Result = false;

            if (sm != null)
            {
                if (sm.HasVMSAccount)
                {
                    Result = sm.CheckAccessToElement(_ControlObjectContext, FormName(), "", FormTitle, AccessType.Execute);
                }
            }

            ControlObjectContext.SaveChanges();

            if (Common.IsMasterLoggedIn(pg.Session))
            {
                return(true);
            }
            else
            {
                return(Result);
            }
        }
Exemple #11
0
        protected bool ProcessFirstWeighing()
        {
            ModelTMSContainer ControlObjectContext = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);
            bool Success = false;

            // start transaction
            using (TransactionScope TS = new TransactionScope())
            {
                try
                {
                    // process freight
                    // setup base objects
                    Freight                 frg  = new Freight();
                    FreightWeighing         frgw = new FreightWeighing();
                    FreightWeighingMaterial frgm = new FreightWeighingMaterial();
                    frg.FreightWeighing.Add(frgw);
                    frgw.FreightWeighingMaterial.Add(frgm);

                    ControlObjectContext.AddToFreightSet(frg);

                    // save the first weighing data in the freight
                    SaveFirstWeighingData(frg, ControlObjectContext);

                    // assign the weighing number
                    frg.AssignFreightNumber(ControlObjectContext);
                    LabelFreightNr.Text = frg.OurReference.ToString();
                    CurrentWeighingId   = frg.Id;
                    frg.Description     = "Weegbon " + frg.OurReference + " / " + Common.CurrentClientDateTime(Session).ToString();
                    frg.FreightType     = "Weighing";

                    // and save to persistent storage
                    ControlObjectContext.SaveChanges(System.Data.Objects.SaveOptions.DetectChangesBeforeSave);

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

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

                    // reset the weighing id when not saved
                    CurrentWeighingId = Guid.Empty;
                }
            }

            if (Success)
            {
                // when success advance panel
                CurrentPageNr++;
            }
            return(Success);
        }
Exemple #12
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            bool   Success = false;
            string Query   = "SELECT VALUE it FROM OrderSet as it WHERE it.id = @Order_Id";

            // save here
            using (TransactionScope TS = new TransactionScope())
            {
                try
                {
                    ControlObjectContext = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);

                    ObjectQuery <Order> query = new ObjectQuery <Order>(Query, ControlObjectContext).Include("OrderLine");
                    query.Parameters.Add(new ObjectParameter("Order_ID", OrderID));
                    ObjectResult <Order> OrderList = query.Execute(MergeOption.AppendOnly);
                    Order ThisOrder = OrderList.First <Order>();

                    LoadOrderLines();

                    // delete all order lines
                    List <OrderLine> oll = ThisOrder.OrderLine.ToList();
                    for (int i = oll.Count - 1; i >= 0; i--)
                    {
                        ControlObjectContext.DeleteObject(oll[i]);
                    }
                    ThisOrder.OrderLine.Clear();

                    // add new order lines
                    foreach (OrderLine ol in OrderLines)
                    {
                        ThisOrder.OrderLine.Add(ol);
                    }
                    ThisOrder.RecalcTotals();

                    // and save to persistent storage
                    ControlObjectContext.SaveChanges(System.Data.Objects.SaveOptions.DetectChangesBeforeSave);

                    // commit the transaciton
                    TS.Complete();

                    Success = true;
                }
                catch (Exception ex) // commit or procedure failed somewhere
                {
                    // rollback transaction
                    TS.Dispose();

                    // inform user
                    Common.InformUserOnTransactionFail(ex, Page);
                }
            }
            if (Success)
            {
                // fire the event for the save button
                FireOnSaveButtonClicked(e);
            }
        }
        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);
        }
Exemple #14
0
        protected void ButtonDestroyOrderAndBack_Click(object sender, EventArgs e)
        {
            bool Success = false;

            if (LabelCurrentOrderId.Text != Guid.Empty.ToString())
            {
                ModelTMSContainer _ControlObjectContext = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);

                // start transaction
                using (TransactionScope TS = new TransactionScope())
                {
                    try
                    {
                        // roll back order

                        // correct invoice if there
                        if (LabelCurrentInvoiceId.Text != "")
                        {
                            Invoice CorrInvoice = _ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.InvoiceSet", "Id", Guid.Parse(LabelCurrentInvoiceId.Text))) as Invoice;

                            // unprocess
                            CorrInvoice.UnprocessInvoice(_ControlObjectContext, CorrInvoice.GroupCode, Common.CurrentClientDateTime(Session));
                        }

                        // destroy rentledger
                        RentLedger TempRentLedger = _ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.RentLedgerSet", "Id", Guid.Parse(LabelCurrentOrderId.Text))) as RentLedger;
                        TempRentLedger.DestroyRentalItemActivities(_ControlObjectContext);
                        _ControlObjectContext.DeleteObject(TempRentLedger);

                        // and save to persistent storage
                        _ControlObjectContext.SaveChanges(System.Data.Objects.SaveOptions.DetectChangesBeforeSave);

                        // commit
                        TS.Complete();

                        Success = true;
                    }
                    catch (Exception ex)
                    {
                        // rollback transaction
                        TS.Dispose();

                        // inform user
                        Common.InformUserOnTransactionFail(ex, Page);
                    }
                }
            }

            if (Success)
            {
                // when success revert
                CurrentPageNr--;
                EnableCorrectScreenElements();
            }
        }
Exemple #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((_ControlObjectContext == null) && (!this.DesignMode))
            {
                _ControlObjectContext = new ModelTMSContainer(Page.Session["CustomerConnectString"].ToString(), Session);
            }

            if (!IsPostBack)
            {
            }
        }
Exemple #16
0
        public void InstallUserRightsIntoPage(Page pg, ModelTMSContainer ControlObjectContext)
        {
            _Page = pg;
            _ControlObjectContext = ControlObjectContext;
            sm = Common.CurrentLoggedInUser(_Page.Session, _ControlObjectContext);
            sm.SecurityRole.Load();

            EnumerateSecuredControls(pg.Controls);

            ControlObjectContext.SaveChanges();
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         // get the relation description
         ModelTMSContainer _ControlObjectContext = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);
         EntityKey         TempKey = new EntityKey("ModelTMSContainer.RelationSet", "Id", Guid.Parse(Request.Params["Id"]));
         Relation          TempObj = _ControlObjectContext.GetObjectByKey(TempKey) as Relation;
         LabelObjectName.Text = TempObj.Description;
     }
 }
        protected bool PrepareOldWeighingForSorting()
        {
            // check whether this weighing may be deleted. If this is not the case then inform the user that this weighing is already processed.
            ModelTMSContainer ControlObjectContext = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);
            bool Success = false;

            // start transaction
            using (TransactionScope TS = new TransactionScope())
            {
                try
                {
                    // add weighing materual as sorting material
                    Freight frg = Freight.SelectFreightByFreightId(CurrentWeighingId, ControlObjectContext);


                    frg.RecalcTotalWeightFromWeighing();

                    foreach (FreightWeighing fw in frg.FreightWeighing)
                    {
                        foreach (FreightWeighingMaterial fwm in fw.FreightWeighingMaterial)
                        {
                            FreightSortingMaterial fsm = new FreightSortingMaterial();

                            fsm.Material    = fwm.Material;
                            fsm.Weight      = fwm.NetWeight;
                            fsm.GrossWeight = fwm.GrossWeight;
                            fsm.TarraWeight = fwm.TarraWeight;
                            fsm.Freight     = frg;

                            ControlObjectContext.AddToFreightSortingMaterialSet(fsm);
                        }
                    }

                    frg.RecalcTotalWeightFromSorting();

                    // and save to persistent storage
                    ControlObjectContext.SaveChanges(System.Data.Objects.SaveOptions.DetectChangesBeforeSave);

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

                    // inform user
                    Common.InformUserOnTransactionFail(ex, Page);
                }
            }
            return(Success);
        }
Exemple #19
0
        protected void ButtonNew_Click(object sender, EventArgs e)
        {
            StaffMember       NewObj = new StaffMember();
            ModelTMSContainer Temp   = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);

            Temp.AddToStaffMemberSet(NewObj);
            NewObj.HomeLocation = Temp.LocationSet.First();
            NewObj.LimitAccessToThisLocation = null;
            Temp.SaveChanges(SaveOptions.DetectChangesBeforeSave);

            WebUserControlStaffMember1.KeyID   = NewObj.Id;
            WebUserControlStaffMember1.Visible = true;
        }
        public static bool IsSystemSettingPresent(ModelTMSContainer Context, string PropertyName)
        {
            bool RetVal = false;
            ObjectQuery <SystemSetting> TempSetting = Context.SystemSettingSet.Where("it.Description = @PropName",
                                                                                     new ObjectParameter("PropName", PropertyName));

            if (TempSetting.Count() == 1)
            {
                RetVal = true;
            }

            return(RetVal);
        }
        public static SystemSetting GetSystemSetting(ModelTMSContainer Context, string PropertyName)
        {
            SystemSetting RetVal = null;
            ObjectQuery <SystemSetting> TempSetting = Context.SystemSettingSet.Where("it.Description = @PropName",
                                                                                     new ObjectParameter("PropName", PropertyName));

            if (TempSetting.Count() >= 1)
            {
                RetVal = TempSetting.First();
            }

            return(RetVal);
        }
        public void ResetRentalItemStatus(ModelTMSContainer ControlObjectContext)
        {
            foreach (GridViewRow gvr in GridViewRentedOutMaterials.Rows)
            {
                Guid Temp = new Guid((gvr.Cells[0].Controls[1] as CheckBox).ToolTip);

                // get the corresponding RentalItemActivitySet
//                RentalItemActivity ria = ControlObjectContext.RentalItemActivitySet.Where(m => m.Id == Temp).First<RentalItemActivity>();
                RentalItemActivity ria = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.RentalItemActivitySet", "Id", Temp)) as RentalItemActivity;

                ria.CheckInvoiceStatus();
            }
        }
Exemple #23
0
        protected void ButtonNew_Click(object sender, EventArgs e)
        {
            Relation          NewObj = new Relation();
            ModelTMSContainer Temp   = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);

            Temp.AddToRelationSet(NewObj);
            NewObj.CustomerType      = "Both";
            NewObj.PreferredCurrency = "Eur";
            Temp.SaveChanges(SaveOptions.DetectChangesBeforeSave);

            WebUserControlCustomerRelation1.KeyID   = NewObj.Id;
            WebUserControlCustomerRelation1.Visible = true;
        }
Exemple #24
0
        protected void ButtonNew_Click(object sender, EventArgs e)
        {
            MaterialUnit      NewMat = new MaterialUnit();
            ModelTMSContainer Temp   = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);

            Temp.AddToMaterialUnitSet(NewMat);
            NewMat.Description = "Materiaaleenheid";

            Temp.SaveChanges(SaveOptions.DetectChangesBeforeSave);

            WebUserControlStockUnitsBase1.KeyID   = NewMat.Id;
            WebUserControlStockUnitsBase1.Visible = true;
        }
Exemple #25
0
        public void SetCorrectLocationCashLedger()
        {
            ModelTMSContainer ControlObjectContext = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);
            Location          loc = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.LocationSet", "Id", Guid.Parse(ComboBoxWeighingLocation.SelectedValue))) as Location;

            ComboBoxLedger.DataBind();
            ListItem li = ComboBoxLedger.Items.FindByValue(loc.CashLedger.Id.ToString());

            if (li != null)
            {
                li.Selected = true;
            }
        }
Exemple #26
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;
        }
Exemple #27
0
        protected void ButtonNew_Click(object sender, EventArgs e)
        {
            Ledger            NewMat = new Ledger();
            ModelTMSContainer Temp   = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);

            //NewMat.LimitToLocation = Temp.LocationSet.First();

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

            WebUserControlLedgerBase1.SetNewKeyID(NewMat.Id);
            WebUserControlLedgerBase1.Visible = true;
        }
        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
        }
        private static Int64 GetNextCounterValue(ModelTMSContainer Context, string CounterName, bool Save)
        {
            String PropName = "Counter." + CounterName;
            Int64  Temp     = Convert.ToInt64(GetSystemSettingValue(Context, PropName, "0"));

            Temp = Temp + 1;

            if (Save)
            {
                SetSystemSettingValue(Context, PropName, Temp.ToString(), "Integer counter value for " + CounterName + ". Do not modify value manually !!!");
            }

            return(Temp);
        }
        protected void ButtonNew_Click(object sender, EventArgs e)
        {
            Location          NewObj = new Location();
            ModelTMSContainer Temp   = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);

            NewObj.DefaultWeighingTariffBookingCode = Temp.LedgerBookingCodeSet.First <LedgerBookingCode>();
            NewObj.DefaultBailPriceBookingCode      = Temp.LedgerBookingCodeSet.First <LedgerBookingCode>();
            Temp.AddToLocationSet(NewObj);

            Temp.SaveChanges(SaveOptions.DetectChangesBeforeSave);

            WebUserControlCompanyLocation1.KeyID   = NewObj.Id;
            WebUserControlCompanyLocation1.Visible = true;
        }