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;
            }
        }
Beispiel #2
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()
        {
            WebUserControlCashPurchase1.Visible    = false;
            WebUserControlNonCashPurchase1.Visible = false;

            PanelSecondWeighingOrderNumber.Visible = true;
            PanelSecondWeighingOrderNumber.Enabled = false;
            PanelInvoiceInformation.Visible        = false;
            PanelInvoiceInformation.Enabled        = false;

            ButtonContinue.Visible = false;
            ButtonRevert.Visible   = false;

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

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

                // check if this is a valid freight number
                bool Success = false;
                try
                {
                    long    FreightNr = Convert.ToInt64(TextBoxOrderNumber.Text);
                    Freight frg       = Freight.SelectFreightByFreightNr(FreightNr, new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session));
                    if (frg != null)
                    {
                        CurrentWeighingId = frg.Id;
                        Success           = true;

                        string InvoiceType = "";
                        if (frg.FreightDirection == "To warehouse")
                        {
                            InvoiceType = "Buy";
                        }
                        else
                        {
                            InvoiceType = "Sell";
                        }

                        URLPopUpControlShowSorting.URLToPopup = "WebFormPopup.aspx?UC=ShowReport&d=DataSetSorting&r=ReportSortingA4&Id=" + CurrentWeighingId.ToString() + "&InvoiceType=" + InvoiceType;

                        if (frg.FreightStatus != "To be invoiced")
                        {
                            Common.InformUser(Page, "Deze vracht is nog niet uitgezocht of al gefactureerd. U kunt deze vracht nogmaals factureren. Deze wordt dan nogmaals op een factuur geplaatst.");
                        }
                    }
                    else
                    {
                        Common.InformUser(Page, "Geef aub een geldig nummer op voor de sorteerbon die nog niet verder is verwerkt.");
                    }
                }
                catch { }

                if (!Success)
                {
                    CurrentPageNr--;
                    EnableCorrectScreenElements();
                }

                break;

            case 3:
                PanelInvoiceInformation.Visible = true;

                switch (RadioButtonListInvoiceType.SelectedIndex)
                {
                case 0:
                    WebUserControlCashPurchase1.Visible = true;
                    WebUserControlCashPurchase1.LoadFromFreight(Freight.SelectFreightByFreightId(CurrentWeighingId, new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session)), false);
                    break;

                case 1:
                    WebUserControlNonCashPurchase1.Visible = true;
                    WebUserControlNonCashPurchase1.LoadFromFreight(Freight.SelectFreightByFreightId(CurrentWeighingId, new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session)), false);
                    break;
                }

                break;
            }
        }