예제 #1
0
        protected void ButtonCloneOrder_Click(object sender, EventArgs e)
        {
            // start transaction
            using (TransactionScope TS = new TransactionScope())
            {
                try
                {
                    // clone order
                    Order NewOrder = (DataItem as Order).CloneToNew(ControlObjectContext, false, null, Common.CurrentClientDateTime(Session));

                    ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);

                    // commit the transaciton
                    TS.Complete();

                    // inform user
                    Page.RegisterClientScriptBlock("Alert", "<script>alert('De order is gekloond. De order wordt nu geopend.');</script>");

                    Response.Redirect("~\\WebFormPurchaseLedger.aspx?OrderNumber=" + NewOrder.OrderNumber.ToString(), false);
                }
                catch (Exception ex)
                {
                    // rollback
                    TS.Dispose();

                    // inform user
                    Common.InformUserOnTransactionFail(ex, Page);
                }
            }
        }
예제 #2
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 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 ButtonAddMaterial_Click(object sender, EventArgs e)
        {
            OrderLine NewLine = new OrderLine();
            Material  MatItem;
            RelationPriceAgreement   PAItem;
            RelationContractMaterial ContractItem;

            DetermineCurrentSelectedMaterial(out MatItem, out PAItem, out ContractItem);

            NewLine.Order = (DataItem as Order);
            try
            {
                NewLine.PricePerUnit             = Convert.ToDouble(TextBoxPrice.Text);
                NewLine.Amount                   = Convert.ToDouble(TextBoxAmount.Text);
                NewLine.Material                 = MatItem;
                NewLine.Description              = MatItem.Description;
                NewLine.RelationPriceAgreement   = PAItem;
                NewLine.RelationContractMaterial = ContractItem;
                ControlObjectContext.AddToOrderLineSet(NewLine);

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

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

            DataBind();
        }
예제 #5
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();
        }
        private void ProcessPayment(Boolean IsCorrection)
        {
            // start transaction
            using (TransactionScope TS = new TransactionScope())
            {
                // process payment
                try
                {
                    ClassCustomBinding.BindToObject("ModelTMSContainer." + SetName + "Set", KeyID, Controls, DataItem, ControlObjectContext);

                    if (!IsCorrection)
                    {
                        (DataItem as RelationAdvancePayment).PayOut(ControlObjectContext, Common.CurrentClientDateTime(Session));
                    }
                    else
                    {
                        (DataItem as RelationAdvancePayment).PayBack(ControlObjectContext, Common.CurrentClientDateTime(Session));
                    }
                    ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);

                    // commit transaction
                    TS.Complete();
                }
                catch (Exception ex)
                {
                    // rollback transaction
                    TS.Dispose();

                    // inform user
                    Common.InformUserOnTransactionFail(ex, Page);
                }
            }
        }
예제 #7
0
        protected Boolean StandardSaveHandler(object sender, EventArgs e, bool ExecuteSaveChanges)
        {
            Boolean result = false;

            try
            {
                SaveDataIntoDataItemFromControls();

                if (ExecuteSaveChanges)
                {
                    ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);
                }

                result = true;
            }
            catch (ControlArgumentException ex)
            {
                Page.RegisterClientScriptBlock("Alert", "<script>alert('Het opslaan van de gegevens is mislukt. Corrigeer de waarde in het veld waar de cursor staat.');</script>");
                ex.CausingControl.Focus();
            }
            catch (Exception ex)
            {
                // inform user
                Common.InformUserOnTransactionFail(ex, Page);

                KeyID = KeyID;
            }
            return(result);
        }
예제 #8
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;
        }
예제 #9
0
        protected void ButtonCorrectInvoice_Click(object sender, EventArgs e)
        {
            // correct invoice, the user may decide whether or not to create a new invoice with these orders
            // start transaction
            using (TransactionScope TS = new TransactionScope())
            {
                try
                {
                    // process order
                    (DataItem as Invoice).UnprocessInvoice(ControlObjectContext, (DataItem as Invoice).GroupCode, Common.CurrentClientDateTime(Session));
                    (DataItem as Invoice).IsCorrected = true;

                    ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);

                    // commit the transaciton
                    TS.Complete();

                    // inform user
                    Page.RegisterClientScriptBlock("Alert", "<script>alert('De factuur en eventueel bijbehordende orders zijn volledig tegengeboekt. U kunt de factuur opnieuw aanmaken.');</script>");
                }
                catch (Exception ex)
                {
                    // rollback
                    TS.Dispose();

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

            RebindControls();
            DataBind();
        }
예제 #10
0
        protected void ButtonCreateClonedInvoiceAndOrders_Click(object sender, EventArgs e)
        {
            // start transaction
            using (TransactionScope TS = new TransactionScope())
            {
                try
                {
                    // clone order
                    Invoice NewInvoice = (DataItem as Invoice).CloneToNew(ControlObjectContext, false, null, Common.CurrentClientDateTime(Session));

                    ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);

                    Response.Redirect(Request.AppRelativeCurrentExecutionFilePath + "?InvoiceNumber=" + NewInvoice.InvoiceNumber.ToString(), false);

                    // commit the transaciton
                    TS.Complete();

                    // inform user
                    Common.InformUser(Page, "De factuur en eventueel bijbehordende orders zijn gekloond. De factuur wordt nu geopend.");
                }
                catch (Exception ex)
                {
                    // rollback
                    TS.Dispose();

                    // inform user
                    Common.InformUserOnTransactionFail(ex, Page);
                }
            }
        }
        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;
        }
예제 #12
0
        protected bool UnstoreSorting()
        {
            Freight frg = null;

            bool Success = false;

            // start transaction
            using (TransactionScope TS = new TransactionScope())
            {
                try
                {
                    frg = Freight.SelectFreightByFreightId(CurrentWeighingId, ControlObjectContext);
                    frg.FreightStatus = "In sorting";

                    // 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);
        }
예제 #13
0
        protected void ButtonResetAvgSalesPrice_Click(object sender, EventArgs e)
        {
            Material Mat = (DataItem as Material);

            Mat.AvgSalesPriceTotalPrice  = 0;
            Mat.AvgSalesPriceTotalWeight = 0;
            Mat.AvgSalesPrice            = 0;
            ControlObjectContext.SaveChanges();
            RebindControls();
        }
        protected void ButtonProcess_Click(object sender, EventArgs e)
        {
            Double MatPrice = 0, MatAmount = 0;

            try
            {
                MatPrice  = Convert.ToDouble(TextBoxPrice.Text);
                MatAmount = Convert.ToDouble(TextBoxAmount.Text);
            }
            catch
            {
            }

            if ((MatPrice.ToString() != TextBoxPrice.Text) || (MatAmount.ToString() != TextBoxAmount.Text))
            {
                Common.InformUser(Page, "De opgegeven getallen voor prijs en hoeveelheid kunnen niet worden herkend. Corrigeer deze naar de juiste waarde.");
                TextBoxPrice.Text  = MatPrice.ToString();
                TextBoxAmount.Text = MatAmount.ToString();
            }
            else
            {
                // process this as a Material Mutation
                MaterialMutation mt = new MaterialMutation();

                mt.Material     = (DataItem as Material);
                mt.Description  = "CORR / Correctie voorraad " + mt.Material.Description + " dd " + mt.CreateDateTime.ToString();
                mt.MutationType = RadioButtonListBuyOrSell.SelectedValue;
                mt.Amount       = MatAmount;
                mt.PricePerUnit = MatPrice;
                mt.TotalPrice   = MatPrice * mt.Amount;
                mt.GenerateMutationNumber(ControlObjectContext);

                if (mt.MutationType == "Sell")
                {
                    mt.Amount = -mt.Amount; // sales are always a negative amount
                }

                mt.RecalcTotals();
                mt.ProcessToStockLevel(false); // do not update average prices
                mt.ProcessToLedgerMutation(ControlObjectContext);

                if (mt.MutationType == "Sell")
                {
                    mt.TotalPrice = MatPrice * mt.Amount; // sales are stored as a negative price so that the total calculation will be correct on the daily closure
                }

                ControlObjectContext.AddToMaterialMutationSet(mt);
                ControlObjectContext.SaveChanges();
                Common.InformUser(Page, "Deze mutatie is succesvol doorgevoerd. U kunt dit popup scherm nu sluiten of nog een mutatie op dit materiaal doorvoeren.");
            }
        }
예제 #15
0
        protected void GridViewOrders_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "UnlinkOrder")
            {
                if (GridViewOrderLines.Enabled)
                {
                    int Row         = Convert.ToInt32(e.CommandArgument);
                    int OrderNumber = Convert.ToInt32(GridViewOrders.Rows[Row].Cells[1].Text);

                    // load order
                    string Query = "SELECT VALUE it FROM OrderSet as it WHERE it.OrderNumber = @OrderNumber";
                    ObjectQuery <Order> query = new ObjectQuery <Order>(Query, ControlObjectContext);
                    query.Parameters.Add(new ObjectParameter("OrderNumber", OrderNumber));
                    ObjectResult <Order> ilines = query.Execute(MergeOption.AppendOnly);

                    Order TempOrder = ilines.First <Order>();

                    // start transaction
                    using (TransactionScope TS = new TransactionScope())
                    {
                        try
                        {
                            TempOrder.Invoice.RemoveOrderFromInvoice(ControlObjectContext, TempOrder);

                            // commit the transaciton
                            ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);
                            TS.Complete();

                            // inform user
                            Common.InformUser(Page, "De order is van de factuur ontkoppeld. De orderregels zijn van deze factuur verwijderd. U dient deze order nogmaals op ean factuur te plaatsen.");
                        }
                        catch (Exception ex)
                        {
                            // rollback
                            TS.Dispose();

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

                    // reload data in the interface
                    DataBind();
                    RebindControls();
                }
                else
                {
                    Common.InformUser(Page, "Deze order kan niet worden ontkoppeld. De factuur is reeds verwerkt.");
                }
            }
        }
예제 #16
0
 protected void ButtonUploadMembershipsLogo_Click(object sender, EventArgs e)
 {
     try
     {
         (DataItem as Location).CompanyMembershipsLogo = Common.ConvertImageToByteArray(
             System.Drawing.Image.FromStream(FileUploadMembershipsLogo.PostedFile.InputStream),
             System.Drawing.Imaging.ImageFormat.Png);
         ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);
     }
     catch (Exception ex)
     {
         Common.InformUserOnGeneralFail(ex, Page, "Het opslaan van de afbeelding is mislukt.");
     }
 }
예제 #17
0
        protected Boolean StandardButtonDeleteClickMethod(object sender, EventArgs e)
        {
            Boolean result = false;

            // check if this object may be deleted
            Boolean AllowDel = AllowDelete();

            // if this object may not be deleted then warn about this
            if (!AllowDel)
            {
                Page.RegisterClientScriptBlock("Alert", "<script>alert('Dit gegeven kan niet worden verwijderd omdat dit elders in het systeem wordt gebruikt. Deactiveer het object ipv het te verwijderen.');</script>");
            }
            else // else delete this object
            {
                RefreshRequired = true; //request a refresh from the container

                try
                {
                    ControlObjectContext.DeleteObject(DataItem);

                    ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);

                    result = true;

                    Page.RegisterClientScriptBlock("Alert", "<script>alert('De gegevens zijn succesvol verwijderd.');</script>");
                }
                catch (ControlArgumentException ex)
                {
                    string tempStr = ex.Message.Replace("'", "\"").Replace("\n", "").Replace("\r", "");
                    Page.RegisterClientScriptBlock("Alert", "<script>alert('Het verwijderen van de gegevens is mislukt. Mogelijk heeft een andere medewerker dit gegeven al verwijderd. (" + tempStr + ")');</script>");
                }
                catch (Exception ex)
                {
                    string tempStr = "";
                    if (ex.InnerException == null)
                    {
                        tempStr = ex.Message.Replace("'", "\"").Replace("\n", "").Replace("\r", "");
                    }
                    else
                    {
                        tempStr = ex.Message + " / " + ex.InnerException.ToString();
                        tempStr = tempStr.Replace("'", "\"").Replace("\n", "").Replace("\r", "");
                    }
                    Page.RegisterClientScriptBlock("Alert", "<script>alert('Het opslaan van de gegevens is mislukt omdat iemand anders de gegevens al heeft verwijderd of omdat er nog relaties zijn naar ander informatie die niet meer verwijderd kunnen worden. Probeer het nogmaals. (" + tempStr + ")');</script>");
                    KeyID = KeyID;
                }
            }

            return(result);
        }
예제 #18
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();
                Ledger         lb = (DataItem as Ledger);

                lm.Description  = "CORR / Correctie " + lb.Description;
                lm.IsCorrection = true;
                lm.BookingType  = RadioButtonListBuyOrSell.SelectedValue;
                lm.Ledger       = lb;

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

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

                lm.Process(ControlObjectContext);

                // store the correction amount as negated number so the book closures will function properly for Buy mutations as well
                if (lm.BookingType == "Buy")
                {
                    CorrectionAmount = -CorrectionAmount;
                }

                ControlObjectContext.SaveChanges();

                Common.InformUser(Page, "U heeft de mutatie succesvol doorgevoerd. U kunt deze popup nu sluiten of nog een mutatie doorvoeren.");
            }
        }
예제 #19
0
        protected void URLPopUpControlAddSaleCustomer_OnBeforePopUpOpened(object sender, EventArgs e)
        {
            SaveDataIntoDataItemFromControls();

            // create a new ledger and show this as a popup
            Relation NewRel = new Relation();

            NewRel.CustomerType = "Debtor";

            ControlObjectContext.AddToRelationSet(NewRel);
            ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);

            URLPopUpControlAddSaleCustomer.URLToPopup = "webformpopup.aspx?uc=CustomerRelation&Id=" + NewRel.Id.ToString();
        }
예제 #20
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();
        }
예제 #21
0
        protected void URLPopUpControlAddBankLedgerForThisLocation_OnBeforePopUpOpened(object sender, EventArgs e)
        {
            SaveDataIntoDataItemFromControls();

            // create a new ledger and show this as a popup
            Ledger NewMat = new Ledger();

            NewMat.LedgerType                 = "Bank";
            NewMat.LimitToLocation            = DataItem as Location;
            NewMat.LimitToLocation.BankLedger = NewMat;

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

            URLPopUpControlAddBankLedgerForThisLocation.URLToPopup = "webformpopup.aspx?uc=LedgerBase&Id=" + NewMat.Id.ToString();
        }
예제 #22
0
 void Page_PreRender(object sender, EventArgs e)
 {
     if (DataItem != null)
     {
         SecurityRole sr = (DataItem as SecurityRole);
         if ((LabelRoleID.Text != sr.Id.ToString()) || (GridViewRoleObjectAccess.Rows.Count == 0))
         {
             // the role ID has changed. Check the SecurityRole
             LabelIDResultSet.Text = ""; // clear the ID cache
             sr.CheckSecurityRolObjectAccess(ControlObjectContext);
             ControlObjectContext.SaveChanges();
             LabelRoleID.Text = sr.Id.ToString();
             GridViewRoleObjectAccess.DataBind();
         }
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            SetName = "Freight";

            if (!IsPostBack)
            {
                Common.AddFreightOurRoleTypeList(ComboBox_TransportRole_SelectedValue.Items, true);
                Common.AddFreightTransportNotificationTransportType(ComboBox_TransportNotificationTransportType_SelectedValue.Items, true);
                Common.AddFreightTransportNotificationRemovalType(ComboBox_TransportNotificationRemovalType_SelectedValue.Items, true);
                Common.AddWrappingTypeList(ComboBox_TransportWrapping_SelectedValue.Items, true);
                Common.AddDCodeList(ComboBox_TransportDRCode_SelectedValue.Items, true, true);
                Common.AddRCodeList(ComboBox_TransportDRCode_SelectedValue.Items, false, false);
                Common.AddDCodeList(ComboBox_TransportDestructionAction_SelectedValue.Items, true, true);
                Common.AddRCodeList(ComboBox_TransportDestructionAction_SelectedValue.Items, false, false);
                Common.AddTransportTypeList(ComboBox_TransportType_SelectedValue.Items, true);

                if (Request.Params["FreightId"] != null)
                {
                    KeyID = new Guid(Request.Params["FreightId"]);
                }

                Freight frg = DataItem as Freight;

                // check if this freight has to be initialised
                if (frg != null)
                {
                    LabelCustomerType.Text = frg.FreightDirection == "To warehouse" ? "Creditor" : "Debtor";
                    EntityDataSourceCustomers.DataBind();

                    if ((frg.TransportSourceCustomer == null) && (frg.TransportDestinationCustomer == null))
                    {
                        // initialise freight
                        frg.TransportSourceCustomer         = frg.FreightDirection == "To warehouse" ? frg.FromRelation : null;
                        frg.TransportUltimateSourceCustomer = frg.TransportSourceCustomer;
                        frg.TransportCompanyCustomer        = null;
                        frg.TransportDestinationCustomer    = frg.FreightDirection == "To warehouse" ? null : frg.FromRelation;
                        frg.TransportDestructorCustomer     = frg.TransportDestinationCustomer;
                        ControlObjectContext.SaveChanges();
                    }

                    RebindControls();
                }
            }
        }
        protected void ButtonNew_Click(object sender, EventArgs e)
        {
            // create new empty invoice
            Invoice NewInvoice = new Invoice();

            NewInvoice.GenerateInvoiceNumber(ControlObjectContext);
            NewInvoice.Description    = "Factuur " + NewInvoice.InvoiceNumber.ToString() + " dd " + NewInvoice.BookingDateTime.ToString();
            NewInvoice.InvoiceType    = LabelInvoiceType.Text;
            NewInvoice.InvoiceSubType = LabelSubInvoiceType.Text;
            NewInvoice.Ledger         = ControlObjectContext.LedgerSet.First();

            ControlObjectContext.AddToInvoiceSet(NewInvoice);

            // save
            ControlObjectContext.SaveChanges();

            // show
            ShowSelectedInvoice(NewInvoice.Id.ToString());
        }
예제 #25
0
        protected void URLPopUpControlAddMaterialForThisLocation_OnBeforePopUpOpened(object sender, EventArgs e)
        {
            SaveDataIntoDataItemFromControls();

            // create a new ledger and show this as a popup
            Material NewMat = new Material();

            NewMat.MaterialUnit = ControlObjectContext.MaterialUnitSet.First();
            NewMat.PurchaseLedgerBookingCode = ControlObjectContext.LedgerBookingCodeSet.First();;
            NewMat.SalesLedgerBookingCode    = ControlObjectContext.LedgerBookingCodeSet.First();;
            NewMat.Category                 = "Other";
            NewMat.VATPercentage            = 19;
            NewMat.Location                 = DataItem as Location;
            NewMat.Location.MaterialForDirt = NewMat;

            ControlObjectContext.AddToMaterialSet(NewMat);
            ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);

            URLPopUpControlAddMaterialForThisLocation.URLToPopup = "webformpopup.aspx?uc=StockMaterial&Id=" + NewMat.Id.ToString();
        }
        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.");
            }
        }
예제 #27
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 = "";
        }
예제 #28
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();
            }
        }
예제 #29
0
        protected void ButtonToProcessed_Click(object sender, EventArgs e)
        {
            // start transaction
            using (TransactionScope TS = new TransactionScope())
            {
                try
                {
                    // first save this information
                    if (StandardSaveHandler(sender, e, false))
                    {
                        // process order
                        (DataItem as Invoice).ProcessInvoice(ControlObjectContext, (DataItem as Invoice).GroupCode, true, Common.CurrentClientDateTime(Session));

                        ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);

                        // commit the transaciton
                        TS.Complete();
                    }
                    else
                    {
                        TS.Dispose();
                    }
                }
                catch (Exception ex)
                {
                    // rollback
                    TS.Dispose();

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

            RebindControls();
            DataBind();
        }
        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();
            }
        }