Exemple #1
0
 private void dgFutureInspections_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
 {
     try
     {
         int FutureOrderId;
         if (e.CommandName == "Assign")
         {
             order                 = new clsWorkOrders();
             order.iId             = OrderId;
             order.iOrgId          = OrgId;
             order.iWOInspectionId = Convert.ToInt32(e.Item.Cells[0].Text);
             // move inspection from future work order
             if (order.SetFutureInspection() == -1)
             {
                 Session["lastpage"] = m_sBackUrl;
                 Session["error"]    = _functions.ErrorMessage(124);
                 Response.Redirect("error.aspx", false);
             }
             // delete future empty work order
             if (order.DeleteFutureWorkOrder() == -1)
             {
                 Session["lastpage"] = m_sBackUrl;
                 Session["error"]    = _functions.ErrorMessage(120);
                 Response.Redirect("error.aspx", false);
             }
             order.iId = OrderId;
             dgInspections.DataSource = new DataView(order.GetInspectionsListForWorkOrder());
             dgInspections.DataBind();
             dtFutureInspections = order.GetFutureInspections();
             if (dtFutureInspections.Rows.Count > 0)
             {
                 dgFutureInspections.DataSource = new DataView(dtFutureInspections);
                 dgFutureInspections.DataBind();
             }
             else
             {
                 tblMain.Rows[2].Visible = false;
                 tblMain.Rows[3].Visible = false;
             }
         }
     }
     catch (Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"]     = m_sBackUrl;
         Session["error"]        = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if (order != null)
         {
             order.Dispose();
         }
     }
 }
Exemple #2
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                if (Request.QueryString["id"] == null)
                {
                    Session["lastpage"] = "wo_default.aspx";
                    Session["error"]    = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    OrderId = Convert.ToInt32(Request.QueryString["id"]);
                }
                catch (FormatException fex)
                {
                    Session["lastpage"] = "wo_default.aspx";
                    Session["error"]    = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }

                Header.AddJavaScriptFile("/OpenWindows.js");

                // if the coming was from order detail screen or for the past work order creating
                if (Request.QueryString["back"] != null)
                {
                    if (Request.QueryString["back"] == "past")
                    {
                        IsPast = true;

                        tblMain.Rows[4].Visible = true;
                        tblMain.Rows[5].Visible = false;

                        m_sBackUrl  = "wo_addInspections.aspx?back=past&id=" + OrderId.ToString();
                        m_sLastPage = "wo_editAddInfo.aspx?back=past&id=" + OrderId.ToString() + "&equipid=0";

                        NextBackControl.BackPage = m_sLastPage;
                    }
                    else
                    {
                        tblMain.Rows[4].Visible = false;
                        tblMain.Rows[5].Visible = true;

                        m_sBackUrl  = "wo_addInspections.aspx?id=" + OrderId.ToString() + "&back=view";
                        m_sLastPage = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();

                        // getting the Bread Crumbs from Cookie and add last item
                        if (Request.Cookies.Count > 0 && Request.Cookies["bfp_navigate"] != null)
                        {
                            Header.BrdCrumbsSerialization = Request.Cookies["bfp_navigate"].Value;
                        }
                        Header.AddBreadCrumb("Work Order Detail", "/wo_viewWorkOrder.aspx?id=" + OrderId.ToString() + "&#Issues");

                        SaveCancelControl.ParentPageURL = this.ParentPageURL;
                        SaveCancelControl.ButtonText    = " Save ";
                    }
                }
                else
                {                 // the coming was usual from previous wizard screen is the Add Preventive Maintenance
                    tblMain.Rows[4].Visible = true;
                    tblMain.Rows[5].Visible = false;

                    m_sBackUrl  = "wo_addInspections.aspx?id=" + OrderId.ToString();
                    m_sLastPage = "wo_addPreventiveMaintenance.aspx?id=" + OrderId.ToString() + "&back=inspect";

                    NextBackControl.BackPage = "wo_addPreventiveMaintenance.aspx?id=" + OrderId.ToString() + "&back=inspect";
                }

                // reloading if coming from the Inspection History screen
                if (Session["reload"] != null)
                {
                    if ((bool)Session["reload"] == true)
                    {
                        Session["reload"] = null;
                        Response.Redirect(m_sBackUrl, false);
                        return;
                    }
                }

                if (!IsPostBack)
                {
                    order        = new clsWorkOrders();
                    order.iOrgId = OrgId;
                    order.iId    = OrderId;
                    if (order.GetWorkOrderId() == -1)
                    {
                        Session["lastpage"] = m_sLastPage;
                        Session["error"]    = _functions.ErrorMessage(120);
                        Response.Redirect("error.aspx", false);
                    }
                    ViewState["WorkOrderCreatedDate"] = order.daCreated.Value;
                    ViewState["WorkOrderNumber"]      = order.iWorkOrderNumber.Value;
                    if (IsPast)
                    {
                        order.daCurrentDate = order.daCreated;
                    }
                    else
                    {
                        order.daCurrentDate = DateTime.Now;
                    }
                    dgInspections.DataSource = new DataView(order.GetInspectionsListForWorkOrder());
                    dgInspections.DataBind();
                    dtFutureInspections = order.GetFutureInspections();
                    if (dtFutureInspections.Rows.Count > 0)
                    {
                        dgFutureInspections.DataSource = new DataView(dtFutureInspections);
                        dgFutureInspections.DataBind();
                    }
                    else
                    {
                        tblMain.Rows[2].Visible = false;
                        tblMain.Rows[3].Visible = false;
                    }
                }
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = m_sLastPage;
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (order != null)
                {
                    order.Dispose();
                }
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            //try
            //{
            ReportViewerControl.LocalReport.ReportPath = _functions.GetValueFromConfig("SQLRS.DefaultPath") + ".rdlc";
            if (Request["Report"] != null)
            {
                ReportViewerControl.LocalReport.ReportPath = Request["Report"] + ".rdlc";
            }

            ReportViewerControl.LocalReport.EnableExternalImages = true;

            clsWorkOrders wo = new clsWorkOrders();

            if (!string.IsNullOrEmpty(Request["OrgId"]))
            {
                wo.iOrgId = Convert.ToInt32(Request["OrgId"]);
            }

            if (!string.IsNullOrEmpty(Request["OrderId"]))
            {
                wo.iId = Convert.ToInt32(Request["OrderId"]);
            }

            if (!string.IsNullOrEmpty(Request["InspectId"]))
            {
                wo.iInspectionId = Convert.ToInt32(Request["InspectId"]);
            }

            string url = string.Empty;

            if (!string.IsNullOrEmpty(Request["URL"]))
            {
                url = Request["URL"];
            }

            foreach (string dataSource in ReportViewerControl.LocalReport.GetDataSourceNames())
            {
                switch (dataSource)
                {
                case "ReportedIssueList":
                    DataSet ds = wo.GetReportedIssueLists();
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        ReportViewerControl.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource, ds.Tables[0]));
                    }
                    break;

                case "PMItemList":
                    ReportViewerControl.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource, wo.GetPMServicesListForWorkOrder()));
                    break;

                case "InspectionsList":
                    ReportViewerControl.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource, wo.GetInspectionsListForWorkOrder()));
                    break;

                case "WorkOrderDetail":
                    ReportViewerControl.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource, wo.GetDetailsForWorkOrder()));
                    break;

                case "CreationNotesList":
                    wo.iNoteTypeId = 1;
                    ReportViewerControl.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource, wo.GetNotesList()));
                    break;

                case "OperatorNotesList":
                    wo.iNoteTypeId = 2;
                    ReportViewerControl.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource, wo.GetNotesList()));
                    break;

                case "PartsList":
                    ReportViewerControl.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource, wo.GetPartsUsedListForReport()));
                    break;

                case "ReportedIssuesList":
                    ReportViewerControl.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource, wo.GetReportedIssues()));
                    break;

                case "PMItemsList":
                    ReportViewerControl.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource, wo.GetPMItemsList()));
                    break;

                case "RepairsList":
                    ReportViewerControl.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource, wo.GetRepairsListForReport()));
                    break;

                case "TechNotesList":
                    wo.iNoteTypeId = 3;
                    ReportViewerControl.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource, wo.GetNotesList()));
                    break;

                case "CheckOutNotesList":
                    wo.iNoteTypeId = 4;
                    ReportViewerControl.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource, wo.GetNotesList()));
                    break;

                case "CheckInDetails":
                    ReportViewerControl.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource, wo.CheckInDetailsForReport(url)));
                    break;

                case "InstructionList":
                    ReportViewerControl.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource, wo.GetInstructionByCheckIn()));
                    break;

                case "InspectionDetail":
                    ReportViewerControl.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource, wo.GetInspectionDetailForReport()));
                    break;

                case "InspectionItemsList":
                    ReportViewerControl.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource, wo.GetInspectionItemsListForReport()));
                    break;

                case "InspectionList":
                    ReportViewerControl.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource, wo.GetInspectionListForReport()));
                    break;
                }
            }
        }
Exemple #4
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            string sTypeName;

            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                if (Request.QueryString["id"] == null)
                {
                    Session["lastpage"] = "main.aspx";
                    Session["error"]    = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    OrderId = Convert.ToInt32(Request.QueryString["id"]);
                }
                catch (FormatException fex)
                {
                    Session["lastpage"] = "main.aspx";
                    Session["error"]    = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                NextBackControl.BackPage    = "wo_addInspections.aspx?id=" + OrderId.ToString();
                NextBackControl.BackVisible = true;
                NextBackControl.NextText    = "Open/Finish";

                if (!IsPostBack)
                {
                    hlStart.NavigateUrl       = "wo_openWorkOrder.aspx?id=" + OrderId.ToString();
                    hlInspections.NavigateUrl = "wo_addInspections.aspx?id=" + OrderId.ToString();
                    hlIssues.NavigateUrl      = "wo_addRepairs.aspx?id=" + OrderId.ToString() + "&back=open";
                    hlPMItems.NavigateUrl     = "wo_addPreventiveMaintenance.aspx?id=" + OrderId.ToString() + "&back=preview";

                    dtCustomFields = new DataTable();
                    dtCustomFields.Columns.Add("ValueName");
                    dtCustomFields.Columns.Add("Value");

                    order         = new clsWorkOrders();
                    order.cAction = "S";
                    order.iOrgId  = OrgId;
                    order.iId     = OrderId;
                    if (order.WorkOrderDetails() == -1)
                    {
                        Session["lastpage"] = "wo_addInspections.aspx?id=" + OrderId.ToString();
                        Session["error"]    = _functions.ErrorMessage(120);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    if (order.iStatusId.Value != (int)WorkOrderStatus.Scheduled ||
                        order.iOperatorStatusId.Value != (int)WorkOrderOperatorStatus.Checked_In)
                    {
                        Signature.sError            = _functions.ErrorMessage(144);
                        NextBackControl.NextEnabled = false;
                    }


                    // showing main info
                    lblWorkOrderN.Text     = order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString();
                    lblWOType.Text         = order.sType.Value;
                    lblStatus.Text         = order.sStatusId.Value;
                    lblOperatorStatus.Text = order.sOperatorStatus.Value;
                    lblOperator.Text       = order.sOperatorName.Value;
                    lblStaying.Text        = order.bStaying.IsNull?"not defined":(order.bStaying.Value?"Yes":"No");
                    lblSpare.Text          = order.sSpareEquipId.Value;
                    lblTech.Text           = order.sTechName.Value;
                    lblDroppedOffBy.Text   = order.sDropedOffBy.Value;
                    lblArrivalDate.Text    = order.daArrival.IsNull?"":order.daArrival.Value.ToLongDateString();
                    lblScheduledDate.Text  = order.daScheduled.Value.ToLongDateString();

                    hlEquipId.Text        = order.sEquipId.Value;
                    hlEquipId.NavigateUrl = "e_view.aspx?id=" + order.iEquipId.Value.ToString();
                    lblType.Text          = order.sEquipTypeName.Value;
                    lblMakeModel.Text     = order.sEquipMakeModel.Value;
                    lblYear.Text          = (order.sEquipYear.Value == "0")?"unknown":order.sEquipYear.Value;
                    lblUnits.Text         = Convert.ToDouble(order.dmMileage.Value).ToString();

                    // showing issues
                    dsRepairs = order.GetReportedIssueLists();
                    if (dsRepairs.Tables[0].Rows.Count > 0)
                    {
                        html_tblNoneIssues.Visible = false;
                    }
                    else
                    {
                        html_tblNoneIssues.Visible = true;
                    }
                    repIssues.DataSource = new DataView(dsRepairs.Tables[0]);
                    repIssues.DataBind();

                    // showing the pm items
                    dwPMItems           = new DataView(order.GetPMServicesListForWorkOrder());
                    dwPMItems.RowFilter = "IsChecked='True'";
                    if (dwPMItems.Count > 0)
                    {
                        html_tblNonePMItems.Visible = false;
                    }
                    else
                    {
                        html_tblNonePMItems.Visible = true;
                    }
                    repPMItems.DataSource = dwPMItems;
                    repPMItems.DataBind();

                    // showing the inspections
                    dwInspections           = new DataView(order.GetInspectionsListForWorkOrder());
                    dwInspections.RowFilter = "IsChecked='True'";
                    if (dwInspections.Count > 0)
                    {
                        html_tblNoneInspections.Visible = false;
                    }
                    else
                    {
                        html_tblNoneInspections.Visible = true;
                    }
                    repInspections.DataSource = dwInspections;
                    repInspections.DataBind();

                    // showing notes

                    order.iItemId               = OrderId;
                    order.iNoteTypeId           = (int)NoteTypes.CreationNote;
                    repCreationNotes.DataSource = new DataView(order.GetNotesList());
                    repCreationNotes.DataBind();

                    order.iNoteTypeId           = (int)NoteTypes.OperatorNote;
                    repOperatorNotes.DataSource = new DataView(order.GetNotesList());
                    repOperatorNotes.DataBind();

                    #region Showing custom fields of order on screen
                    dtCustomFieldsFromDB = order.WorkOrderDetail_CustomFields(null);

                    if (dtCustomFieldsFromDB.Rows.Count > 0)
                    {
                        arrCFD = _functions.GetCustomFields(CFDataType.WorkOrder, 0, HttpContext.Current.User.Identity.Name);
                        if (arrCFD.Count > 0)
                        {
                            // fill custom fields
                            for (int j = 0; j < arrCFD.Count; j++)
                            {
                                cfd       = (clsCustomFieldsDef)arrCFD[j];
                                sTypeName = _functions.GetFieldTypeText(cfd.FieldTypeId) + cfd.NumberColumn.ToString();

                                switch (cfd.FieldTypeId)
                                {
                                case DBFieldType._lookup:
                                    switch (cfd.NameLookupTable)
                                    {
                                    case "EquipModels":
                                        if (dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value)
                                        {
                                            dtCustomFields.Rows.Add(new object [] { "Make/Model", "" });
                                        }
                                        else
                                        {
                                            mm          = new clsMakesModels();
                                            mm.iOrgId   = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                                            mm.iModelId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]);
                                            mm.GetModelMakes();
                                            dtCustomFields.Rows.Add(new object [] { "Make/Model", mm.sMakeName + "/" + mm.sModelName });
                                            if (mm != null)
                                            {
                                                mm.Dispose();
                                            }
                                        }
                                        break;

                                    case "Departments":
                                        if (dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value)
                                        {
                                            dtCustomFields.Rows.Add(new object [] { cfd.NameText, "" });
                                        }
                                        else
                                        {
                                            dep         = new clsDepartments();
                                            dep.cAction = "S";
                                            dep.iOrgId  = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                                            dep.iId     = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]);
                                            if (dep.DepartmentDetail() == 0)
                                            {
                                                dtCustomFields.Rows.Add(new object [] { cfd.NameText, dep.sName.Value });
                                            }
                                            else
                                            {
                                                dtCustomFields.Rows.Add(new object [] { cfd.NameText, "" });
                                            }
                                            if (dep != null)
                                            {
                                                dep.Dispose();
                                            }
                                        }
                                        break;

                                    case "Locations":
                                        if (dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value)
                                        {
                                            dtCustomFields.Rows.Add(new object [] { cfd.NameText, "" });
                                        }
                                        else
                                        {
                                            loc         = new clsLocations();
                                            loc.cAction = "S";
                                            loc.iOrgId  = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                                            loc.iId     = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]);
                                            if (loc.LocationDetail() == 0)
                                            {
                                                dtCustomFields.Rows.Add(new object [] { cfd.NameText, loc.sName.Value });
                                            }
                                            else
                                            {
                                                dtCustomFields.Rows.Add(new object [] { cfd.NameText, "" });
                                            }
                                            if (loc != null)
                                            {
                                                loc.Dispose();
                                            }
                                        }
                                        break;

                                    default:
                                        break;
                                    }
                                    break;

                                case DBFieldType._datetime:
                                    if (dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value)
                                    {
                                        dtCustomFields.Rows.Add(new object [] { cfd.NameText, "" });
                                    }
                                    else
                                    {
                                        dtCustomFields.Rows.Add(new object [] { cfd.NameText, ((DateTime)dtCustomFieldsFromDB.Rows[0][sTypeName]).ToShortDateString() });
                                    }
                                    break;

                                case DBFieldType._bit:
                                    if (dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value)
                                    {
                                        dtCustomFields.Rows.Add(new object [] { cfd.NameText, "" });
                                    }
                                    else
                                    {
                                        if (((bool)dtCustomFieldsFromDB.Rows[0][sTypeName]) == true)
                                        {
                                            dtCustomFields.Rows.Add(new object [] { cfd.NameText, "Yes" });
                                        }
                                        else
                                        {
                                            dtCustomFields.Rows.Add(new object [] { cfd.NameText, "No" });
                                        }
                                    }
                                    break;

                                default:
                                    if (dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value)
                                    {
                                        dtCustomFields.Rows.Add(new object [] { cfd.NameText, "" });
                                    }
                                    else
                                    {
                                        dtCustomFields.Rows.Add(new object [] { cfd.NameText, dtCustomFieldsFromDB.Rows[0][sTypeName] });
                                    }
                                    break;
                                }
                                cfd = null;
                            }

                            // showing a Equipment's data from custom fields
                            repCustomFields.DataSource = new DataView(dtCustomFields);
                            repCustomFields.DataBind();
                        }
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = "wo_addInspections.aspx?id=" + OrderId.ToString();
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (order != null)
                {
                    order.Dispose();
                }
            }
        }