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;
        }
Example #2
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();
        }
        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;
            }
        }