Esempio n. 1
0
    protected void btnSubmitMakeDeliveryRequest_Click(object sender, EventArgs e)
    {
        try
        {
            Entities dbContext = new Entities();
            DeliveryRequest deliveryRequest = new DeliveryRequest();
            deliveryRequest.CustomerId = WebUser.GetInstance().Id;
            deliveryRequest.Description = txtDescription.Text;
            int iq;
            bool iqIsInt = int.TryParse(txtItemQuantity.Text, out iq);
            if(iqIsInt)
            {
                deliveryRequest.ItemQuantity = iq;
            }else{
                throw new Exception("Item Quantity must be a valid integer");
            }
            deliveryRequest.FromLocation = txtFromLocation.Text;
            deliveryRequest.Destination = txtDestination.Text;

            DateTime dt;
            DateTime at;

            bool isDT = DateTime.TryParse(txtDispatchTime.Text, out dt);

            if(isDT)
            {
                deliveryRequest.DispatchTime = dt;
            }else{
                throw new Exception("Dispatch time must be a valid date time value.");
            }

            isDT = DateTime.TryParse(txtDispatchTime.Text, out at);

            if (isDT)
            {
                deliveryRequest.ArrivalTime = at;
            }
            else
            {
                throw new Exception("Arrival time must be a valid date time value.");
            }

            deliveryRequest.Status = 0;

            dbContext.DeliveryRequests.AddObject(deliveryRequest);

            dbContext.SaveChanges();

            lblFormResponse.Text = "Your delivery request was submitted. Your delivery will appear in your Deliveries List when accepted by an operator.";

        }
        catch (Exception ex)
        {
            lblFormResponse.Text = ex.Message;
        }
    }
Esempio n. 2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the DeliveryRequests EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDeliveryRequests(DeliveryRequest deliveryRequest)
 {
     base.AddObject("DeliveryRequests", deliveryRequest);
 }
Esempio n. 3
0
 /// <summary>
 /// Create a new DeliveryRequest object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="customerId">Initial value of the CustomerId property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 /// <param name="fromLocation">Initial value of the FromLocation property.</param>
 /// <param name="destination">Initial value of the Destination property.</param>
 /// <param name="dispatchTime">Initial value of the DispatchTime property.</param>
 /// <param name="arrivalTime">Initial value of the ArrivalTime property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 public static DeliveryRequest CreateDeliveryRequest(global::System.Int32 id, global::System.Int32 customerId, global::System.String description, global::System.String fromLocation, global::System.String destination, global::System.DateTime dispatchTime, global::System.DateTime arrivalTime, global::System.Int32 status)
 {
     DeliveryRequest deliveryRequest = new DeliveryRequest();
     deliveryRequest.Id = id;
     deliveryRequest.CustomerId = customerId;
     deliveryRequest.Description = description;
     deliveryRequest.FromLocation = fromLocation;
     deliveryRequest.Destination = destination;
     deliveryRequest.DispatchTime = dispatchTime;
     deliveryRequest.ArrivalTime = arrivalTime;
     deliveryRequest.Status = status;
     return deliveryRequest;
 }