Beispiel #1
0
        public void SaveSecondWeighingData(Freight frg, ModelTMSContainer ControlObjectContext)
        {
            FreightWeighing         fgw = frg.FreightWeighing.First <FreightWeighing>();
            FreightWeighingMaterial fwm = fgw.FreightWeighingMaterial.First <FreightWeighingMaterial>();

            fgw.WeighingDateTime2 = CalendarWithTimeControl2.SelectedDateTime;
            fgw.Key2 = TextBoxKey2.Text;
            try { fgw.Weight2 = Convert.ToDouble("0" + TextBoxWeight2.Text); }  catch { };
            fwm.TarraWeight    = fgw.Weight2;
            fwm.NetWeight      = fwm.GrossWeight - fwm.TarraWeight;
            frg.TotalNetWeight = fwm.NetWeight;
            frg.Description    = TextBoxDescription.Text;
            frg.Comments       = TextBoxComments.Text;
            frg.FreightStatus  = "Done";

            frg.RecalcTotalWeightFromWeighing();

            if (CheckBoxWeighingActionSort.Checked)
            {
                frg.FreightStatus = "In sorting";
            }
            if (CheckBoxWeighingActionInvoice.Checked)
            {
                frg.FreightStatus = "To be invoiced";
            }
        }
Beispiel #2
0
        protected bool ProcessFirstWeighing()
        {
            ModelTMSContainer ControlObjectContext = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);
            bool Success = false;

            // start transaction
            using (TransactionScope TS = new TransactionScope())
            {
                try
                {
                    // process freight
                    // setup base objects
                    Freight                 frg  = new Freight();
                    FreightWeighing         frgw = new FreightWeighing();
                    FreightWeighingMaterial frgm = new FreightWeighingMaterial();
                    frg.FreightWeighing.Add(frgw);
                    frgw.FreightWeighingMaterial.Add(frgm);

                    ControlObjectContext.AddToFreightSet(frg);

                    // save the first weighing data in the freight
                    SaveFirstWeighingData(frg, ControlObjectContext);

                    // assign the weighing number
                    frg.AssignFreightNumber(ControlObjectContext);
                    LabelFreightNr.Text = frg.OurReference.ToString();
                    CurrentWeighingId   = frg.Id;
                    frg.Description     = "Weegbon " + frg.OurReference + " / " + Common.CurrentClientDateTime(Session).ToString();
                    frg.FreightType     = "Weighing";

                    // 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);

                    // reset the weighing id when not saved
                    CurrentWeighingId = Guid.Empty;
                }
            }

            if (Success)
            {
                // when success advance panel
                CurrentPageNr++;
            }
            return(Success);
        }
Beispiel #3
0
        public void SaveFirstWeighingData(Freight frg, ModelTMSContainer ControlObjectContext)
        {
            FreightWeighing         fgw = frg.FreightWeighing.First <FreightWeighing>();
            FreightWeighingMaterial fwm = fgw.FreightWeighingMaterial.First <FreightWeighingMaterial>();

            frg.FreightDirection = "To warehouse";
            if (RadioButtonListBuyOrSell.SelectedIndex == 1)
            {
                frg.FreightDirection = "To customer";
            }
            frg.SourceOrDestinationLocation = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.LocationSet", "Id", Guid.Parse(ComboBoxWeighingLocation.SelectedValue))) as Location;
            frg.FreightDateTime             = CalendarWithTimeControlDateTime1.SelectedDateTime;
            frg.FreightStatus = "2nd weighing";

            fgw.Key1 = TextBoxKey1.Text;
            try { fgw.Weight1 = Convert.ToDouble(TextBoxGrossWeight.Text); }  catch { };
            fgw.IsDriverInTruck   = CheckBoxIsDriverInTruck.Checked;
            fgw.WeighingDateTime1 = frg.FreightDateTime;
            fgw.Description       = TextBoxPMV.Text;

            frg.OurTruck = null;
            if (ComboBoxOurPlate.SelectedValue != "")
            {
                frg.OurTruck = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.TruckSet", "Id", Guid.Parse(ComboBoxOurPlate.SelectedValue))) as Truck;
            }

            frg.YourTruckPlate = TextBoxCustomerPlate.Text;
            frg.YourDriverName = TextBoxCustomerID.Text;

            frg.FromRelation       = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.RelationSet", "Id", Guid.Parse(ComboBoxCustomer.SelectedValue))) as Relation;
            LabelCustomerGuid.Text = frg.FromRelation.Id.ToString();

            fwm.GrossWeight = fgw.Weight1;
            fwm.Material    = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.MaterialSet", "Id", Guid.Parse(ComboBoxProduct.SelectedValue))) as Material;
            fwm.Description = fwm.Material.Description;
        }
        public void LoadFromFreight(Freight frg, bool ForceReload)
        {
            if ((LabelFreightGuid.Text != frg.Id.ToString()) || ForceReload)
            {
                ListItem        li  = null;
                FreightWeighing fgw = null;
                if (frg.FreightWeighing.Count > 0)
                {
                    fgw = frg.FreightWeighing.First <FreightWeighing>();
                }

                LabelOrderNr.Text        = frg.OurReference.ToString();
                TextBox_Description.Text = frg.Description;

                if (frg.FreightDirection == "To warehouse")
                {
                    // switch to purchase order
                    SwitchPurchaseType(InvoiceType.Buy);
                }
                else
                {
                    // switch to sales order
                    SwitchPurchaseType(InvoiceType.Sell);
                }

                // first load the customer, this is required for Freights
                DropDownListCustomers.DataBind();
                li = DropDownListCustomers.Items.FindByValue(frg.FromRelation.Id.ToString());
                if (li != null)
                {
                    li.Selected      = true;
                    LabelCustID.Text = li.Value;
                }

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

                DropDownListCustomerFreights.DataBind();
                li = DropDownListCustomerFreights.Items.FindByValue(frg.Id.ToString());
                if (li != null)
                {
                    li.Selected = true;
                    DropDownListCustomerFreights.SelectedIndex = DropDownListCustomerFreights.Items.IndexOf(li);
                }

                TextBox_YourTruckPlate.Text = frg.YourTruckPlate;
                TextBox_YourDriverName.Text = frg.YourDriverName;

                if (fgw != null)
                {
                    TextBoxFreightID.Text = fgw.Description;
                }

                WebUserControlEditOrderMaterials1.LoadFromFreight(frg);

                LabelFreightGuid.Text = frg.Id.ToString();
            }
        }
Beispiel #5
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();
        }