コード例 #1
0
        private Entities.FacadeResult SubContractSpecificLegs(Entities.JobSubContractor jobSubContractor, DateTime lastUpdateDateTime, string userID)
        {
            Facade.IJobSubContractor facJobSubContractor = new Facade.Job();

            if (!m_isUpdate)
            {
                List <int> instructionIDs = new List <int>();
                foreach (GridItem gdi in grdLegs.SelectedItems)
                {
                    int instructionID = int.Parse(gdi.OwnerTableView.DataKeyValues[gdi.ItemIndex]["InstructionID"].ToString());
                    instructionIDs.Add(instructionID);
                }

                if (chkUseSubContractorTrailer.Checked)
                {
                    return(facJobSubContractor.Create(m_jobId, instructionIDs, new List <int>(), jobSubContractor, lastUpdateDateTime, userID, chkForceRemoveResources.Checked));
                }
                else
                {
                    return(facJobSubContractor.Create(m_jobId, instructionIDs, new List <int>(), jobSubContractor, int.Parse(cboTrailer.SelectedValue), lastUpdateDateTime, userID, chkForceRemoveResources.Checked));
                }
            }
            else
            {
                return(GenerateValidationError("UnableToUpdate", "Unable to update sub-contracted information in this way"));
            }
        }
コード例 #2
0
        protected void repOrderSubbyRates_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView       drv                     = e.Item.DataItem as DataRowView;
                Repeater          repReferences           = e.Item.FindControl("repReferences") as Repeater;
                Repeater          repOrderSubbyRates      = sender as Repeater;
                DataTable         referenceData           = (repOrderSubbyRates.DataSource as DataSet).Tables[1];
                RadNumericTextBox rntSubContractRate      = e.Item.FindControl("rntSubContractRate") as RadNumericTextBox;
                TextBox           txtSubcontractReference = e.Item.FindControl("txtSubcontractReference") as TextBox;
                CheckBox          chkIsAttended           = e.Item.FindControl("chkIsAttended") as CheckBox;

                if (drv["SubbyForeignRate"] != DBNull.Value)
                {
                    rntSubContractRate.Text = ((decimal)drv["SubbyForeignRate"]).ToString();

                    bool canBeChanged = (bool)drv["CanBeChanged"];
                    rntSubContractRate.Enabled      = canBeChanged;
                    txtSubcontractReference.Enabled = canBeChanged;
                    chkIsAttended.Enabled           = canBeChanged;
                }
                else
                {
                    rntSubContractRate.Text = (new decimal(0)).ToString();
                }

                int            orderID        = int.Parse(drv["OrderID"].ToString());
                DataRow[]      references     = referenceData.Select("OrderID = " + orderID.ToString());
                List <DataRow> listReferences = new List <DataRow>(references);

                // Add the customer order number and delivery order number!
                DataRow deliveryOrderNumber = referenceData.NewRow();
                deliveryOrderNumber["OrderID"]     = orderID;
                deliveryOrderNumber["Description"] = "Delivery Order Number";
                deliveryOrderNumber["Reference"]   = drv["DeliveryOrderNumber"].ToString();
                listReferences.Insert(0, deliveryOrderNumber);
                DataRow customerOrderNumber = referenceData.NewRow();
                customerOrderNumber["OrderID"]     = orderID;
                customerOrderNumber["Description"] = "Customer Order Number";
                customerOrderNumber["Reference"]   = drv["CustomerOrderNumber"].ToString();
                listReferences.Insert(0, customerOrderNumber);

                int jobSubContractID = (int)drv["JobSubContractID"];
                Facade.IJobSubContractor  facJobSubContractor = new Facade.Job();
                Entities.JobSubContractor jobSubContract      = facJobSubContractor.GetSubContractorForJobSubContractId(jobSubContractID);
                rntSubContractRate.Culture = new CultureInfo(jobSubContract.LCID);

                if (jobSubContractID > 0)
                {
                    txtSubcontractReference.Text = drv["Reference"].ToString();
                    chkIsAttended.Checked        = bool.Parse(drv["IsAttended"].ToString());
                }

                repReferences.DataSource = listReferences;
                repReferences.DataBind();
            }
        }
コード例 #3
0
        void repLegSubbyRates_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView       drv = e.Item.DataItem as DataRowView;
                RadNumericTextBox rntSubContractRate      = e.Item.FindControl("rntSubContractRate") as RadNumericTextBox;
                HtmlTableRow      rowSubbedOrders         = e.Item.FindControl("rowSubbedOrders") as HtmlTableRow;
                Repeater          repOrderSubbyRates      = e.Item.FindControl("repOrderSubbyRates") as Repeater;
                TextBox           txtSubcontractReference = e.Item.FindControl("txtSubcontractReference") as TextBox;
                CheckBox          chkIsAttended           = e.Item.FindControl("chkIsAttended") as CheckBox;

                if (drv["JobSubContractID"] == DBNull.Value)
                {
                    rntSubContractRate.Visible      = false;
                    chkIsAttended.Visible           = false;
                    txtSubcontractReference.Visible = false;
                    rowSubbedOrders.Visible         = true;
                    Facade.IOrder facOrder = new Facade.Order();
                    repOrderSubbyRates.DataSource = facOrder.GetSubbedOrdersForInstructionID((int)drv["InstructionId"]);
                    repOrderSubbyRates.DataBind();
                }
                else
                {
                    rntSubContractRate.Visible      = true;
                    txtSubcontractReference.Visible = true;
                    chkIsAttended.Visible           = true;
                    rowSubbedOrders.Visible         = false;
                    repOrderSubbyRates.Visible      = false;

                    rntSubContractRate.Text = ((decimal)drv["SubbyForeignRateForLeg"]).ToString();

                    int jobSubContractID = (int)drv["JobSubContractID"];
                    Facade.IJobSubContractor facJobSubContractor = new Facade.Job();

                    if (jobSubContractID > 0)
                    {
                        txtSubcontractReference.Text = drv["Reference"].ToString();
                        chkIsAttended.Checked        = bool.Parse(drv["IsAttended"].ToString());
                    }

                    // If the rate isn't editabel then the Reference and IsAttended flag isn't editable either.
                    bool rateEditable = facJobSubContractor.IsRateEditable(jobSubContractID);
                    rntSubContractRate.Enabled = rateEditable;
                    txtReference.Enabled       = rateEditable;
                    chkIsAttended.Enabled      = rateEditable;

                    Entities.JobSubContractor jobSubContract = facJobSubContractor.GetSubContractorForJobSubContractId(jobSubContractID);
                    rntSubContractRate.Culture = new CultureInfo(jobSubContract.LCID);
                }
            }
        }
コード例 #4
0
        public bool UpdatePalletForceOrder(PalletForceOrder inputOrder, string userName)
        {
            foreach (Surcharge surcharge in inputOrder.Surcharges)
            {
                if (surcharge.IsSelected)
                {
                    AddSurcharge(inputOrder, surcharge.ExtraTypeID, userName);
                }
                else
                {
                    RemoveSurcharge(inputOrder, surcharge.ExtraTypeID, userName);
                }
            }

            Orchestrator.EF.DataContext DB = Orchestrator.EF.DataContext.Current;
            var order     = DB.OrderSet.Include("JobSubContract").FirstOrDefault(o => o.OrderId == inputOrder.OrderID);
            var vigoOrder = DB.VigoOrderSet.FirstOrDefault(o => o.OrderId == inputOrder.OrderID);
            List <Orchestrator.EF.VigoOrderExtra> surcharges = DB.VigoOrderExtraSet.Where(o => o.VigoOrder.OrderId == inputOrder.OrderID).ToList();

            // Update the Order
            order.NoPallets        = (int)inputOrder.NoPallets;
            order.PalletSpaces     = inputOrder.PalletSpaces;
            order.Weight           = inputOrder.Weight;
            order.LastUpdateUserID = userName;



            // Update the Vigo Order
            vigoOrder.FullPallets = inputOrder.FullPallets;
            vigoOrder.QtrPallets  = inputOrder.QtrPallets;
            vigoOrder.HalfPallets = inputOrder.HalfPallets;
            vigoOrder.OverPallets = inputOrder.OverPallets;


            // Update the Extras


            DB.SaveChanges();

            Facade.IJobSubContractor jobSubContractor = new Facade.Job();
            if (order != null && order.JobSubContract.JobSubContractID > 0)
            {
                Entities.JobSubContractor js = jobSubContractor.GetSubContractorForJobSubContractId(order.JobSubContract.JobSubContractID);
                jobSubContractor.UpdateSubContractorCostsForOrders(new List <int>()
                {
                    order.OrderId
                }, js, userName);
            }
            return(true);
        }
コード例 #5
0
        private Entities.FacadeResult SubContractWholeJob(Entities.JobSubContractor jobSubContractor, DateTime lastUpdateDateTime, string userID)
        {
            Facade.IJobSubContractor facJobSubContractor = new Facade.Job();

            if (m_isUpdate)
            {
                return(facJobSubContractor.Update(m_jobId, jobSubContractor, lastUpdateDateTime, userID));
            }
            else
            {
                if (chkUseSubContractorTrailer.Checked)
                {
                    return(facJobSubContractor.Create(m_jobId, new List <int>(), new List <int>(), jobSubContractor, lastUpdateDateTime, userID, chkForceRemoveResources.Checked));
                }
                else
                {
                    return(facJobSubContractor.Create(m_jobId, new List <int>(), new List <int>(), jobSubContractor, int.Parse(cboTrailer.SelectedValue), lastUpdateDateTime, userID, chkForceRemoveResources.Checked));
                }
            }
        }
コード例 #6
0
        private Entities.FacadeResult SubContractPerOrder(Entities.JobSubContractor jobSubContractor, DateTime lastUpdateDateTime, string userID)
        {
            Facade.IJobSubContractor facJobSubContractor = new Facade.Job();

            if (!m_isUpdate)
            {
                List <int> instructionIDs = new List <int>();
                List <int> orderIDs       = new List <int>();
                foreach (GridItem gdi in grdLegs.SelectedItems)
                {
                    Label lblOrderIDs = (Label)gdi.FindControl("lblOrderIDs");
                    if (lblOrderIDs.Text == string.Empty)
                    {
                        int instructionID = int.Parse(gdi.OwnerTableView.DataKeyValues[gdi.ItemIndex]["InstructionID"].ToString());
                        instructionIDs.Add(instructionID);
                    }
                    else
                    {
                        string[] split       = new string[] { ", " };
                        string[] arrOrderIDs = lblOrderIDs.Text.Split(split, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string orderID in arrOrderIDs)
                        {
                            orderIDs.Add(int.Parse(orderID));
                        }
                    }
                }

                if (chkUseSubContractorTrailer.Checked)
                {
                    return(facJobSubContractor.Create(m_jobId, instructionIDs, orderIDs, jobSubContractor, lastUpdateDateTime, userID, chkForceRemoveResources.Checked));
                }
                else
                {
                    return(facJobSubContractor.Create(m_jobId, instructionIDs, orderIDs, jobSubContractor, int.Parse(cboTrailer.SelectedValue), lastUpdateDateTime, userID, chkForceRemoveResources.Checked));
                }
            }
            else
            {
                return(GenerateValidationError("UnableToUpdate", "Unable to update sub-contracted information in this way"));
            }
        }
コード例 #7
0
        Entities.JobSubContractor GetJobSubContract(Entities.Instruction selected)
        {
            Facade.IExchangeRates facER = new Facade.ExchangeRates();
            decimal rate = Decimal.Parse(rntSubContractRate.Text, System.Globalization.NumberStyles.Currency);

            Entities.JobSubContractor jobSubContract = new Entities.JobSubContractor(int.Parse(cboSubContractor.SelectedValue), rate, chkUseSubContractorTrailer.Checked);
            jobSubContract.LCID = rntSubContractRate.Culture.LCID;

            CultureInfo culture = new CultureInfo(Orchestrator.Globals.Configuration.NativeCulture);

            if (jobSubContract.LCID != culture.LCID) // Default
            {
                jobSubContract.ExchangeRateID = facER.GetCurrentExchangeRateID(Facade.Culture.GetCurrencySymbol(jobSubContract.LCID), selected.PlannedArrivalDateTime);
                jobSubContract.Rate           = facER.GetConvertedRate((int)jobSubContract.ExchangeRateID, jobSubContract.ForeignRate);
            }
            else
            {
                jobSubContract.Rate = decimal.Round(jobSubContract.ForeignRate, 4, MidpointRounding.AwayFromZero);
            }

            return(jobSubContract);
        }
コード例 #8
0
        //-----------------------------------------------------------------------------------------------------------



        //-----------------------------------------------------------------------------------------------------------

        protected void grdOrders_UpdateCommand(object source, GridCommandEventArgs e)
        {
            GridEditableItem editedItem = e.Item as GridEditableItem;
            int orderId = 0;

            if (!String.IsNullOrEmpty(editedItem.GetDataKeyValue("OrderId").ToString()))
            {
                orderId = Convert.ToInt32(editedItem.GetDataKeyValue("OrderId").ToString());
            }

            if (orderId > 0)
            {
                RadNumericTextBox txtNoPallets    = (RadNumericTextBox)e.Item.FindControl("txtNoPallets");
                RadNumericTextBox txtPalletSpaces = (RadNumericTextBox)e.Item.FindControl("txtPalletSpaces");
                RadNumericTextBox txtWeight       = (RadNumericTextBox)e.Item.FindControl("txtWeight");
                RadNumericTextBox txtQtrPallets   = (RadNumericTextBox)e.Item.FindControl("txtQtrPallets");
                RadNumericTextBox txtHalfPallets  = (RadNumericTextBox)e.Item.FindControl("txtHalfPallets");
                RadNumericTextBox txtFullPallets  = (RadNumericTextBox)e.Item.FindControl("txtFullPallets");
                RadNumericTextBox txtOverPallets  = (RadNumericTextBox)e.Item.FindControl("txtOverPallets");

                Orchestrator.EF.DataContext context   = new Orchestrator.EF.DataContext();
                Orchestrator.EF.VigoOrder   vigoOrder = context.VigoOrderSet.FirstOrDefault(vo => vo.OrderId == orderId);

                vigoOrder.QtrPallets  = Convert.ToInt32(txtQtrPallets.Value);
                vigoOrder.HalfPallets = Convert.ToInt32(txtHalfPallets.Value);
                vigoOrder.FullPallets = Convert.ToInt32(txtFullPallets.Value);
                vigoOrder.OverPallets = Convert.ToInt32(txtOverPallets.Value);

                vigoOrder.LastUpdateDate   = DateTime.Now;
                vigoOrder.LastUpdateUserId = Page.User.Identity.Name;

                context.SaveChanges(true);

                //Orchestrator.EF.RateInformation rateInformation = null;

                Facade.IOrder facOrder            = new Facade.Order();
                Orchestrator.Entities.Order order = facOrder.GetForOrderID(orderId);

                order.NoPallets    = Convert.ToInt32(txtNoPallets.Value);
                order.PalletSpaces = Convert.ToDecimal(txtPalletSpaces.Value);
                order.Weight       = Convert.ToDecimal(txtWeight.Value);

                order.LastUpdatedDateTime = DateTime.Now;
                order.LastUpdatedBy       = Page.User.Identity.Name;


                facOrder.Update(order, Page.User.Identity.Name);

                // We need to make sure the subcontractor (Palletforce) costs are re-rated
                Facade.IJobSubContractor jobSubContractor = new Facade.Job();
                if (order != null && order.JobSubContractID > 0)
                {
                    Entities.JobSubContractor js = jobSubContractor.GetSubContractorForJobSubContractId(order.JobSubContractID);
                    jobSubContractor.UpdateSubContractorCostsForOrders(new List <int>()
                    {
                        order.OrderID
                    }, js, this.Page.User.Identity.Name);
                }


                CheckBoxList        cblSurcharge = e.Item.FindControl("cblSurcharges") as CheckBoxList;
                List <EF.ExtraType> extraTypes   = context.ExtraTypeSet.Select(et => et).ToList();

                List <int> selectedExtraTypeIds = new List <int>();
                foreach (ListItem item in cblSurcharge.Items)
                {
                    if (item.Selected)
                    {
                        selectedExtraTypeIds.Add(int.Parse(item.Value));
                    }
                }

                //Remove the selected extras which are already present
                foreach (var extra in vigoOrder.VigoOrderExtras)
                {
                    selectedExtraTypeIds.Remove(extra.ExtraType.ExtraTypeId);
                }

                //Now add Extras for the selected extras remaining
                foreach (int extraTypeId in selectedExtraTypeIds)
                {
                    var vigoOrderExtra = new EF.VigoOrderExtra();
                    vigoOrderExtra.ExtraType = extraTypes.First(et => et.ExtraTypeId == extraTypeId); //new EntityKey("DataContext.ExtraTypeSet", "ExtraTypeId", extraTypeId);
                    vigoOrder.VigoOrderExtras.Add(vigoOrderExtra);
                }


                context.SaveChanges();

                //this.grdOrders.DataSource = null;
                //this.grdOrders.Rebind();
            }
        }
コード例 #9
0
        private void DisplayOrder(Orchestrator.Entities.Order order)
        {
            Orchestrator.Facade.IOrganisation  facOrg     = new Orchestrator.Facade.Organisation();
            Orchestrator.Facade.IPoint         facPoint   = new Orchestrator.Facade.Point();
            Orchestrator.Facade.IReferenceData facRefData = new Orchestrator.Facade.ReferenceData();
            Orchestrator.Facade.IPOD           facPOD     = new Orchestrator.Facade.POD();

            Orchestrator.Facade.IOrder facOrd = new Orchestrator.Facade.Order();
            order.ClientInvoiceID = facOrd.ClientInvoiceID(OrderID);
            Orchestrator.Facade.Organisation facOrgD = new Orchestrator.Facade.Organisation();

            Orchestrator.Entities.Point collectionPoint    = facPoint.GetPointForPointId(order.CollectionPointID);
            Orchestrator.Entities.Point deliveryPoint      = facPoint.GetPointForPointId(order.DeliveryPointID);
            Orchestrator.Entities.POD   scannedPOD         = facPOD.GetForOrderID(order.OrderID);
            Orchestrator.Entities.Scan  scannedBookingForm = null;

            CurrentCulture = new CultureInfo(order.LCID);
            ExchangeRateID = order.ExchangeRateID;

            lblOrderHeading.Text = string.Format("Order {0}", order.OrderID);

            this.lblOrderStatus.Text = order.OrderStatus.ToString();

            if (((Entities.CustomPrincipal) this.Page.User).IsInRole(((int)eUserRole.SubConPortal).ToString()))
            {
                this.btnPIL.Visible = false;
                this.btnCreateDeliveryNote.Visible  = false;
                this.btnCreateDeliveryNote2.Visible = false;
                this.btnPIL2.Visible = false;
                plcBooking.Visible   = false;

                plcPOD.Visible = false;

                // get cost for subby and display as rate. (The rate the subby is being paid)
                Facade.IJobSubContractor jobSubContractor = new Facade.Job();
                if (order != null && order.JobSubContractID > 0)
                {
                    Entities.JobSubContractor js = jobSubContractor.GetSubContractorForJobSubContractId(order.JobSubContractID);
                    CultureInfo subbyCulture     = new CultureInfo(js.LCID);

                    if (Orchestrator.Globals.Configuration.MultiCurrency)
                    {
                        this.lblRate.Text = string.Format(rateTemplate, js.ForeignRate.ToString("C", subbyCulture), js.Rate.ToString("C"));
                    }
                    else
                    {
                        this.lblRate.Text = js.Rate.ToString("C", subbyCulture);
                    }
                }

                this.tblSubbyRate.Visible = true;
                this.trRate.Visible       = false;
                this.trInvoiceId.Visible  = false;
            }
            else
            {
                this.tblSubbyRate.Visible = false;
                //If the order has a scanned Booking Form get it so that
                //a link to it can be displayed
                if (order.BookingFormScannedFormId != null)
                {
                    Orchestrator.Facade.Form facBF = new Orchestrator.Facade.Form();
                    scannedBookingForm = facBF.GetForScannedFormId(order.BookingFormScannedFormId.Value);
                }

                //this.lblOrderID.Text = order.OrderID.ToString();
                this.lblOrderStatus.Text = order.OrderStatus.ToString().Replace("_", " ");

                if (scannedBookingForm != null)
                {
                    hlBookingFormLink.Visible     = true;
                    hlBookingFormLink.NavigateUrl = scannedBookingForm.ScannedFormPDF.Trim();

                    aScanBookingForm.InnerHtml = "| Re-Scan";
                    aScanBookingForm.HRef      = @"javascript:ReDoBookingForm(" + scannedBookingForm.ScannedFormId + "," + order.OrderID.ToString() + ");";
                }
                else
                {
                    hlBookingFormLink.Visible  = false;
                    aScanBookingForm.InnerHtml = "Scan";
                    aScanBookingForm.HRef      = @"javascript:NewBookingForm(" + order.OrderID.ToString() + ");";
                }

                plcPOD.Visible = false;

                if (Orchestrator.Globals.Configuration.MultiCurrency)
                {
                    this.lblRate.Text = string.Format(rateTemplate, order.ForeignRate.ToString("C", CurrentCulture), order.Rate.ToString("C"));
                }
                else
                {
                    this.lblRate.Text = order.ForeignRate.ToString("C", CurrentCulture);
                }

                trRate.Visible = !order.IsInGroup;

                if (order.ClientInvoiceID <= 0)
                {
                    lblInvoiceNumber.Text = "None Assigned";
                }
                else
                {
                    lblInvoiceNumber.Text = order.ClientInvoiceID.ToString();
                    string PDFLink = order.PDFLocation.ToString();
                    lblInvoiceNumber.NavigateUrl = Orchestrator.Globals.Configuration.WebServer + PDFLink;
                }
            }
            this.lblLoadNumber.Text      = order.CustomerOrderNumber;
            this.lblDeliveryOrderNo.Text = order.DeliveryOrderNumber;

            this.lblCollectionPoint.Text = collectionPoint.Address.ToString();
            this.lblDeliverTo.Text       = deliveryPoint.Address.ToString();

            this.lblCollectDateTime.Text  = (order.CollectionIsAnytime == true ? (order.CollectionDateTime.ToString("dd/MM/yy") + " AnyTime") : (order.CollectionDateTime.ToString("dd/MM/yy HH:mm")));
            this.lblDeliveryDateTime.Text = (order.DeliveryIsAnytime == true ? (order.DeliveryDateTime.ToString("dd/MM/yy") + " AnyTime") : (order.DeliveryDateTime.ToString("dd/MM/yy HH:mm"))) + order.DeliveryAnnotation;

            this.lblPallets.Text      = order.NoPallets.ToString() + " " + Orchestrator.Facade.PalletType.GetForPalletTypeId(order.PalletTypeID).Description;
            this.lblPalletSpaces.Text = order.PalletSpaces.ToString("0.##");
            this.lblGoodsType.Text    = Orchestrator.Facade.GoodsType.GetForGoodsTypeId(order.GoodsTypeID).Description;
            this.lblWeight.Text       = Convert.ToInt32(order.Weight).ToString() + " " + Orchestrator.Facade.WeightType.GetForWeightTypeId(order.WeightTypeID).ShortCode;

            this.repReferences.DataSource = order.OrderReferences;
            this.repReferences.DataBind();

            this.lblCartons.Text = order.Cases.ToString();

            if (order.Notes == null || order.Notes.Length == 0)
            {
                this.lblNotes.Text = "&#160;";
            }
            else
            {
                this.lblNotes.Text = order.Notes;
            }

            if (order.CreateDateTime != DateTime.MinValue)
            {
                lblCreated.Text = order.CreatedBy + " on " + order.CreateDateTime.ToString("dd/MM/yy HH:mm");
            }
            lblOrderServiceLevel.Text = order.OrderServiceLevel;

            if (order.BusinessTypeID > 0)
            {
                Orchestrator.Facade.IBusinessType  facBusinessType = new Orchestrator.Facade.BusinessType();
                Orchestrator.Entities.BusinessType businessType    = facBusinessType.GetForBusinessTypeID(order.BusinessTypeID);
                lblBusinessType.Text = businessType.Description;
            }
            else
            {
                lblBusinessType.Text = "Not Set";
            }

            plcCancellation.Visible = order.OrderStatus == eOrderStatus.Cancelled;
            if (order.OrderStatus == eOrderStatus.Cancelled)
            {
                lblCancellationReason.Text = order.CancellationReason;
                lblCancelledBy.Text        = order.CancelledBy;
                lblCancelledAt.Text        = order.CancelledAt.ToString("dd/MM/yy HH:mm");
            }
        }
コード例 #10
0
        void gvPreInvoices_ItemCommand(object source, GridCommandEventArgs e)
        {
            string userName = ((Entities.CustomPrincipal)Page.User).UserName;

            switch (e.CommandName.ToLower())
            {
                #region Client Reference Editing

            case "cancelclientreference":
                e.Item.Edit = false;
                gvPreInvoices.Rebind();
                break;

            case "editclientreference":
                e.Item.Edit = true;
                gvPreInvoices.Rebind();
                break;

            case "editpurchaseorderreference":
                e.Item.Edit = true;
                gvPreInvoices.Rebind();
                break;

            case "updateclientreference":
                e.Item.Edit = false;
                string clientReference = string.Empty;

                LinkButton lnkChangeClientReference = e.Item.FindControl("lnkChangeClientReference") as LinkButton;
                TextBox    txtClientReference       = e.Item.FindControl("txtClientReference") as TextBox;

                if (lnkChangeClientReference != null && txtClientReference != null)
                {
                    string oldClientReference = lnkChangeClientReference.Text;
                    clientReference = txtClientReference.Text;

                    // Only apply the change if the client reference has been altered
                    if (oldClientReference != clientReference)
                    {
                        // Update the client reference
                        int preInvoiceID = int.Parse(((GridDataItem)e.Item).GetDataKeyValue("PreInvoiceID").ToString());
                        Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();
                        facPreInvoice.UpdateClientInvoiceReference(preInvoiceID, clientReference, userName);
                    }
                }
                gvPreInvoices.Rebind();
                break;

            case "updatepurchaseorderreference":
                e.Item.Edit = false;
                string purchaseOrderReference = string.Empty;

                LinkButton lnkChangePurchaseOrderReference = e.Item.FindControl("lnkChangePurchaseOrderReference") as LinkButton;
                TextBox    txtPurchaseOrderReference       = e.Item.FindControl("txtPurchaseOrderReference") as TextBox;

                if (lnkChangePurchaseOrderReference != null && txtPurchaseOrderReference != null)
                {
                    string oldPurchaseOrderReference = lnkChangePurchaseOrderReference.Text;
                    purchaseOrderReference = txtPurchaseOrderReference.Text;

                    // Only apply the change if the client reference has been altered
                    if (oldPurchaseOrderReference != purchaseOrderReference)
                    {
                        // Update the client reference
                        int preInvoiceID = int.Parse(((GridDataItem)e.Item).GetDataKeyValue("PreInvoiceID").ToString());
                        Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();
                        facPreInvoice.UpdatePurchaseOrderReference(preInvoiceID, purchaseOrderReference, userName);
                    }
                }
                gvPreInvoices.Rebind();
                break;

                #endregion

                #region Rate Editing

            //case "cancelrate":
            //    e.Item.Edit = false;
            //    e.Item.OwnerTableView.Rebind();
            //    gvPreInvoices.MasterTableView.Rebind();
            //    StayOpen = e.Item.OwnerTableView.ParentItem.ItemIndex;
            //    break;
            //case "editrate":
            //    e.Item.Edit = true;
            //    e.Item.OwnerTableView.Rebind();
            //    gvPreInvoices.MasterTableView.Rebind();
            //    StayOpen = e.Item.OwnerTableView.ParentItem.ItemIndex;
            //    break;
            case "update":     // update rate and pallet spaces.
                e.Item.Edit = false;
                decimal rate = 0;

                //LinkButton lnkChangeRate = e.Item.FindControl("lnkChangeRate") as LinkButton;
                HiddenField  hidOldRate = e.Item.FindControl("hidOldRate") as HiddenField;
                TextBox      txtRate    = e.Item.FindControl("txtRate") as TextBox;
                GridDataItem parentItem = e.Item.OwnerTableView.ParentItem;

                int         lcid = int.Parse(parentItem.GetDataKeyValue("LCID").ToString());
                CultureInfo preInvoiceCulture = new CultureInfo(lcid);

                if (Decimal.TryParse(txtRate.Text, System.Globalization.NumberStyles.Currency, preInvoiceCulture, out rate))
                {
                    decimal oldRate = 0;
                    oldRate = decimal.Parse(hidOldRate.Value);

                    // Only apply the rate change if the rate has altered.
                    if (oldRate != rate)
                    {
                        int itemID = int.Parse(txtRate.Attributes["ItemID"]);

                        // Update the rate (depends on item type - depends on invoice type)
                        int          preInvoiceID = int.Parse(parentItem.GetDataKeyValue("PreInvoiceID").ToString());
                        eInvoiceType invoiceType  = (eInvoiceType)int.Parse(parentItem.GetDataKeyValue("InvoiceTypeID").ToString());
                        CultureInfo  culture      = new CultureInfo(Orchestrator.Globals.Configuration.NativeCulture);

                        Facade.IPreInvoice    facPreInvoice = new Facade.PreInvoice();
                        Facade.IExchangeRates facER         = new Facade.ExchangeRates();

                        switch (invoiceType)
                        {
                        case eInvoiceType.ClientInvoicing:
                            Facade.IOrder  facOrder = new Facade.Order();
                            Entities.Order order    = facOrder.GetForOrderID(itemID);
                            order.ForeignRate = rate;

                            if (order.LCID != culture.LCID)
                            {
                                BusinessLogicLayer.IExchangeRates    blER = new BusinessLogicLayer.ExchangeRates();
                                BusinessLogicLayer.CurrencyConverter currencyConverter = blER.CreateCurrencyConverter(order.LCID, order.CollectionDateTime);
                                order.Rate = currencyConverter.ConvertToLocal(order.ForeignRate);
                            }
                            else
                            {
                                order.Rate = decimal.Round(order.ForeignRate, 4, MidpointRounding.AwayFromZero);
                            }

                            //if (order.OrderGroupID > 0)
                            //facPreInvoice.UpdateOrderGroupRate(preInvoiceID, order.OrderGroupID, order.ForeignRate, order.Rate, userName);
                            //else

                            facPreInvoice.UpdateOrderRate(preInvoiceID, itemID, order.ForeignRate, order.Rate, userName);

                            break;

                        case eInvoiceType.SubContractorSelfBill:
                        case eInvoiceType.SubContract:
                            // Needs to be Amended For Currency : TL 12/05/08;
                            Facade.IJobSubContractor  facJSC           = new Facade.Job();
                            Entities.JobSubContractor jobSubContractor = facJSC.GetSubContractorForJobSubContractId(itemID);
                            jobSubContractor.ForeignRate = rate;

                            if (jobSubContractor.LCID != culture.LCID)
                            {
                                jobSubContractor.Rate = facER.GetConvertedRate((int)jobSubContractor.ExchangeRateID, jobSubContractor.ForeignRate);
                            }
                            else
                            {
                                jobSubContractor.Rate = decimal.Round(jobSubContractor.ForeignRate, 4, MidpointRounding.AwayFromZero);
                            }

                            facPreInvoice.UpdateJobSubContractRate(preInvoiceID, itemID, jobSubContractor.ForeignRate, jobSubContractor.Rate, jobSubContractor.ExchangeRateID, userName);
                            break;

                        default:
                            throw new NotSupportedException("You can not alter item rates on invoices of type " + invoiceType.ToString());
                        }

                        this.lblSavedMessage.Text = string.Format("Your changes were saved at {0}", DateTime.Now.ToLongTimeString());
                    }
                }

                e.Item.OwnerTableView.Rebind();
                gvPreInvoices.MasterTableView.Rebind();
                StayOpen = parentItem.ItemIndex;
                break;

                #endregion
            }
        }
コード例 #11
0
        private void SaveBatchChanges()
        {
            string userName = ((Entities.CustomPrincipal)Page.User).UserName;

            // React to the user's options.
            foreach (GridDataItem row in gvPreInvoices.Items)
            {
                string tableName    = row.OwnerTableView.Name;
                int    preInvoiceId = -1;
                int.TryParse(row.GetDataKeyValue("PreInvoiceID").ToString(), out preInvoiceId);

                if (tableName == PreInvoiceTableName && (row.ItemType == GridItemType.Item || row.ItemType == GridItemType.AlternatingItem))
                {
                    HiddenField hidIsDirty = row.FindControl("hidIsDirty") as HiddenField;
                    bool        isDirty    = false;

                    if (bool.TryParse(hidIsDirty.Value, out isDirty) && isDirty)
                    {
                        #region Update PreInvoice
                        DateTime?invoiceDate = null;
                        string   clientReference = string.Empty, purchaseOrderReference = string.Empty;
                        int      taxRateID = -1;

                        RadDateInput rdiInvoiceDate = row.FindControl("rdiInvoiceDate") as RadDateInput;

                        RadTextBox rtClientReference        = row.FindControl("rtClientReference") as RadTextBox;
                        RadTextBox rtPurchaseOrderReference = row.FindControl("rtPurchaseOrderReference") as RadTextBox;

                        DropDownList cboTaxRate = row.FindControl("cboTaxRate") as DropDownList;

                        if (rdiInvoiceDate.SelectedDate.HasValue)
                        {
                            invoiceDate = rdiInvoiceDate.SelectedDate.Value;
                        }

                        clientReference        = rtClientReference.Text;
                        purchaseOrderReference = rtPurchaseOrderReference.Text;

                        int.TryParse(cboTaxRate.SelectedValue, out taxRateID);

                        Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();
                        facPreInvoice.UpdatePreinvoiceDetails(preInvoiceId, invoiceDate, clientReference, purchaseOrderReference, taxRateID, userName);
                        #endregion
                    }
                }
                else if (tableName == PreInvoiceItemTableName && (row.ItemType == GridItemType.Item || row.ItemType == GridItemType.AlternatingItem))
                {
                    HiddenField hidInvoiceItemIsDirty = row.FindControl("hidInvoiceItemIsDirty") as HiddenField;
                    bool        isDirty = false;

                    HiddenField hidInvoiceItemPendingDelete = row.FindControl("hidInvoiceItemPendingDelete") as HiddenField;
                    bool        isPendingDelete             = false;

                    if (bool.TryParse(hidInvoiceItemPendingDelete.Value, out isPendingDelete) && isPendingDelete)
                    {
                        Facade.IPreInvoice facPreInvoice = new Facade.PreInvoice();

                        TextBox      txtRate    = row.FindControl("txtRate") as TextBox;
                        GridDataItem parentItem = row.OwnerTableView.ParentItem;

                        int itemID = int.Parse(txtRate.Attributes["ItemID"]);

                        // Update the rate (depends on item type - depends on invoice type)
                        int preInvoiceID = int.Parse(parentItem.GetDataKeyValue("PreInvoiceID").ToString());

                        facPreInvoice.RemovePreInvoiceOrder(preInvoiceID, itemID);
                    }

                    else if (bool.TryParse(hidInvoiceItemIsDirty.Value, out isDirty) && isDirty)
                    {
                        #region Pre Invoice Item

                        decimal      rate       = 0;
                        HiddenField  hidOldRate = row.FindControl("hidOldRate") as HiddenField;
                        TextBox      txtRate    = row.FindControl("txtRate") as TextBox;
                        GridDataItem parentItem = row.OwnerTableView.ParentItem;

                        int         lcid = int.Parse(parentItem.GetDataKeyValue("LCID").ToString());
                        CultureInfo preInvoiceCulture = new CultureInfo(lcid);

                        if (Decimal.TryParse(txtRate.Text, System.Globalization.NumberStyles.Currency, preInvoiceCulture, out rate))
                        {
                            //decimal oldRate = 0;
                            //oldRate = decimal.Parse(hidOldRate.Value);

                            // Only apply the rate change if the rate has altered.
                            //if (oldRate != rate)
                            if (hidOldRate.Value != txtRate.Text)
                            {
                                int itemID = int.Parse(txtRate.Attributes["ItemID"]);

                                // Update the rate (depends on item type - depends on invoice type)
                                int          preInvoiceID = int.Parse(parentItem.GetDataKeyValue("PreInvoiceID").ToString());
                                eInvoiceType invoiceType  = (eInvoiceType)int.Parse(parentItem.GetDataKeyValue("InvoiceTypeID").ToString());
                                CultureInfo  culture      = new CultureInfo(Orchestrator.Globals.Configuration.NativeCulture);

                                Facade.IPreInvoice    facPreInvoice = new Facade.PreInvoice();
                                Facade.IExchangeRates facER         = new Facade.ExchangeRates();

                                switch (invoiceType)
                                {
                                case eInvoiceType.ClientInvoicing:
                                    #region Client Invoice

                                    Facade.IOrder  facOrder = new Facade.Order();
                                    Entities.Order order    = facOrder.GetForOrderID(itemID);
                                    order.ForeignRate = rate;

                                    if (order.LCID != culture.LCID)
                                    {
                                        BusinessLogicLayer.IExchangeRates    blER = new BusinessLogicLayer.ExchangeRates();
                                        BusinessLogicLayer.CurrencyConverter currencyConverter = blER.CreateCurrencyConverter(order.LCID, order.CollectionDateTime);
                                        order.Rate = currencyConverter.ConvertToLocal(order.ForeignRate);
                                    }
                                    else
                                    {
                                        order.Rate = decimal.Round(order.ForeignRate, 4, MidpointRounding.AwayFromZero);
                                    }

                                    facPreInvoice.UpdateOrderRate(preInvoiceID, itemID, order.ForeignRate, order.Rate, userName);

                                    #endregion
                                    break;

                                case eInvoiceType.SubContractorSelfBill:
                                case eInvoiceType.SubContract:
                                    #region Subby Invoicing
                                    // Needs to be Amended For Currency : TL 12/05/08;
                                    Facade.IJobSubContractor  facJSC           = new Facade.Job();
                                    Entities.JobSubContractor jobSubContractor = facJSC.GetSubContractorForJobSubContractId(itemID);
                                    jobSubContractor.ForeignRate = rate;

                                    if (jobSubContractor.LCID != culture.LCID)
                                    {
                                        jobSubContractor.Rate = facER.GetConvertedRate((int)jobSubContractor.ExchangeRateID, jobSubContractor.ForeignRate);
                                    }
                                    else
                                    {
                                        jobSubContractor.Rate = decimal.Round(jobSubContractor.ForeignRate, 4, MidpointRounding.AwayFromZero);
                                    }

                                    facPreInvoice.UpdateJobSubContractRate(preInvoiceID, itemID, jobSubContractor.ForeignRate, jobSubContractor.Rate, jobSubContractor.ExchangeRateID, userName);
                                    #endregion
                                    break;

                                default:
                                    throw new NotSupportedException("You can not alter item rates on invoices of type " + invoiceType.ToString());
                                }
                            }
                        }

                        #endregion
                    }
                }
            }
        }
コード例 #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Label PageTitle = ((System.Web.UI.UserControl)(Page.Master)).FindControl("lblWizardTitle") as Label;

            if (PageTitle != null)
            {
                PageTitle.Text = "Sub Contract";
            }

            m_jobId    = int.Parse(Request.QueryString["jobId"]);
            m_isUpdate = (Request.QueryString["isUpdate"] != null && Request.QueryString["isUpdate"].ToString() == "true");

            if (!IsPostBack && Request.QueryString["rcbId"] == null)
            {
                // You can only sub-contract per order if the job is a groupage job.
                if (Job.JobType != eJobType.Groupage)
                {
                    rdoSubContractMethod.Items.RemoveAt(2);
                }

                // If any of the legs have been completed then the sub contract whole job should be disabled (how can you sub the whole
                // job to someone when part of the job has already been completed.
                ReadOnlyCollection <Entities.Instruction> completedInstructions = Job.Instructions.FindAll(new Predicate <Orchestrator.Entities.Instruction>(FindAllCompletedInstructions));
                if (completedInstructions != null && completedInstructions.Count > 0)
                {
                    // disable the whole job radio button.
                    rdoSubContractMethod.Items[0].Selected = false;
                    rdoSubContractMethod.Items[0].Enabled  = false;
                }

                if (!m_isUpdate)
                {
                    grdLegs.Visible = false;
                }
                else
                if (Request.QueryString["rcbId"] == null)
                {
                    // Populate with the correct settings.
                    Facade.IJobSubContractor  facJobSubContractor = new Facade.Job();
                    Facade.IOrganisation      facOrganisation     = new Facade.Organisation();
                    Entities.JobSubContractor jobSubContractor    = facJobSubContractor.GetSubContractorForJobId(m_jobId)[0];
                    rntSubContractRate.Culture = new CultureInfo(jobSubContractor.LCID);

                    cboSubContractor.SelectedValue     = jobSubContractor.ContractorIdentityId.ToString();
                    cboSubContractor.Text              = facOrganisation.GetNameForIdentityId(jobSubContractor.ContractorIdentityId);
                    chkUseSubContractorTrailer.Checked = jobSubContractor.UseSubContractorTrailer;
                    rntSubContractRate.Text            = jobSubContractor.ForeignRate.ToString();

                    cboSubContractor.Enabled           = false;
                    chkUseSubContractorTrailer.Enabled = false;
                    pnlTrailer.Visible = true;
                }

                if (Globals.Configuration.SubContractorCommunicationsRequired)
                {
                    lblShowAsCommunicated.Visible = true;
                    chkShowAsCommunicated.Visible = true;
                }
            }

            InjectScript.Text = string.Empty;
        }
コード例 #13
0
        void btnConfirmSubContract_Click(object sender, EventArgs e)
        {
            if (Page.IsValid && ValidateSubContractLeg())
            {
                // Check whether the user is trying to subcontract instructions that have resources assigned.
                // Only applies to driver and vehicle resources.
                Entities.InstructionCollection instructions = Job.Instructions;

                // Extract the collections.
                Entities.Instruction selected = instructions.Find(
                    delegate(Entities.Instruction instruction)
                {
                    return(instruction.InstructionOrder == 0);
                });

                // No resources exist for selected instructions, so continue with save oepration.
                SubContractingMethod method = (SubContractingMethod)int.Parse(rdoSubContractMethod.SelectedValue);
                string userID = ((Entities.CustomPrincipal)Page.User).UserName;

                Entities.JobSubContractor jobSubContractor = GetJobSubContract(selected);
                DateTime lastUpdateDate = DateTime.Parse(Request.QueryString["LastUpdateDate"]);

                // Set the job to be sub-contracted
                Entities.FacadeResult result = null;

                switch (method)
                {
                case SubContractingMethod.WholeJob:
                    //add something that finds if any of the other legs have been subbed out already.
                    result = SubContractWholeJob(jobSubContractor, lastUpdateDate, userID);
                    break;

                case SubContractingMethod.SpecificLegs:
                    result = SubContractSpecificLegs(jobSubContractor, lastUpdateDate, userID);
                    break;

                case SubContractingMethod.PerOrder:
                    result = SubContractPerOrder(jobSubContractor, lastUpdateDate, userID);
                    break;
                }

                if (Globals.Configuration.SubContractorCommunicationsRequired &&
                    chkShowAsCommunicated.Checked)
                {
                    CommunicateInstructionsForSubContractor(Job.JobId, jobSubContractor.ContractorIdentityId, userID);
                }

                if (result.Success)
                {
                    Cache.Remove("JobEntityForJobId" + m_jobId.ToString());
                    //InjectScript.Text = "<script>RefreshParentPage();</script>";
                    this.ReturnValue = "refresh";
                    this.Close();
                }
                else
                {
                    infrigementDisplay.Infringements = result.Infringements;
                    infrigementDisplay.DisplayInfringments();
                    infrigementDisplay.Visible = true;

                    pnlConfirmation.Visible = false;
                }
            }
        }
コード例 #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["JID"]))
            {
                if (int.TryParse(Request.QueryString["JID"], out m_jobID))
                {
                    bool subbedOutWholeJob = false;
                    _job = GetJobEntityFromCache();

                    foreach (Entities.JobSubContractor jsc in _job.SubContractors)
                    {
                        if (jsc.SubContractWholeJob)
                        {
                            _wholeJobSubcontractor = jsc;
                            _culture          = new CultureInfo(jsc.LCID);
                            subbedOutWholeJob = true;
                            break;
                        }
                    }

                    if (!IsPostBack)
                    {
                        if (!subbedOutWholeJob)
                        {
                            // Only show the legs and orders grid if not subbed out whole job
                            repLegSubbyRates.Visible = true;

                            Facade.IJob facJob = new Facade.Job();
                            DataTable   dt     = facJob.GetTrafficSheetForJobId(m_jobID).Tables[1];
                            repLegSubbyRates.DataSource = dt;
                            repLegSubbyRates.DataBind();
                        }
                        else
                        {
                            // ...otherwise, show the whole job rate controls.
                            fldWholeJobSubcontractInformation.Visible = true;
                            repLegSubbyRates.Visible = false;

                            txtWholeJobSubcontractRate.Attributes.Add("jobSubContractID", _wholeJobSubcontractor.JobSubContractID.ToString());
                            txtWholeJobSubcontractRate.Attributes.Add("LCID", _wholeJobSubcontractor.LCID.ToString());

                            txtWholeJobSubcontractRate.Culture = new CultureInfo(_wholeJobSubcontractor.LCID);
                            txtWholeJobSubcontractRate.Text    = _wholeJobSubcontractor.ForeignRate.ToString();
                            chkIsAttended.Checked = _wholeJobSubcontractor.IsAttended;
                            txtReference.Text     = _wholeJobSubcontractor.Reference;

                            if (_wholeJobSubcontractor.InvoiceID > 0)
                            {
                                // don't allow the user to update information as the invoice has already been generated
                                txtWholeJobSubcontractRate.Enabled = false;
                                chkIsAttended.Enabled  = false;
                                txtReference.Enabled   = false;
                                btnUpdateRates.Enabled = false;
                            }
                        }
                    }
                }
            }

            this.Master.WizardTitle = "Update Sub-Contract Rates";
        }
コード例 #15
0
        void btnUpdateRates_Click(object sender, EventArgs e)
        {
            if (_wholeJobSubcontractor == null)
            {
                // the JS will not allow non currency figures.
                Facade.IJobSubContractor facSubby = new Facade.Job();
                Entities.Job             job      = GetJobEntityFromCache();

                int               jobSubContractID        = 0;
                decimal           rate                    = 0M;
                string            userID                  = this.User.Identity.Name;
                RadNumericTextBox txtRate                 = null;
                TextBox           txtSubcontractReference = null;
                CheckBox          chkIsAttended           = null;
                HiddenField       hidJobSubContractID     = null;

                foreach (RepeaterItem legItem in repLegSubbyRates.Items)
                {
                    if (legItem.ItemType == ListItemType.Item || legItem.ItemType == ListItemType.AlternatingItem)
                    {
                        txtRate                 = legItem.FindControl("rntSubContractRate") as RadNumericTextBox;
                        hidJobSubContractID     = legItem.FindControl("hidJobSubContractID") as HiddenField;
                        txtSubcontractReference = legItem.FindControl("txtSubcontractReference") as TextBox;
                        chkIsAttended           = legItem.FindControl("chkIsAttended") as CheckBox;

                        if (!string.IsNullOrEmpty(hidJobSubContractID.Value))
                        {
                            jobSubContractID = int.Parse(hidJobSubContractID.Value);
                            if (decimal.TryParse(txtRate.Text, System.Globalization.NumberStyles.Currency, System.Threading.Thread.CurrentThread.CurrentCulture, out rate))
                            {
                                Entities.JobSubContractor jobSubContract = facSubby.GetSubContractorForJobSubContractId(jobSubContractID);
                                jobSubContract.ForeignRate = rate;
                                jobSubContract.IsAttended  = chkIsAttended.Checked;
                                jobSubContract.Reference   = txtSubcontractReference.Text;
                                facSubby.Update(m_jobID, jobSubContract, _job.LastUpdateDate, userID);
                            }
                        }
                        else
                        {
                            Repeater repOrderSubbyRates = legItem.FindControl("repOrderSubbyRates") as Repeater;
                            if (repOrderSubbyRates.Visible)
                            {
                                foreach (RepeaterItem orderItem in repOrderSubbyRates.Items)
                                {
                                    if (orderItem.ItemType == ListItemType.Item || orderItem.ItemType == ListItemType.AlternatingItem)
                                    {
                                        txtRate                 = orderItem.FindControl("rntSubContractRate") as RadNumericTextBox;
                                        hidJobSubContractID     = orderItem.FindControl("hidJobSubContractID") as HiddenField;
                                        txtSubcontractReference = orderItem.FindControl("txtSubcontractReference") as TextBox;
                                        chkIsAttended           = orderItem.FindControl("chkIsAttended") as CheckBox;

                                        if (!string.IsNullOrEmpty(hidJobSubContractID.Value))
                                        {
                                            jobSubContractID = int.Parse(hidJobSubContractID.Value);
                                            if (decimal.TryParse(txtRate.Text, System.Globalization.NumberStyles.Currency, System.Threading.Thread.CurrentThread.CurrentCulture, out rate))
                                            {
                                                Entities.JobSubContractor jobSubContract = facSubby.GetSubContractorForJobSubContractId(jobSubContractID);
                                                jobSubContract.ForeignRate = rate;
                                                jobSubContract.IsAttended  = chkIsAttended.Checked;
                                                jobSubContract.Reference   = txtSubcontractReference.Text;
                                                facSubby.Update(m_jobID, jobSubContract, _job.LastUpdateDate, userID);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                Facade.IJobSubContractor facSub = new Facade.Job();
                job.SubContractors = facSub.GetSubContractorForJobId(_job.JobId);
                AddJobEntityToCache(_job);
            }
            else
            {
                // Save and Hide the Edit Facilities
                decimal rate = 0;

                Facade.IJobSubContractor facSub = new Facade.Job();

                if (Decimal.TryParse(txtWholeJobSubcontractRate.Text, System.Globalization.NumberStyles.Currency, CultureInfo.CreateSpecificCulture("en-GB"), out rate))
                {
                    int jobSubContractID = int.Parse(txtWholeJobSubcontractRate.Attributes["jobSubContractID"]);

                    // Set the jobsubcontract information.
                    _wholeJobSubcontractor.ForeignRate = decimal.Parse(txtWholeJobSubcontractRate.Text);
                    _wholeJobSubcontractor.IsAttended  = chkIsAttended.Checked;
                    _wholeJobSubcontractor.Reference   = txtReference.Text;

                    // Save it.
                    facSub.Update(_wholeJobSubcontractor.JobID, _wholeJobSubcontractor, _job.LastUpdateDate, User.Identity.Name);

                    // Update the cached job.
                    _job.SubContractors = facSub.GetSubContractorForJobId(_job.JobId);
                    AddJobEntityToCache(_job);
                }
            }

            // Refresh the job details page.
            lblInjectScript.Text = "<script>RefreshParentPage();</script>";
        }
コード例 #16
0
        //-----------------------------------------------------------------------------------------------------------

        protected void grdOrders_UpdateCommand(object source, GridCommandEventArgs e)
        {
            GridEditableItem editedItem = e.Item as GridEditableItem;
            int orderId = 0;

            if (!String.IsNullOrEmpty(editedItem.GetDataKeyValue("OrderId").ToString()))
            {
                orderId = Convert.ToInt32(editedItem.GetDataKeyValue("OrderId").ToString());
            }

            if (orderId > 0)
            {
                RadNumericTextBox txtNoPallets    = (RadNumericTextBox)e.Item.FindControl("txtNoPallets");
                RadNumericTextBox txtPalletSpaces = (RadNumericTextBox)e.Item.FindControl("txtPalletSpaces");
                RadNumericTextBox txtWeight       = (RadNumericTextBox)e.Item.FindControl("txtWeight");
                RadNumericTextBox txtQtrPallets   = (RadNumericTextBox)e.Item.FindControl("txtQtrPallets");
                RadNumericTextBox txtHalfPallets  = (RadNumericTextBox)e.Item.FindControl("txtHalfPallets");
                RadNumericTextBox txtFullPallets  = (RadNumericTextBox)e.Item.FindControl("txtFullPallets");
                RadNumericTextBox txtOverPallets  = (RadNumericTextBox)e.Item.FindControl("txtOverPallets");

                Orchestrator.EF.DataContext context   = new Orchestrator.EF.DataContext();
                Orchestrator.EF.VigoOrder   vigoOrder = context.VigoOrderSet.FirstOrDefault(vo => vo.OrderId == orderId);

                vigoOrder.QtrPallets  = Convert.ToInt32(txtQtrPallets.Value);
                vigoOrder.HalfPallets = Convert.ToInt32(txtHalfPallets.Value);
                vigoOrder.FullPallets = Convert.ToInt32(txtFullPallets.Value);
                vigoOrder.OverPallets = Convert.ToInt32(txtOverPallets.Value);

                vigoOrder.LastUpdateDate   = DateTime.Now;
                vigoOrder.LastUpdateUserId = Page.User.Identity.Name;

                context.SaveChanges(true);

                //Orchestrator.EF.RateInformation rateInformation = null;

                Facade.IOrder facOrder            = new Facade.Order();
                Orchestrator.Entities.Order order = facOrder.GetForOrderID(orderId);

                order.NoPallets    = Convert.ToInt32(txtNoPallets.Value);
                order.PalletSpaces = Convert.ToDecimal(txtPalletSpaces.Value);
                order.Weight       = Convert.ToDecimal(txtWeight.Value);

                order.LastUpdatedDateTime = DateTime.Now;
                order.LastUpdatedBy       = Page.User.Identity.Name;

                //// Rate has not changed so auto rate it
                //if (order.ForeignRate == Convert.ToDecimal(txtRate.Value.Value))
                //{
                //    IEnumerable<Orchestrator.EF.RateSurcharge> rateSurcharge = new List<Orchestrator.EF.RateSurcharge>();
                //    rateInformation = facOrder.GetRate(order, true, out rateSurcharge);

                //    if (rateInformation != null)
                //    {
                //        order.TariffRateID = rateInformation.TariffRateId;
                //        order.ForeignRate = rateInformation.ForeignRate;
                //        order.Rate = rateInformation.Rate;
                //    }
                //    else
                //    {
                //        Facade.IExchangeRates facER = new Facade.ExchangeRates();
                //        CultureInfo nativeCulture = new CultureInfo(Orchestrator.Globals.Configuration.NativeCulture);

                //        order.ForeignRate = Convert.ToDecimal(txtRate.Value);

                //        if (order.LCID != nativeCulture.LCID)
                //        {
                //            order.ExchangeRateID = facER.GetCurrentExchangeRateID(Facade.Culture.GetCurrencySymbol(order.LCID), order.CollectionDateTime);
                //            order.Rate = facER.GetConvertedRate((int)order.ExchangeRateID, order.ForeignRate);
                //        }
                //        else
                //            order.Rate = order.ForeignRate;

                //        order.IsTariffOverride = true;
                //        order.TariffRateID = null;
                //        order.TariffOverrideUserID = Page.User.Identity.Name;
                //        order.TariffOverrideDate = DateTime.Now;
                //    }
                //}
                //else
                //{
                //    Facade.IExchangeRates facER = new Facade.ExchangeRates();
                //    CultureInfo nativeCulture = new CultureInfo(Orchestrator.Globals.Configuration.NativeCulture);

                //    order.ForeignRate = Convert.ToDecimal(txtRate.Value);

                //    if (order.LCID != nativeCulture.LCID)
                //    {
                //        order.ExchangeRateID = facER.GetCurrentExchangeRateID(Facade.Culture.GetCurrencySymbol(order.LCID), order.CollectionDateTime);
                //        order.Rate = facER.GetConvertedRate((int)order.ExchangeRateID, order.ForeignRate);
                //    }
                //    else
                //        order.Rate = order.ForeignRate;

                //    order.IsTariffOverride = true;
                //    order.TariffRateID = null;
                //    order.TariffOverrideUserID = Page.User.Identity.Name;
                //    order.TariffOverrideDate = DateTime.Now;
                //}

                facOrder.Update(order, Page.User.Identity.Name);

                // We need to make sure the subcontractor (Palletforce) costs are re-rated
                Facade.IJobSubContractor jobSubContractor = new Facade.Job();
                if (order != null && order.JobSubContractID > 0)
                {
                    Entities.JobSubContractor js = jobSubContractor.GetSubContractorForJobSubContractId(order.JobSubContractID);
                    jobSubContractor.UpdateSubContractorCostsForOrders(new List <int>()
                    {
                        order.OrderID
                    }, js, this.Page.User.Identity.Name);
                }

                this.grdOrders.DataSource = null;
                this.grdOrders.Rebind();
            }
        }