Exemplo n.º 1
0
    protected void wizardCreate_FinishButtonClick(object sender, WizardNavigationEventArgs e)
    {
        try
        {
            Order order  = (Order)Session["orderModify"];
            int   status = 0;
            if (order.OrderOfService_Status.Equals("Pending"))
            {
                status = 0;
            }
            else if (order.OrderOfService_Status.Equals("In Progress"))
            {
                status = 99;
            }
            else if (order.OrderOfService_Status.Equals("Resolved"))
            {
                status = 1;
            }
            OB.UpdateOrder(orderId, order.OrderOfService_Description, order.OrderOfService_PaymentMethod, order.OrderOfService_PaymentDate, order.OrderOfService_BillDate, status);

            // Delete all order's details.
            List <OrderOfServiceDetail> list = OB.GetAllOrderDetailsByOrderId(orderId);
            foreach (OrderOfServiceDetail od in list)
            {
                OB.DeleteOrderDetail(od.OrderOfService_Id.ToString(), od.Service_Id.ToString());
            }
            // Create again.
            List <OrderDetail> listOrderDetail = (List <OrderDetail>)Session["listOrderDetailModify"];
            foreach (OrderDetail item in listOrderDetail)
            {
                OB.CreateOrderDetail(orderId, item.Service_Id, DateTime.Parse(item.OrderOfServiceDetail_FromDate), DateTime.Parse(item.OrderOfServiceDetail_ToDate), item.OrderOfServiceDetail_NumberOfEmployee);
            }

            if (Session["orderModify"] != null)
            {
                Session.Remove("orderModify");
            }
            if (Session["listOrderDetailModify"] != null)
            {
                Session.Remove("listOrderDetailModify");
            }

            pnlGreen.Visible = true;
            if (Session["return"] == null)
            {
                Session.Add("return", "modify");
            }
            else
            {
                Session["return"] = "modify";
            }
            Response.Redirect(WebHelper.Instance.GetURL() + "ManageService/Order/Manage/" + orderId.ToString());
        }
        catch (Exception ex)
        {
            pnlRed.Visible       = true;
            lblError.Text        = ex.Message;
            hplnkRed.Text        = "Please try again.";
            hplnkRed.NavigateUrl = "";
        }
    }