Ejemplo n.º 1
0
        void grdManifestList_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            Facade.OrderManifest facOrderManifest = new Orchestrator.Facade.OrderManifest();
            DataSet dsOrderManifest = facOrderManifest.GetOrderManifestList((DateTime)dteStartDate.SelectedDate, (DateTime)dteEndDate.SelectedDate);

            this.grdManifestList.DataSource = dsOrderManifest;
        }
Ejemplo n.º 2
0
        private void SaveManifest(bool addOrders)
        {
            Facade.OrderManifest facOrderManifest = new Orchestrator.Facade.OrderManifest();

            if (OrderManifestId > 0)
            {
                List <int> orderIdsOfOrdersToRemoveFromJobs = new List <int>();

                // Identify those for removal
                if (chkRemoveFromJob.Checked)
                {
                    foreach (Entities.OrderManifestOrder existingOrderManifestOrder in this.OrderManifest.OrderManifestOrders)
                    {
                        if (!(this.OrdersList.Find(o => o == existingOrderManifestOrder.OrderId) > 0))
                        {
                            // Order Manifest order does not exist in the selected list.
                            if (existingOrderManifestOrder.Removed == false)
                            {
                                existingOrderManifestOrder.Removed = true;
                                orderIdsOfOrdersToRemoveFromJobs.Add(existingOrderManifestOrder.OrderId);
                            }
                        }
                    }
                }

                if (addOrders)
                {
                    // Identify those for insertion
                    foreach (int orderId in this.AddOrdersList)
                    {
                        Entities.OrderManifestOrder existingOrderManifestOrder = this.OrderManifest.OrderManifestOrders.Find(o => o.OrderId == orderId);
                        if (existingOrderManifestOrder != null)
                        {
                            if (existingOrderManifestOrder.Removed)
                            {
                                // This order has previously been in the manifest, then removed, and now the user
                                // wants to add it in once again.
                                existingOrderManifestOrder.Removed = false;
                            }
                        }
                        else
                        {
                            // The order has never been saved on this manifest, add it...
                            // Insert the order manifest order into the collection
                            Entities.OrderManifestOrder omo = new Orchestrator.Entities.OrderManifestOrder();
                            omo.OrderManifestId = this.OrderManifest.OrderManifestId;
                            omo.OrderId         = orderId;
                            this.OrderManifest.OrderManifestOrders.Add(omo);
                        }
                    }
                }

                this.OrderManifest.Description  = txtOrderManifestName.Text;
                this.OrderManifest.ManifestDate = dteOrderManifestDate.SelectedDate.Value;

                // No point in updating the driverresourceid or the subcontractoridentityid because once
                // a manifest has been created it should not be possible to change them.

                facOrderManifest.UpdateOrderManifest(this.OrderManifest, orderIdsOfOrdersToRemoveFromJobs, this.Page.User.Identity.Name);
                this.OrderManifest = new Facade.OrderManifest().GetForOrderManifestId(OrderManifestId);
            }
            else
            {
                if (this.AddOrdersList.Count != 0)
                {
                    // This is a completely new manifest.
                    Entities.OrderManifest newOrderManifest = new Orchestrator.Entities.OrderManifest();
                    newOrderManifest.Description  = txtOrderManifestName.Text;
                    newOrderManifest.ManifestDate = dteOrderManifestDate.SelectedDate.Value;

                    if (cboResource.SelectedValue != "")
                    {
                        newOrderManifest.ResourceId   = Convert.ToInt32(cboResource.SelectedValue);
                        newOrderManifest.ResourceName = cboResource.Text;
                    }

                    if (cboSubContractor.SelectedValue != "")
                    {
                        newOrderManifest.SubContractorIdentityId = Convert.ToInt32(cboSubContractor.SelectedValue);
                        newOrderManifest.SubContractorName       = cboSubContractor.Text;
                    }

                    List <Entities.OrderManifestOrder> orderManifestOrders = new List <Orchestrator.Entities.OrderManifestOrder>();
                    foreach (int orderId in this.AddOrdersList)
                    {
                        Entities.OrderManifestOrder omo = new Orchestrator.Entities.OrderManifestOrder();
                        omo.OrderId = orderId;
                        orderManifestOrders.Add(omo);
                    }

                    newOrderManifest.OrderManifestOrders = orderManifestOrders;

                    OrderManifestId    = facOrderManifest.CreateOrderManifest(newOrderManifest, Page.User.Identity.Name);
                    this.OrderManifest = new Facade.OrderManifest().GetForOrderManifestId(OrderManifestId);
                }
                else
                {
                    this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "NoRows", "alert('There are no orders in your manifest. Please add some orders and try again.');", true);
                }
            }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            txtExtraRowCount.Type = NumericType.Number;

            if (!Page.IsPostBack)
            {
                OrderManifestId = Convert.ToInt32(Request.QueryString["omID"]);

                // The default start date is the start of tomorrow.
                DateTime defaultStartDateTime = DateTime.Now;
                defaultStartDateTime = defaultStartDateTime.Subtract(defaultStartDateTime.TimeOfDay);
                defaultStartDateTime = defaultStartDateTime.AddDays(1);

                dteStartDateTime.SelectedDate = defaultStartDateTime;

                if (OrderManifestId == 0)
                {
                    pnlOrdersCurrentlyOnManifest.Visible = false;

                    dteOrderManifestDate.SelectedDate = defaultStartDateTime;

                    // The user is looking to create a new order manifest
                    this.OrderManifest = null;

                    // Hide the resouce and subcontractor combos
                    trResourceSubcontractorComboSection.Visible = true;

                    grdManifest.Visible = false;
                }
                else
                {
                    pnlOrdersCurrentlyOnManifest.Visible = true;

                    // Hide the resouce and subcontractor combos
                    trResourceSubcontractorComboSection.Visible = false;

                    grdManifestAddOrders.Visible = false;

                    pnlSaveAndDisplay.Visible = true;

                    // The user wants to view/modify an existing order manifest
                    // Retrieve the Order Manifest
                    Facade.OrderManifest facOrderManifest = new Orchestrator.Facade.OrderManifest();
                    this.OrderManifest = facOrderManifest.GetForOrderManifestId(OrderManifestId);

                    lblOrderManifestNumber.Text = this.OrderManifest.OrderManifestId.ToString();
                    this.lblResourceOrSubcontractorNameLabel.Text = this.OrderManifest.ResourceId > 0 ? "Resource:" : "Subcontractor:";
                    this.lblResourceOrSubcontractorName.Text      = this.OrderManifest.ResourceId > 0 ? this.OrderManifest.ResourceName : this.OrderManifest.SubContractorName;

                    // Users should not be allowed to edit the resource and subby drop downs.
                    this.cboResource.Enabled      = false;
                    this.cboSubContractor.Enabled = false;

                    if (this.OrderManifest.ResourceId > 0)
                    {
                        this.cboResource.SelectedValue = this.OrderManifest.ResourceId.ToString();
                        this.cboResource.Text          = this.OrderManifest.ResourceName;
                    }
                    else
                    {
                        this.cboSubContractor.SelectedValue = this.OrderManifest.SubContractorIdentityId.ToString();
                        this.cboSubContractor.Text          = this.OrderManifest.SubContractorName;
                    }

                    this.dteOrderManifestDate.SelectedDate = new DateTime?(this.OrderManifest.ManifestDate);
                    this.txtOrderManifestName.Text         = this.OrderManifest.Description;

                    grdManifest.Visible    = true;
                    grdManifest.DataSource = new Facade.OrderManifest().GetOrderManifestForDisplay(this.OrderManifest.OrderManifestId);
                    grdManifest.DataBind();

                    // Do not display the saved manifest until the user explicitly clicks the "Save & Display" button.
                    //DisplaySavedManifest();
                }
            }
        }