protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ComboBoxWeighingLocation.DataBind();
                ComboBoxCustomer.DataBind();

                // parse the FreightId and link this one up to that freight
                if (Request.Params["FreightId"] != null)
                {
                    //ModelTMSContainer ControlObjectContext = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);

                    CurrentWeighingId = new Guid(Request.Params["FreightId"].ToString());

                    Freight frg = Freight.SelectFreightByFreightId(CurrentWeighingId, ControlObjectContext);

                    if ((frg.FreightStatus == "In sorting") && (frg.FreightSortingMaterial.Count == 0))
                    {
                        // only create a new sorting form for an existing weighing if this weighing is "In sorting" and not filled in yet
                        PrepareOldWeighingForSorting();

                        // show form
                        CurrentPageNr = 2;
                    }
                    else
                    {
                        CurrentWeighingId = Guid.Empty;
                    }
                }

                Common.LimitLocationList(ComboBoxWeighingLocation.Items, Session, ControlObjectContext);
                ShowCorrectCustomer();
            }
        }
        protected void LoadFreightData(Freight frg)
        {
            RadioButtonListBuyOrSell.SelectedIndex = frg.FreightDirection == "To customer" ? 1 : 0;
            RadioButtonListBuyOrSell_SelectedIndexChanged(null, null);

            CalendarWithTimeControlDateTime1.SelectedDateTime = frg.FreightDateTime;
            TextBoxTotalNetWeight.Text = frg.TotalNetWeight.ToString();
            TextBoxPMV.Text            = frg.FirstFreightWeighingDescription();
            TextBoxCustomerPlate.Text  = frg.YourTruckPlate;
            TextBoxCustomerID.Text     = frg.YourDriverName;

            ComboBoxWeighingLocation.DataBind();
            ListItem li = ComboBoxWeighingLocation.Items.FindByValue(frg.SourceOrDestinationLocation.Id.ToString());

            if (li != null)
            {
                li.Selected = true;
            }

            ComboBoxCustomer.DataBind();
            li = ComboBoxCustomer.Items.FindByValue(frg.FromRelation.Id.ToString());
            if (li != null)
            {
                li.Selected = true;
            }

            ComboBoxOurPlate.DataBind();
            if (frg.OurTruck != null)
            {
                li = ComboBoxOurPlate.Items.FindByValue(frg.OurTruck.Id.ToString());
                if (li != null)
                {
                    li.Selected = true;
                }
            }
            //ComboBoxWeighingLocation = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.LocationSet", "Id", frg.SourceOrDestinationLocation )) as Location;
            //ComboBoxCustomer =  ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.RelationSet", "Id", frg.FromRelation.Id)) as Relation;
            //ComboBoxOurPlate = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.TruckSet", "Id", frg.OurTruck.Id)) as Truck;
        }
示例#3
0
        public void LoadFirstWeighingData(Freight frg)
        {
            DataBind();

            FreightWeighing         fgw = frg.FreightWeighing.First <FreightWeighing>();
            FreightWeighingMaterial fwm = fgw.FreightWeighingMaterial.First <FreightWeighingMaterial>();

            TextBoxOrderNumber.Text = frg.OurReference.ToString();
            TextBoxDescription.Text = frg.Description;

            if (frg.FreightDirection == "To warehouse")
            {
                RadioButtonListBuyOrSell.SelectedIndex = 0;
            }
            else
            {
                RadioButtonListBuyOrSell.SelectedIndex = 1;
            }
            SetCustomerType();

            ComboBoxWeighingLocation.DataBind();
            ListItem li = ComboBoxWeighingLocation.Items.FindByValue(frg.SourceOrDestinationLocation.Id.ToString());

            if (li != null)
            {
                li.Selected = true;
            }
            CalendarWithTimeControlDateTime1.SelectedDateTime = frg.FreightDateTime;

            TextBoxKey1.Text                = fgw.Key1;
            TextBoxGrossWeight.Text         = fgw.Weight1.ToString();
            CheckBoxIsDriverInTruck.Checked = fgw.IsDriverInTruck;
            TextBoxPMV.Text = fgw.Description;

            ComboBoxOurPlate.DataBind();
            if (frg.OurTruck != null)
            {
                li = ComboBoxOurPlate.Items.FindByValue(frg.OurTruck.Id.ToString());
                if (li != null)
                {
                    li.Selected = true;
                    ComboBoxOurPlate.SelectedIndex = ComboBoxOurPlate.Items.IndexOf(li);
                }
            }
            TextBoxCustomerPlate.Text = frg.YourTruckPlate;
            TextBoxCustomerID.Text    = frg.YourDriverName;

            ComboBoxCustomer.DataBind();
            li = ComboBoxCustomer.Items.FindByValue(frg.FromRelation.Id.ToString());
            if (li != null)
            {
                li.Selected = true;
            }
            LabelCustomerGuid.Text = frg.FromRelation.Id.ToString();

            ComboBoxProduct.DataBind();
            li = ComboBoxProduct.Items.FindByValue(fwm.Material.Id.ToString());
            if (li != null)
            {
                li.Selected = true;
            }

            CurrentWeighingId = frg.Id;

            // make sure the cash ledger of the current location is set
            SetCorrectLocationCashLedger();
        }
示例#4
0
        private void EnableCorrectScreenElements()
        {
            // disable all screen elements
            //PanelCustomerInformation.Visible = true;
            PanelFirstWeighing.Visible             = false;
            PanelFirstWeighingNr.Visible           = false;
            PanelInvoice.Visible                   = false;
            PanelSecondWeighing.Visible            = false;
            PanelSecondWeighingOrderNumber.Visible = false;
            PanelCustomerInformation.Enabled       = false;
            PanelFirstWeighing.Enabled             = false;
            PanelFirstWeighingNr.Enabled           = false;
            PanelInvoice.Enabled                   = false;
            PanelSecondWeighing.Enabled            = false;
            PanelSecondWeighingOrderNumber.Enabled = false;

            ButtonContinue.Visible        = false;
            ButtonDestroyAndBack.Visible  = false;
            ButtonInvoiceOrder.Visible    = false;
            ButtonNew.Visible             = false;
            ButtonPrintAndProcess.Visible = false;
            ButtonRevert.Visible          = false;
            ButtonSecondWeighing.Visible  = false;
            ButtonSortOrder.Visible       = false;

            URLPopUpControlLegalDocuments.Visible = false;

            if (CurrentPageNr == 9)
            {
                CurrentPageNr = 1;
            }
            if (CurrentPageNr == 19)
            {
                CurrentPageNr = 1;
            }

            if (CurrentPageNr == 12)
            {
                CurrentPageNr = 11;
            }                                                // error situation. Fix this way.
            if (CurrentPageNr > 23)
            {
                CurrentPageNr = 23;
            }                                               // error situation. Fix this way.

            switch (CurrentPageNr)
            // note : 1 is general, 10 series is for first weighing, 20 is for second weighing.
            {
            case 1:
                PanelCustomerInformation.Enabled = true;
                ButtonContinue.Visible           = true;
                break;

            case 10:
                PanelFirstWeighing.Visible = true;
                PanelFirstWeighing.Enabled = true;

                CalendarWithTimeControlDateTime1.SelectedDateTime = Common.CurrentClientDateTime(Session);

                ComboBoxWeighingLocation.DataBind();
                ComboBoxCustomer.DataBind();
                ShowCorrectCustomer();

                ButtonRevert.Visible          = PanelCustomerInformation.Visible;
                ButtonPrintAndProcess.Visible = true;
                break;

            case 11:
                if (Convert.ToInt64("0" + TextBoxGrossWeight.Text) <= 0)
                {
                    CurrentPageNr--;
                    EnableCorrectScreenElements();
                    Common.InformUser(Page, "Vul aub een positief gewicht in.");
                }
                else
                {
                    if (ProcessFirstWeighing())
                    {
                        PanelFirstWeighing.Visible   = true;
                        PanelFirstWeighing.Enabled   = true;
                        PanelFirstWeighingNr.Visible = true;

                        ButtonSecondWeighing.Visible = true;
                        //ButtonDestroyAndBack.Visible = true;
                        ButtonNew.Visible = true;

                        PanelInvoice.Visible                = true;
                        PanelInvoice.Enabled                = true;
                        FrameShowInvoiceB.Visible           = false;
                        FrameShowInvoiceA.Attributes["src"] = "WebFormPopup.aspx?UC=ShowReport&d=DataSetWeighing&r=ReportWeighingA4&Id=" + CurrentWeighingId.ToString();

                        URLPopUpControlLegalDocuments.URLToPopup = "webformpopup.aspx?UC=FreightLegalDocuments&FreightId=" + CurrentWeighingId.ToString();
                        URLPopUpControlLegalDocuments.Visible    = true;
                    }
                    else
                    {
                        CurrentPageNr--;
                        EnableCorrectScreenElements();
                    }
                }
                break;

            case 20:
                PanelSecondWeighingOrderNumber.Visible = true;
                PanelSecondWeighingOrderNumber.Enabled = true;
                LabelWeighingLoaded.Text = "";

                ButtonRevert.Visible   = true;
                ButtonContinue.Visible = true;
                break;

            case 21:
                // load freight
                Freight frg = Freight.SelectFreightByFreightNr(Convert.ToInt64(TextBoxOrderNumber.Text), new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session));

                if (frg != null)
                {
                    if (LabelWeighingLoaded.Text == "")
                    {
                        LoadFirstWeighingData(frg); LabelWeighingLoaded.Text = "x";
                    }

                    PanelSecondWeighingOrderNumber.Visible = true;
                    PanelFirstWeighing.Visible             = true;
                    PanelFirstWeighing.Enabled             = true;
                    PanelSecondWeighing.Visible            = true;

                    CalendarWithTimeControl2.SelectedDateTime = Common.CurrentClientDateTime(Session);

                    ButtonRevert.Visible   = true;
                    ButtonContinue.Visible = true;

                    if (frg.FreightStatus != "2nd weighing")
                    {
                        Common.InformUser(Page, "Deze weging heeft niet de juiste status voor het invoeren van een tweede weging. U kunt deze gegevens wel invoeren als u het zeker weet.");
                    }
                }
                else
                {
                    CurrentPageNr--;
                    EnableCorrectScreenElements();
                    if (frg == null)
                    {
                        Common.InformUser(Page, "Geef aub een correct vrachtnummer op.");
                    }
                    else
                    {
                        Common.InformUser(Page, "Het opgegeven vrachtnummer is correct, maar deze vracht is al verder verwerkt. Een tweede weging opgeven kan maar één keer.");
                    }
                }
                break;

            case 22:
                PanelSecondWeighingOrderNumber.Visible = true;
                PanelFirstWeighing.Visible             = true;
                PanelSecondWeighing.Visible            = true;
                PanelSecondWeighing.Enabled            = true;

                SetCustomerType();

                ButtonRevert.Visible          = true;
                ButtonPrintAndProcess.Visible = true;
                break;

            case 23:
                if (Convert.ToInt64("0" + TextBoxGrossWeight.Text) <= Convert.ToInt64("0" + TextBoxWeight2.Text))
                {
                    CurrentPageNr--;
                    EnableCorrectScreenElements();
                    Common.InformUser(Page, "Vul aub een gewicht in wat kleiner is dan de eerste weging.");
                }
                else
                {
                    if (ProcessSecondWeighing())
                    {
                        PanelSecondWeighingOrderNumber.Visible = true;
                        PanelFirstWeighing.Visible             = true;
                        PanelSecondWeighing.Visible            = true;
                        PanelInvoice.Visible = true;
                        PanelInvoice.Enabled = true;

                        ButtonNew.Visible = true;
                        //ButtonDestroyAndBack.Visible = true;

                        ButtonSortOrder.Visible    = CheckBoxWeighingActionSort.Checked;
                        ButtonInvoiceOrder.Visible = CheckBoxWeighingActionInvoice.Checked;

                        FrameShowInvoiceB.Visible = CheckBoxWeighingActionPay.Checked;

                        FrameShowInvoiceA.Attributes["src"] = "WebFormPopup.aspx?UC=ShowReport&d=DataSetWeighing&r=ReportWeighingA4&Id=" + CurrentWeighingId.ToString();
                        if (FrameShowInvoiceB.Visible)
                        {
                            FrameShowInvoiceB.Attributes["src"] = "WebFormPopup.aspx?UC=ShowReport&d=DataSetInvoice&r=ReportInvoiceA4&Id=" + LabelGeneratedInvoiceId.Text.ToString();
                        }

                        URLPopUpControlLegalDocuments.URLToPopup = "webformpopup.aspx?UC=FreightLegalDocuments&FreightId=" + CurrentWeighingId.ToString();
                        URLPopUpControlLegalDocuments.Visible    = true;
                    }
                    else
                    {
                        CurrentPageNr--;
                        EnableCorrectScreenElements();
                    }
                }
                break;
            }
        }
        private void EnableCorrectScreenElements()
        {
            string InvoiceType = "";

            PanelSecondWeighingOrderNumber.Visible = true;
            PanelSecondWeighingOrderNumber.Enabled = false;
            PanelBasicData.Visible = false;
            PanelBasicData.Enabled = false;
            PanelMaterials.Visible = false;
            PanelMaterials.Enabled = false;
            PanelTotals.Visible    = false;
            PanelTotals.Enabled    = false;
            PanelInvoice.Visible   = false;
            PanelInvoice.Enabled   = false;

            ButtonContinue.Visible              = false;
            ButtonDestroyAndBack.Visible        = false;
            ButtonInvoiceOrder.Visible          = false;
            ButtonNew.Visible                   = false;
            ButtonPrintAndProcess.Visible       = false;
            ButtonProcessAndCashInvoice.Visible = false;
            ButtonRevert.Visible                = false;

            URLPopUpControlShowSorting.Visible = false;
            LabelWeightWarning.Visible         = false;

            switch (CurrentPageNr)
            {
            case 1:
                PanelSecondWeighingOrderNumber.Enabled = true;
                ButtonContinue.Visible = true;
                break;

            case 2:
                ButtonContinue.Visible = true;
                ButtonRevert.Visible   = true;

                PanelBasicData.Visible = true;
                PanelBasicData.Enabled = true;

                // get the data from the already registered weighing
                if (Convert.ToInt32(LabelPreviousPageNr.Text) < CurrentPageNr)
                {
                    if ((!CheckBoxNewSorting.Checked))
                    {
                        bool Success = false;
                        try
                        {
                            long    FreightNr = Convert.ToInt64(TextBoxOrderNumber.Text);
                            Freight frg       = Freight.SelectFreightByFreightNr(FreightNr, new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session));
                            if (frg != null)
                            {
                                LoadFreightData(frg);
                                CurrentWeighingId = frg.Id;
                                Success           = true;

                                if (RadioButtonListBuyOrSell.SelectedIndex == 0)
                                {
                                    InvoiceType = "Buy";
                                }
                                else
                                {
                                    InvoiceType = "Sell";
                                }

                                URLPopUpControlShowSorting.URLToPopup = "WebFormPopup.aspx?UC=ShowReport&d=DataSetSorting&r=ReportSortingA4&Id=" + CurrentWeighingId.ToString() + "&InvoiceType=" + InvoiceType;
                            }
                            else
                            {
                                Common.InformUser(Page, "Geef aub een geldig nummer op voor de sorteerbon die nog niet verder is verwerkt.");
                            }
                        }
                        catch { }

                        if (!Success)
                        {
                            CurrentPageNr--;
                            EnableCorrectScreenElements();
                        }
                    }
                    else
                    {
                        ComboBoxWeighingLocation.DataBind();
                        ComboBoxOurPlate.DataBind();
                        ComboBoxCustomer.DataBind();
                        CalendarWithTimeControlDateTime1.SelectedDateTime = Common.CurrentClientDateTime(Session);
                        TextBoxTotalNetWeight.Text = "0";
                        ShowCorrectCustomer();
                    }
                }
                break;

            case 3:
                ButtonContinue.Visible = true;
                ButtonRevert.Visible   = true;

                PanelBasicData.Visible = true;
                PanelMaterials.Enabled = true;
                PanelMaterials.Visible = true;

                // load materials from the sorting into the xml data source
                InitSortingMaterials();

                break;

            case 4:
                PanelBasicData.Visible = true;
                PanelMaterials.Visible = true;
                PanelTotals.Visible    = true;
                PanelTotals.Enabled    = true;

                // save in XML
                LoadSortingMaterials();    // load them in the freightsortingmaterial lines
                SaveSortingMaterials();    // save them in the screen & freightsortingmaterial lines

                // calc total weights
                double TotalWeightInLines = Convert.ToDouble(LabelTotalWeightInOrder.Text);
                double TotalWeightInOrder = 0;
                try { TotalWeightInOrder = Convert.ToDouble(TextBoxTotalNetWeight.Text); } catch { TotalWeightInOrder = 0.1; };
                LabelWeightWarning.Visible = TotalWeightInOrder < TotalWeightInLines;

                if (LabelWeightWarning.Visible)
                {
                    Common.InformUser(Page, LabelWeightWarning.Text);
                }

                ButtonContinue.Visible = true;
                ButtonRevert.Visible   = true;
                ButtonProcessAndCashInvoice.Visible = true;
                break;

            case 5:
                PanelBasicData.Visible = true;
                PanelMaterials.Visible = true;
                PanelTotals.Visible    = true;
                PanelInvoice.Visible   = true;
                PanelInvoice.Enabled   = true;

                // store the sorted materials which are relevant with the weighing
                LoadSortingMaterials();
                if (StoreSorting())
                {
                    // if storing was successfull then show the sorting slip
                    if (RadioButtonListBuyOrSell.SelectedIndex == 0)
                    {
                        InvoiceType = "Buy";
                    }
                    else
                    {
                        InvoiceType = "Sell";
                    }
                    FrameShowInvoice.Attributes["src"] = "WebFormPopup.aspx?UC=ShowReport&d=DataSetSorting&r=ReportSortingA4&Id=" + CurrentWeighingId.ToString() + "&InvoiceType=" + InvoiceType;

                    ButtonDestroyAndBack.Visible = true;
                    ButtonInvoiceOrder.Visible   = true;
                    ButtonNew.Visible            = true;
                }
                else
                {
                    CurrentPageNr--;
                    EnableCorrectScreenElements();
                }
                break;
            }
        }