Пример #1
0
        protected void GridViewOrderLines_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            e.Cancel = true;

            OrderLine TempLine;

            try
            {
                TempLine                        = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.OrderLineSet", "Id", Guid.Parse(e.Keys[0].ToString()))) as OrderLine;
                TempLine.Description            = e.NewValues[0].ToString();
                TempLine.Amount                 = Math.Round(Convert.ToDouble(e.NewValues[1].ToString()), 4);
                TempLine.PricePerUnit           = Math.Round(Convert.ToDouble(e.NewValues[2].ToString()), 4);
                TempLine.AlreadyDeliveredAmount = Math.Round(Convert.ToDouble(e.NewValues[3].ToString()), 4);

                TempLine.Order.RecalcTotals();
            }
            catch { }

            try
            {
                ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);
            }
            catch (Exception ex)
            {
                Common.InformUserOnTransactionFail(ex, Page);
            }

            GridViewOrderLines.EditIndex = -1;

            RebindControls();
            DataBind();
        }
        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;
        }
        protected void ButtonCorrect_Click(object sender, EventArgs e)
        {
            // start transaction
            using (TransactionScope TS = new TransactionScope())
            {
                try
                {
                    Invoice inv = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.InvoiceSet", "Id", new System.Guid(LabelGeneratedInvoiceId.Text))) as Invoice;

                    inv.UnprocessInvoice(ControlObjectContext, new System.Guid(LabelGroupId.Text), Common.CurrentClientDateTime(Session));

                    // save the data
                    ControlObjectContext.SaveChanges(System.Data.Objects.SaveOptions.DetectChangesBeforeSave);

                    // commit the transaciton
                    TS.Complete();

                    CurrentPageNr--;
                    EnableCurrentPageElements();
                }
                catch (Exception ex)
                {
                    // rollback transaction
                    TS.Dispose();

                    // inform user
                    Common.InformUserOnTransactionFail(ex, Page);
                }
            }
        }
Пример #4
0
        protected void LoadSortingMaterials()
        {
            if (LabelMaterialData.Text != "")
            {
                StringReader  TempData        = new StringReader(LabelMaterialData.Text);
                XmlTextReader CurrentMaterial = new XmlTextReader(TempData);
                MaterialLines = new List <FreightSortingMaterial>();
                Double TotalWeight = 0;

                while (CurrentMaterial.Read())
                {
                    if (CurrentMaterial.Name == "MaterialLine")
                    {
                        // process this orderline
                        FreightSortingMaterial TempFSMLine = new FreightSortingMaterial();

                        TempFSMLine.Id          = Guid.Parse(CurrentMaterial.GetAttribute("id"));
                        TempFSMLine.Description = CurrentMaterial.GetAttribute("description");
                        TempFSMLine.GrossWeight = Convert.ToDouble(CurrentMaterial.GetAttribute("GrossAmount"));
                        TempFSMLine.TarraWeight = Convert.ToDouble(CurrentMaterial.GetAttribute("NetAmount"));
                        TempFSMLine.Material    = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.MaterialSet", "Id", Guid.Parse(CurrentMaterial.GetAttribute("materialid")))) as Material;
                        TempFSMLine.RecalcTotals();
                        TotalWeight = TotalWeight + TempFSMLine.Weight;
                        MaterialLines.Add(TempFSMLine);
                    }
                }

                LabelTotalWeightInOrder.Text = TotalWeight.ToString();
                CurrentMaterial.Close();
            }
        }
Пример #5
0
        private void DetermineCurrentSelectedMaterial(out Material MatItem, out RelationPriceAgreement PAItem, out RelationContractMaterial ContractItem)
        {
            // locate the material, price agreement or contract in the entitydatasource
            Guid SelID = Guid.Parse(DropDownListMaterials.SelectedValue);

            // try to load the data from material, relationcontract or relationpriceagreement
            MatItem      = null;
            PAItem       = null;
            ContractItem = null;
            EntityKey TempKey = new EntityKey("ModelTMSContainer.MaterialSet", "Id", SelID);

            try { MatItem = ControlObjectContext.GetObjectByKey(TempKey) as Material; }
            catch { };
            if (MatItem == null)
            {
                TempKey = new EntityKey("ModelTMSContainer.RelationPriceAgreementSet", "Id", SelID);
                try
                {
                    PAItem  = ControlObjectContext.GetObjectByKey(TempKey) as RelationPriceAgreement;
                    MatItem = PAItem.Material;
                }
                catch { };
            }
            if ((MatItem == null) && (PAItem == null))
            {
                TempKey = new EntityKey("ModelTMSContainer.RelationContractMaterialSet", "Id", SelID);
                try
                {
                    ContractItem = ControlObjectContext.GetObjectByKey(TempKey) as RelationContractMaterial;
                    MatItem      = ContractItem.Material;
                }
                catch { };
            }
        }
Пример #6
0
        protected void ButtonAddWorkCorrection_Click(object sender, EventArgs e)
        {
            StandardSaveHandler(sender, e, false);

            InvoiceLine il = new InvoiceLine();

            try
            {
                RelationWork RelWork = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.RelationWorkSet", "Id", Guid.Parse(DropDownListWorkCorrection.SelectedValue))) as RelationWork;

                (DataItem as Invoice).AddWorkCorrection(ControlObjectContext,
                                                        RelWork,
                                                        Convert.ToDouble(TextBoxWorkCorrectionAmount.Text) * -1,
                                                        LabelWorkCorrection.Text + " " + RelWork.Description);

                (DataItem as Invoice).RecalcTotals();
            }
            catch { }

            try
            {
                ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);
            }
            catch (Exception ex)
            {
                Common.InformUserOnTransactionFail(ex, Page);
            }

            RebindControls();
            DataBind();
        }
Пример #7
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);
            }
        }
Пример #8
0
        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);
        }
Пример #9
0
        protected void GridViewOrderLines_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            e.Cancel = true;

            InvoiceLine il;

            il = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.InvoiceLineSet", "Id", Guid.Parse(e.Keys[0].ToString()))) as InvoiceLine;

            try
            {
                il.Description        = e.NewValues[0].ToString();
                il.Amount             = Convert.ToDouble(e.NewValues[1].ToString());
                il.PricePerUnit       = Convert.ToDouble(e.NewValues[2].ToString());
                il.DiscountPercentage = Convert.ToDouble(e.NewValues[3].ToString());
                il.VATPercentage      = Convert.ToDouble(e.NewValues[4].ToString());
                il.Invoice.RecalcTotals();
            }
            catch { }

            try
            {
                ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);
            }
            catch (Exception ex)
            {
                Common.InformUserOnTransactionFail(ex, Page);
            }

            RebindControls();
            DataBind();

            GridViewOrderLines.EditIndex = -1;
        }
Пример #10
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);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // set the correct filters
                CalendarControlStartDate.SelectedDate = new DateTime(Common.CurrentClientDateTime(Session).Year, 1, 1);
                CalendarControlEndDate.SelectedDate   = Common.CurrentClientDateTime(Session).Date;

                ButtonSearch_Click(sender, e);

                if (Request.Params["MutationNumber"] != null)
                {
                    TextBoxOrderNo.Text = Request.Params["MutationNumber"];
                    EntityDataSourceStockMutationLedger.CommandParameters["MutationNumber"].DefaultValue = TextBoxOrderNo.Text;
                    EntityDataSourceStockMutationLedger.DataBind();

                    if (GridViewSelectedMutations.Rows.Count == 1)
                    {
                        GridViewSelectedMutations.SelectedIndex = 0;
                        GridViewSelectedMutations_SelectedIndexChanged(null, null);
                    }
                }

                if (Request.Params["Id"] != null)
                {
                    // load material to show in the header
                    Material Mat = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.MaterialSet", "Id", new Guid(Request.Params["Id"]))) as Material;
                    LabelObjectName.Text = Mat.Description;
                }
            }
        }
Пример #12
0
        private void CheckAlternativeMaterialsSettings()
        {
            RentalType rt = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.RentalTypeSet", "Id", new Guid(ComboBoxMaterialType.SelectedValue))) as RentalType;

            URLPopUpControlAlternativeMaterials.Visible    = rt.AlternativeRentalTypes.Count > 0;
            URLPopUpControlAlternativeMaterials.URLToPopup = "WebFormPopUp.aspx?uc=RentAlternativeMaterials&RentalType=" + ComboBoxMaterialType.SelectedValue +
                                                             "&LocationId=" + EntityDataSourceMaterials.CommandParameters["LocationId"].DefaultValue +
                                                             "&StartDate=" + EntityDataSourceMaterials.CommandParameters["StartDate"].DefaultValue +
                                                             "&EndDate=" + EntityDataSourceMaterials.CommandParameters["EndDate"].DefaultValue;
        }
Пример #13
0
 public object GetDataItem(Guid IDKey)
 {
     if (SetName != "")
     {
         EntityKey TempKey = new EntityKey("ModelTMSContainer." + SetName + "Set", "Id", IDKey);
         return(ControlObjectContext.GetObjectByKey(TempKey));
     }
     else
     {
         return(null);
     }
 }
Пример #14
0
        public void LoadOrderLines(bool SaveOrderLine = true)
        {
            LabelTotalWeight.Text   = "...";
            LabelTotalPrice.Text    = "...";
            LabelTotalPriceVAT.Text = "...";

            OrderLines.Clear();
            if (LabelOrderData.Text != "")
            {
                StringReader  TempData     = new StringReader(LabelOrderData.Text);
                XmlTextReader CurrentOrder = new XmlTextReader(TempData);
                OrderLines = new ArrayList();
                Double TotalWeight   = 0;
                Double TotalPrice    = 0;
                Double TotalPriceVAT = 0;

                while (CurrentOrder.Read())
                {
                    if (CurrentOrder.Name == "OrderLine")
                    {
                        // process this orderline
                        OrderLine TempOrderLine = new OrderLine();
                        TempOrderLine.Id                     = Guid.Parse(CurrentOrder.GetAttribute("id"));
                        TempOrderLine.Description            = CurrentOrder.GetAttribute("description");
                        TempOrderLine.Amount                 = Convert.ToDouble(CurrentOrder.GetAttribute("amount"));
                        TempOrderLine.AlreadyDeliveredAmount = Convert.ToDouble(CurrentOrder.GetAttribute("alreadydeliveredamount"));
                        TempOrderLine.PricePerUnit           = Convert.ToDouble(CurrentOrder.GetAttribute("priceperunit"));
                        TempOrderLine.PriceExVAT             = TempOrderLine.Amount * TempOrderLine.PricePerUnit;
                        TempOrderLine.Material               = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.MaterialSet", "Id", Guid.Parse(CurrentOrder.GetAttribute("materialid")))) as Material;
                        TotalWeight   = TotalWeight + TempOrderLine.AmountInKgs;
                        TotalPrice    = TotalPrice + TempOrderLine.PriceExVAT;
                        TotalPriceVAT = TotalPriceVAT + TempOrderLine.PriceWithVAT;
                        if (CurrentOrder.GetAttribute("priceagreementid") != "")
                        {
                            TempOrderLine.RelationPriceAgreement = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.RelationPriceAgreementSet", "Id", Guid.Parse(CurrentOrder.GetAttribute("priceagreementid")))) as RelationPriceAgreement;
                        }
                        if (CurrentOrder.GetAttribute("contractmaterialid") != "")
                        {
                            TempOrderLine.RelationContractMaterial = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.RelationContractMaterialSet", "Id", Guid.Parse(CurrentOrder.GetAttribute("contractmaterialid")))) as RelationContractMaterial;
                        }

                        OrderLines.Add(TempOrderLine);
                    }
                }
                LabelTotalWeight.Text   = TotalWeight.ToString();
                LabelTotalPrice.Text    = Math.Round(TotalPrice, 2).ToString();
                LabelTotalPriceVAT.Text = Math.Round(TotalPriceVAT, 2).ToString();
            }
            if (SaveOrderLine)
            {
                SaveOrderLines();
            }
        }
        public void ConstructQuery()
        {
            RentalType rt = ControlObjectContext.GetObjectByKey(new System.Data.EntityKey("ModelTMSContainer.RentalTypeSet", "Id", new Guid(Request.Params["RentalType"]))) as RentalType;

            StringBuilder Query = new StringBuilder();

            Query.Append("select distinct it.Id, it.ItemNumber, it.Description, it.Description, it.BaseRentalPrice, it.RentPerDay, it.RentPerWeek, it.RentPerMonth, it.BailPrice, it.Location.Description as LocationDescription " +
                         "from RentalItemSet as it  " +
                         "where  " +
                         "it.IsActive and  " +
                         "( (it.ItemState = \"Available\") or (it.ItemState = \"Rented\") ) and " +
                         "( it not in ( " +
                         "	select value itx2.RentalItem  "+
                         "	from RentalItemActivitySet as itx2  "+
                         "	where itx2.RentalItem.Id = it.Id and "+
                         "	 (  "+
                         "	   ((@StartDate <= itx2.RentStartDateTime) and (@EndDate >= itx2.RentStartDateTime))  "+
                         "	 ) or "+
                         "	 ( "+
                         "	   ((@StartDate >= itx2.RentStartDateTime) and (@StartDate <= itx2.RentEndStartDateTime)) "+
                         "	 ) "+
                         "  ) " +
                         ") and  ( cast(it.RentalType.Id as System.String) in { ");
            // insert the alternative rental type ID's
            foreach (RentalType rtAlt in rt.AlternativeRentalTypes)
            {
                Query.Append("'" + rtAlt.Id.ToString() + "'");
            }
            Query.Append("} ) ");

            // insert the location ID if required
            if (CheckBoxIncludeAlternativeLocations.Checked)
            {
                if (ComboBoxLocations.SelectedValue != "")
                {
                    Query.Append(" and (it.Location.Id = @LocationId) ");
                    EntityDataSourceMaterials.CommandParameters["LocationId"].DefaultValue = ComboBoxLocations.SelectedValue;
                }
            }
            else
            {
                Query.Append(" and (it.Location.Id = @LocationId) ");
                EntityDataSourceMaterials.CommandParameters["LocationId"].DefaultValue = Request.Params["LocationId"];
            }

            // add the ordering
            Query.Append("order by Description, BaseRentalPrice");

            // set as commandtext
            EntityDataSourceMaterials.CommandText = Query.ToString();
        }
Пример #16
0
        protected void GridViewOrderLines_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            e.Cancel = true;

            OrderLine TempLine;

            TempLine = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.OrderLineSet", "Id", Guid.Parse(e.Keys[0].ToString()))) as OrderLine;

            (DataItem as Order).OrderLine.Remove(TempLine);
            ControlObjectContext.DeleteObject(TempLine);
            ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);

            RebindControls();
            DataBind();
        }
        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);
            }
        }
Пример #18
0
        protected void GridViewRentedOutMaterials_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            DateTime EndDateRent;

            if (e.Row.DataItem != null)
            { // register the row id in the hint
                (e.Row.Cells[0].Controls[1] as CheckBox).ToolTip = (e.Row.DataItem as DbDataRecord).GetValue(0).ToString();
                (e.Row.Cells[0].Controls[1] as CheckBox).Checked = RentalNr > 0;

                // get the combobox
                ComboBox cbx = (e.Row.Cells[8].Controls[3] as ComboBox);

                // grab the possible new enddate from the grid
                EndDateRent = new DateTime(2100, 1, 1);
                try
                {
                    EndDateRent = Convert.ToDateTime((e.Row.DataItem as DbDataRecord).GetValue(4));
                    EndDateRent = Convert.ToDateTime((e.Row.Cells[4].Controls[0]).ToString()); // original value
                }
                catch { }

                ObjectQuery Results = ControlObjectContext.CreateQuery <RentalItem>(MaterialAvailableQuery,
                                                                                    new ObjectParameter("RentalType", (e.Row.DataItem as DbDataRecord).GetValue(2)),
                                                                                    new ObjectParameter("LocationId", (e.Row.DataItem as DbDataRecord).GetValue(1)),
                                                                                    new ObjectParameter("StartDate", (e.Row.DataItem as DbDataRecord).GetValue(3)),
                                                                                    new ObjectParameter("EndDate", EndDateRent),
                                                                                    new ObjectParameter("BorderEndDate", new DateTime(2100, 1, 1)));

                LoadComboBox(cbx, Results);

                URLPopUpControl upc = (e.Row.Cells[8].Controls[5] as URLPopUpControl);
                // get the corresponding RentalItemActivitySet
                Guid Temp = new Guid((e.Row.DataItem as DbDataRecord).GetValue(0).ToString());
//                RentalItemActivity ria = ControlObjectContext.RentalItemActivitySet.Where(m => m.Id == Temp).First<RentalItemActivity>();
                RentalItemActivity ria = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.RentalItemActivitySet", "Id", Temp)) as RentalItemActivity;
                upc.Visible = false;
                if ((ria != null) && (ria.InvoiceLine != null))
                {
                    upc.Visible    = true;
                    upc.URLToPopup = "WebFormPopup.aspx?UC=InvoiceBase&Id=" + ria.InvoiceLine.Invoice.Id.ToString();
                }
            }
        }
Пример #19
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            // save the object access settings for this role
            if (GridViewRoleObjectAccess.Rows.Count != 0)
            {
                // get the IDs of the security objects
                String[] IDResultSet = LabelIDResultSet.Text.Split(',');
                int      RowCounter  = 0;

                // loop through all rows
                foreach (GridViewRow gvr in GridViewRoleObjectAccess.Rows)
                {
                    if (gvr.RowType == DataControlRowType.DataRow)
                    {
                        DbDataRecord dbdr = gvr.DataItem as DbDataRecord;

                        // get the row id
                        //Guid RowID = new Guid(dbdr.GetValue(0).ToString());
                        Guid RowID = new Guid(IDResultSet[RowCounter]);
                        RowCounter++;

                        // update the row with the new settings
                        Boolean Create, Read, Update, Delete, Execute;
                        Create  = (gvr.FindControl("CheckBoxCreate") as CheckBox).Checked;
                        Read    = (gvr.FindControl("CheckBoxRead") as CheckBox).Checked;
                        Update  = (gvr.FindControl("CheckBoxUpdate") as CheckBox).Checked;
                        Delete  = (gvr.FindControl("CheckBoxDelete") as CheckBox).Checked;
                        Execute = (gvr.FindControl("CheckBoxExecute") as CheckBox).Checked;

                        // locate the object access & update
                        SecurityRoleObjectAccess sroa = ControlObjectContext.GetObjectByKey(new System.Data.EntityKey("ModelTMSContainer.SecurityRoleObjectAccessSet", "Id", RowID)) as SecurityRoleObjectAccess;
                        sroa.HasCreateAccess  = Create;
                        sroa.HasReadAccess    = Read;
                        sroa.HasUpdateAccess  = Update;
                        sroa.HasDeleteAccess  = Delete;
                        sroa.HasExecuteAccess = Execute;
                    }
                }
            }

            StandardButtonSaveClickHandler(sender, e);
        }
Пример #20
0
        public int NrOfInvoicedItems()
        {
            int Result = 0;

            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;

                if ((ria.InvoiceLine != null) && ((gvr.Cells[0].Controls[1] as CheckBox).Checked))
                {
                    Result++;
                }
            }

            return(Result);
        }
        protected void SaveCheckBoxesInAlternativeMaterialTypes()
        {
            RentalType rt = (DataItem as RentalType);

            // delete all elements
            foreach (RentalType CheckRt in rt.AlternativeRentalTypes.ToArray <RentalType>())
            {
                rt.AlternativeRentalTypes.Remove(CheckRt);
            }

            // add new elements
            foreach (ListItem li in CheckBoxListAlternativeMaterialTypes.Items)
            {
                if (li.Selected)
                {
                    RentalType rtNew = ControlObjectContext.GetObjectByKey(new System.Data.EntityKey("ModelTMSContainer.RentalTypeSet", "Id", new Guid(li.Value))) as RentalType;
                    rt.AlternativeRentalTypes.Add(rtNew);
                }
            }
        }
        protected void ButtonProcess_Click(object sender, EventArgs e)
        {
            double CorrectionAmount = 0;

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

            if (CorrectionAmount.ToString() != TextBoxPaidAmount.Text)
            {
                Common.InformUser(Page, "Het bedrag wat u heeft ingevuld is niet juist. Controleer het bedrag.");
                TextBoxPaidAmount.Text = CorrectionAmount.ToString();
            }
            else
            {
                LedgerMutation lm = new LedgerMutation();
                ControlObjectContext.AddToLedgerMutationSet(lm);

                Invoice inv = (DataItem as Invoice);

                lm.Ledger      = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.LedgerSet", "Id", new Guid(DropDownListLedger.SelectedValue))) as Ledger;
                lm.Location    = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.LocationSet", "Id", new Guid(DropDownListLocation.SelectedValue))) as Location;
                lm.Description = "INV / PPaid / Vooruitbetaald bedrag factuur " + inv.InvoiceNumber.ToString();
                lm.GroupCode   = inv.GroupCode;
                lm.BookingType = inv.InvoiceType;
                lm.AmountEXVat = CorrectionAmount;
                lm.VATAmount   = 0;
                lm.TotalAmount = CorrectionAmount;
                lm.Process(ControlObjectContext);

                inv.AlreadyPaid   = inv.AlreadyPaid + CorrectionAmount;
                inv.InvoiceStatus = inv.AlreadyPaid != 0 ? "PPaid" : "Open";

                ControlObjectContext.SaveChanges();
                Common.InformUser(Page, "De vooruitbetaling is verwerkt. U kunt dit scherm nu sluiten.");
            }
        }
Пример #23
0
        protected void ButtonAddInvoiceLine_Click(object sender, EventArgs e)
        {
            StandardSaveHandler(sender, e, false);

            InvoiceLine il = new InvoiceLine();

            try
            {
                il.Invoice           = (DataItem as Invoice);
                il.LedgerBookingCode = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.LedgerBookingCodeSet", "Id", Guid.Parse(DropDownListFreeLineLedgerBookingCode.SelectedValue))) as LedgerBookingCode;
                il.Ledger            = il.Invoice.Ledger;
                il.Description       = TextBoxFreeLine.Text;
                il.OriginalPrice     = Convert.ToDouble(TextBoxFreeLinePrice.Text);
                il.VATPercentage     = Convert.ToDouble(TextBoxFreeLineVATPercentage.Text);

                il.Invoice.InvoiceLine.Add(il);
                il.LineNumber = il.Invoice.InvoiceLine.Count;

                il.Invoice.RecalcTotals();
            }
            catch { }

            try
            {
                ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);
            }
            catch (Exception ex)
            {
                Common.InformUserOnTransactionFail(ex, Page);
            }

            RebindControls();
            DataBind();

            TextBoxFreeLine.Text      = "";
            TextBoxFreeLinePrice.Text = "";
        }
Пример #24
0
        protected void GridViewOrderLines_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            e.Cancel = true;

            InvoiceLine TempLine;

            TempLine = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.InvoiceLineSet", "Id", Guid.Parse(e.Keys[0].ToString()))) as InvoiceLine;

            if (TempLine.Material != null)
            {
                Page.RegisterClientScriptBlock("Alert", "<script>alert('U mag deze regel niet verwijderen. Deze regel bevat een materiaal uit een order.');</script>");
            }
            else
            {
                (DataItem as Invoice).InvoiceLine.Remove(TempLine);
                ControlObjectContext.DeleteObject(TempLine);
                (DataItem as Invoice).RecalcTotals();

                ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);

                RebindControls();
                DataBind();
            }
        }
Пример #25
0
        protected void ButtonUpdate_Click(object sender, EventArgs e)
        {
            // update the availability in the combo box of this line
            Button      btn  = (sender as Button);
            GridViewRow gvr  = btn.Parent.Parent as GridViewRow;
            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;


            // grab the possible new enddate from the grid
            DateTime EndDateRent = ria.RentEndStartDateTime;

            try
            {
                EndDateRent = Convert.ToDateTime((gvr.Cells[4].Controls[1] as CalendarWithTimeControl).Text);
            }
            catch { }

            (gvr.Cells[4].Controls[1] as CalendarWithTimeControl).Text = EndDateRent.ToString();


            ObjectQuery Results = ControlObjectContext.CreateQuery <RentalItem>(MaterialAvailableQuery,
                                                                                new ObjectParameter("RentalType", ria.RentalItem.RentalType.Id),
                                                                                new ObjectParameter("LocationId", ria.RentLedger.Location.Id),
                                                                                new ObjectParameter("StartDate", ria.RentStartDateTime),
                                                                                new ObjectParameter("EndDate", EndDateRent),
                                                                                new ObjectParameter("BorderEndDate", new DateTime(2100, 1, 1)));

            // get the combobox to reload
            ComboBox cbx = (gvr.Cells[8].Controls[3] as ComboBox);

            LoadComboBox(cbx, Results);
        }
        public void CreateNewInvoice()
        {
            bool Success = false;

            // start transaction
            using (TransactionScope TS = new TransactionScope())
            {
                try
                {
                    Invoice inv = new Invoice();

                    ControlObjectContext.AddToInvoiceSet(inv);

                    foreach (GridViewRow gvr in GridViewSelectedRentOuts.Rows)
                    {
                        if ((gvr.Cells[0].Controls[1] as CheckBox).Checked)
                        {
                            String RentID = (gvr.Cells[0].Controls[1] as CheckBox).ToolTip;

                            RentalItemActivity ria = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.RentalItemActivitySet", "Id", new System.Guid(RentID))) as RentalItemActivity;

                            ria.AddRentToInvoice(ControlObjectContext, inv);
                            inv.Location = ria.RentLedger.Location;
                        }
                    }
                    inv.GenerateInvoiceNumber(ControlObjectContext);

                    inv.Relation = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.RelationSet", "Id", Guid.Parse(DropDownListCustomers.SelectedValue))) as Relation;

                    inv.Description     = TextBoxDescription.Text;
                    inv.InvoiceType     = "Sell";
                    inv.InvoiceSubType  = "Rent";
                    inv.BookingDateTime = Common.CurrentClientDateTime(Session);
                    inv.Ledger          = inv.Location.BankLedger;
                    try
                    {
                        inv.DiscountPercentage = Convert.ToDouble("0" + TextBoxInvoiceDiscount.Text);
                    }
                    catch {}

                    // add bail to the invoice
                    double Bail = Convert.ToDouble(TextBoxBail.Text); // except if this fails, this should be a valid number
                    if (Bail != 0)
                    {
                        InvoiceLine iline = new InvoiceLine();
                        iline.Description       = "Borg";
                        iline.OriginalPrice     = -Bail;
                        iline.AllowDiscount     = false;
                        iline.VATPercentage     = 0;
                        iline.VATPrice          = 0;
                        iline.TotalPrice        = -Bail;
                        iline.Invoice           = inv;
                        iline.LineNumber        = iline.Invoice.InvoiceLine.Count;
                        iline.LedgerBookingCode = iline.Invoice.Location.DefaultBailPriceBookingCode;
                    }


                    LabelGeneratedInvoiceNr.Text = inv.InvoiceNumber.ToString();
                    LabelGeneratedInvoiceId.Text = inv.Id.ToString();

                    if (LabelGroupId.Text == "")
                    {
                        LabelGroupId.Text = inv.GroupCode.ToString();
                    }

                    inv.GroupCode   = new Guid(LabelGroupId.Text);
                    inv.InvoiceNote = TextBoxInvoiceNote.Text;

                    // all invoice lines to the same ledger
                    inv.AllInvoiceLinesToSameLedger(inv.Ledger);
                    inv.RecalcTotals();

                    // save the data
                    ControlObjectContext.SaveChanges(System.Data.Objects.SaveOptions.DetectChangesBeforeSave);

                    // commit the transaciton
                    TS.Complete();

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

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

            if (!Success)
            {
                CurrentPageNr--;
                EnableCurrentPageElements();
            }
        }
Пример #27
0
        public void UpdateLocationVATPriceFromDropDown()
        {
            Location loc = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.LocationSet", "Id", new Guid(DropDownList_Location.SelectedValue))) as Location;

            TextBoxFreeLineVATPercentage.Text = loc.DefaultVATPercentage.ToString();
        }
        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);
                    }
                }
            }
        }