Exemplo n.º 1
0
        private void repInspections_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
        {
            try
            {
                if(e.CommandName.Length > 0)
                {
                    status = (WorkOrderStatus)ViewState["status"];
                    opstatus = (WorkOrderOperatorStatus)ViewState["opstatus"];

                    if(status == WorkOrderStatus.Scheduled
                        && e.CommandName != "Delete")
                    {
                        if(opstatus == WorkOrderOperatorStatus.Null)
                        {
                            Response.Redirect("wo_viewCheckIn.aspx?id=" + OrderId.ToString(), false);
                            return;
                        }
                        else
                        {
                            Response.Redirect("wo_openWorkOrder.aspx?id=" + OrderId.ToString(), false);
                            return;
                        }
                    }
                    if(e.CommandName == "Complete")
                    {
                        Response.Redirect("wo_viewCompleteInspection.aspx?id=" + OrderId.ToString() + "&inspectid=" + e.CommandArgument, false);
                        return;
                    }

                    if(e.CommandName == "Delete")
                    {
                        Header.BodyOnloadScript = "javascript:document.location='#Issues'";
                        //Header.Render();

                        order = new clsWorkOrders();
                        order.cAction = "D";
                        order.iOrgId = OrgId;
                        order.iId = OrderId;
                        order.iWOInspectionId = Convert.ToInt32(e.CommandArgument);
                        order.iTechId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                        if(order.WorkOrderInspectionsDetail() == -1)
                        {
                            Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();
                            Session["error"] = _functions.ErrorMessage(124);
                            Response.Redirect("error.aspx", false);
                        }
                        else
                        {
                            dtInspections = order.GetWorkOrderInspections();
                            if(dtInspections.Rows.Count > 0)
                                html_tblNoneInspections.Visible = false;
                            else
                                html_tblNoneInspections.Visible = true;

                            repInspections.DataSource = new DataView(dtInspections);
                            repInspections.DataBind();

                            ShowRepairList();
                        }
                    }
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }