Ejemplo n.º 1
0
        private void btSave_FormSubmit(object sender, EventArgs e)
        {
            DateTime daCurrentDate;
            try
            {
                daCurrentDate = DateTime.Now;
                order = new clsWorkOrders();
                order.iOrgId = OrgId;
                order.iId = OrderId;
                order.sInitials = Signature.sInitials;
                order.sPIN = Signature.sPIN;
                order.dmMileage = Convert.ToDecimal(tbMileage.Text);
                order.bStaying = Convert.ToBoolean(rblStaying.SelectedValue);
                order.sDropedOffBy = tbDroppedOffBy.Text;
                order.daCurrentDate = _functions.CorrectDate(adtCheckIn.Date);
                if(order.SigningEquipmentCheckIn() == -1)
                {
                    Signature.sError = _functions.ErrorMessage(140);
                }
                else
                {
                    order.cAction = "U";
                    order.iNoteId = 0;
                    order.iItemId = OrderId;
                    order.daCreated = daCurrentDate;

                    if(tbNotes.Text.Length > 0)
                    {
                        order.iNoteTypeId = (int)NoteTypes.OperatorNote;
                        order.sNote = tbNotes.Text;
                        order.NoteDetails();
                    }

                    // redirect to the finish screen
                    BackFinishScreen finish = new BackFinishScreen();

                    finish.sMainText = "The Equipment has been checked-in successfully!";

                    finish.bMainMenuVisible = true;
                    finish.sMainMenuText = "[Return to Main Menu]";
                    finish.sMainMenuURL = "main.aspx";

                    finish.bContinueVisible = true;
                    finish.sContinueText = "[Continue to Open Work Order]";
                    finish.sContinueURL = "wo_openWorkOrder.aspx?id=" + OrderId.ToString();

                    finish.bViewVisible = true;
                    finish.sViewText = "[Return to Work Order Detail]";
                    finish.sViewURL = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();

                    finish.bAdditionalVisible = false;

                    finish.bPrintVisible = false;

                    Session["BackFinish"] = finish;

                    Response.Redirect("wo_finish.aspx", false);
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "wo_viewCheckIn.aspx?id=" + OrderId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Procedure is adding a new work order into database and redirecting to finish screen
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btNext_FormSubmit(object sender, EventArgs e)
        {
            string sDataGridName;
            DBFieldType FieldType;
            DateTime daTmpForFixBug, daCurrent;
            try
            {
                daCurrent = DateTime.Now;
                if(adtScheduled.Date < daCurrent)
                {
                    lblErrorScheduled.Text = "The Scheduled date must be in future";
                    return;
                }
                order = new clsWorkOrders();
                order.iOrgId = OrgId;
                order.iEquipId = EquipId;
                if(adtScheduled.Date.Hour == 0 || adtScheduled.Date.Hour == 12)
                {
                    daTmpForFixBug = adtScheduled.Date;
                    if(daTmpForFixBug.Hour == 0)daTmpForFixBug = daTmpForFixBug.AddHours(12);
                    else daTmpForFixBug = daTmpForFixBug.AddHours(-12);
                }
                else
                    daTmpForFixBug = adtScheduled.Date;
                order.daScheduled = daTmpForFixBug;
                order.iInspectSchedDetailId = InspectSchedDetailId;
                order.iUserId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                order.daCurrentDate = daCurrent;
                order.SetInspectWorkOrder();

                if(tbNotes.Text.Length > 0)
                {
                    order.cAction = "U";
                    order.iNoteId = 0;
                    order.iNoteTypeId = (int)NoteTypes.CreationNote;
                    order.iItemId = order.iId;
                    order.daCreated = daCurrent;
                    order.sNote = tbNotes.Text;
                    order.NoteDetails();
                }

                BackFinishScreen finish = new BackFinishScreen();

                finish.sMainText = "The Work Order with Inspection has been created successfully.";

                finish.bMainMenuVisible = true;
                finish.sMainMenuText = "[Return to Main Menu]";
                finish.sMainMenuURL = "main.aspx";

                finish.bContinueVisible = true;
                finish.sContinueText = "[Create a New Future Work Order with Inspection]";
                finish.sContinueURL = "wo_showEquipsForInspect.aspx";

                finish.bViewVisible = true;
                finish.sViewText = "[View a new Work Order with Inspection]";
                finish.sViewURL = "wo_viewWorkOrder.aspx?id=" +  order.iId.Value.ToString();

                finish.bAdditionalVisible = false;

                finish.bPrintVisible = false;

                Session["BackFinish"] = finish;

                Response.Redirect("wo_finish.aspx", false);

            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "wo_addInspectForecast.aspx?equipid=" + EquipId.ToString() + "&sid=" + InspectSchedDetailId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }
Ejemplo n.º 3
0
        private void lbSaveNotes_Click(object sender, System.EventArgs e)
        {
            try
            {
                Header.BodyOnloadScript  = "javascript:document.location='#Notes'";
                //Header.Render();

                order = new clsWorkOrders();
                order.cAction = "U";
                order.iOrgId = OrgId;
                order.iNoteId = 0;
                order.iNoteTypeId = (int)NoteTypes.TechnicianNote;
                order.iItemId = OrderId;
                order.daCreated = DateTime.Now;
                order.sNote = tbNotes.Text;
                order.iUserId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                order.NoteDetails();
                tbNotes.Text = "";
                order.iNoteTypeId = (int)NoteTypes.TechnicianNote;
                repTechNotes.DataSource = new DataView(order.GetNotesList());
                repTechNotes.DataBind();
            }
            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();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Procedure close and sign the work order
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btSave_FormSubmit(object sender, EventArgs e)
        {
            string sDataGridName;
            DBFieldType FieldType;
            DateTime daCurrentDate;
            try
            {
                daCurrentDate = DateTime.Now;
                order = new clsWorkOrders();
                order.iOrgId = OrgId;
                order.iId = OrderId;
                order.iUserId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                order.sInitials = Signature.sInitials;
                order.sPIN = Signature.sPIN;
                order.sCleanliness = tbCleanliness.Text;
                order.daCurrentDate = _functions.CorrectDate(adtClosed.Date);
                if(order.SigningWorkOrderClose() == -1)
                {
                    Signature.sError = _functions.ErrorMessage(140);
                }
                else
                {
                    order.cAction = "U";
                    order.iNoteId = 0;
                    order.iItemId = OrderId;
                    order.daCreated = daCurrentDate;

                    if(tbTechNote.Text.Length > 0)
                    {
                        order.iNoteTypeId = (int)NoteTypes.TechnicianNote;
                        order.sNote = tbTechNote.Text;
                        order.NoteDetails();
                    }
                    if(tbCheckOutNote.Text.Length > 0)
                    {
                        order.iNoteTypeId = (int)NoteTypes.CheckOutNote;
                        order.sNote = tbCheckOutNote.Text;
                        order.NoteDetails();
                    }

                    #region saving cutom fields
                    if(ViewState["CustomFields"] != null)
                    {
                        order.iId = OrderId;
                        dtCustomFields = (DataTable)ViewState["CustomFields"];

                        sDataGridName = repCustomFields.ClientID;

                        // getting data from Form and changing the dtCustomFields datatable
                        for(int i=0; i<dtCustomFields.Rows.Count; i++)
                        {
                            for(int j=0; j<Request.Form.Count; j++)
                            {
                                if((string)dtCustomFields.Rows[i]["TypeName"] == Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":inputTypeName"])
                                {
                                    FieldType = _functions.TypeNameParser((string)dtCustomFields.Rows[i]["TypeName"]); // nvarchar1...n, ...
                                    switch(FieldType)
                                    {
                                        case DBFieldType._nvarchar:
                                            dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":tbValue"];
                                            break;
                                        case DBFieldType._int:
                                            dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":tbValue"];
                                            break;
                                        case DBFieldType._float:
                                            dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":tbValue"];
                                            break;
                                        case DBFieldType._datetime:
                                            dtCustomFields.Rows[i]["Value_String"] = new SqlDateTime(Convert.ToInt32(Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":adtValue_year"]),
                                                Convert.ToInt32(Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":adtValue_month"]),
                                                Convert.ToInt32(Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":adtValue_day"]));
                                            break;
                                        case DBFieldType._bit:
                                            if(Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":chValue"] != null)
                                            {
                                                dtCustomFields.Rows[i]["Value_String"] = "True";
                                            }
                                            else
                                            {
                                                dtCustomFields.Rows[i]["Value_String"] = "False";
                                            }
                                            break;
                                        case DBFieldType._ntext:
                                            dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":tbValue"];
                                            break;
                                        case DBFieldType._sql_variant:
                                            dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":tbValue"];
                                            break;
                                        case DBFieldType._lookup:
                                            dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":ddlValue"];
                                            break;
                                        default:
                                            dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":tbValue"];
                                            break;
                                    }
                                }
                            }
                        }

                        // saving data to database
                        order.WorkOrderDetail_CustomFields(_functions.SetDataToParameters(dtCustomFields));
                    }
                    #endregion

                    // redirect to the finish screen
                    BackFinishScreen finish = new BackFinishScreen();

                    finish.sMainText = "The Work Order closed successfully!";

                    finish.bMainMenuVisible = true;
                    finish.sMainMenuText = "[Return to Main Menu]";
                    finish.sMainMenuURL = "main.aspx";

                    finish.bContinueVisible = true;
                    finish.sContinueText = "[Continue to Check-Out Equipment by Technician]";
                    finish.sContinueURL = "wo_viewCheckOut.aspx?id=" + OrderId.ToString();

                    finish.bViewVisible = true;
                    finish.sViewText = "[Return to Work Order Detail]";
                    finish.sViewURL = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();

                    finish.bAdditionalVisible = false;

                    finish.bPrintVisible = true;
                    finish.sPrintText = "[Print the Closed Work Order]";
                    finish.sPrintURL = "ReportViewer.aspx?Report=FleetProReports%2fCompletedOrder&OrderId=" + OrderId.ToString()+ "&OrgId=" + OrgId.ToString();

                    Session["BackFinish"] = finish;

                    Response.Redirect("wo_finish.aspx", false);
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "wo_closeWorkOrder.aspx?id=" + OrderId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(order != null)
                {
                    order.Dispose();
                }
            }
        }
Ejemplo n.º 5
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"] = "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;
                }

                // 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());

                SaveCancelControl.ParentPageURL = this.ParentPageURL;
                SaveCancelControl.ButtonText = "  Close & Sign  ";

                if(!IsPostBack)
                {
                    order = new clsWorkOrders();
                    user = new clsUsers();

                    order.cAction = "S";
                    order.iOrgId = OrgId;
                    order.iId = OrderId;
                    if(order.WorkOrderDetails() == -1)
                    {
                        Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();;
                        Session["error"] = _functions.ErrorMessage(120);
                        Response.Redirect("error.aspx", false);
                        return;
                    }

                    if(!user.IsTechnician(_functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true)))
                    {
                        Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();
                        Session["error"] = _functions.ErrorMessage(131);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    if(order.iTechId.Value == 0)
                    {
                        Signature.sError = _functions.ErrorMessage(143);
                        SaveCancelControl.EnableSave = false;
                    }
                    if(order.GetCompleteAbleOrder() != 1)
                    {
                        Signature.sError = _functions.ErrorMessage(142);
                        SaveCancelControl.EnableSave = false;
                    }

                    lblWorkOrderId.Text = order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString();
                    lblEquipId.Text = order.sEquipId.Value;
                    lblSpareEquipId.Text = order.sSpareEquipId.Value;
                    lblTech.Text = order.sTechName.Value;
                    lblOperator.Text = order.sOperatorName.Value;
                    tbCleanliness.Text = order.sCleanliness.Value;
                    if(order.daClosed.IsNull)
                        adtClosed.Date = DateTime.Now;
                    else
                        adtClosed.Date = order.daClosed.Value;

                    if(order.iStatusId.Value == (int)WorkOrderStatus.Closed
                        || order.iStatusId.Value == (int)WorkOrderStatus.Scheduled)
                    {
                        tbCleanliness.Enabled = false;
                        tbTechNote.Enabled = false;
                        tbCheckOutNote.Enabled = false;
                        Signature.Enabled = false;
                        SaveCancelControl.EnableSave = false;
                        Signature.sError = _functions.ErrorMessage(141);
                    }
                    // show notes
                    order.iItemId = OrderId;
                    order.iNoteTypeId = (int)NoteTypes.TechnicianNote;
                    repTechNotes.DataSource = new DataView(order.GetNotesList());
                    repTechNotes.DataBind();

                    order.iNoteId = 0;
                    order.iNoteTypeId = (int)NoteTypes.CheckOutNote;
                    if(order.NoteDetails() != -1)
                    {
                        tbCheckOutNote.Text = order.sNote.Value;
                    }

                    ShowCustomFields();
                }
            }
            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(user != null)
                    user.Dispose();
                if(order != null)
                    order.Dispose();
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Procedure is adding a new work order into database and redirecting to next screen
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btNext_FormSubmit(object sender, EventArgs e)
        {
            string sDataGridName;
            DBFieldType FieldType;
            DateTime daCurrent, CorrectDate;
            try
            {
                #region saving the static data
                order = new clsWorkOrders();
                if(IsPast)
                {
                    order.cAction = "U";
                    order.bWizardUpdate = true;
                    order.iOrgId = OrgId;
                    order.iId = OrderId;
                    order.iEquipId = EquipId;
                    order.iStatusId = (int)WorkOrderStatus.Scheduled;
                    CorrectDate = _functions.CorrectDate(adtScheduled.Date);
                    daCurrent = CorrectDate;
                    order.daScheduled = CorrectDate;
                    order.iTypeId = Convert.ToInt32(rblWOTypes.SelectedValue);
                    order.sDecs = tbNotes.Text;
                    order.iUserId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                    order.daUpdated = daCurrent;
                    order.daCreated = daCurrent;
                }
                else
                {
                    daCurrent = DateTime.Now;
                    CorrectDate = _functions.CorrectDate(adtScheduled.Date);
                    if(CorrectDate < daCurrent)
                    {
                        Header.ErrorMessage = "The Scheduled date must be in future";
                        ShowCustomFields();
                        return;
                    }
                    if(Convert.ToInt32(rblWOTypes.SelectedValue) < 1)
                    {
                        Header.ErrorMessage = "Work Order Type is required";
                        ShowCustomFields();
                        return;
                    }

                    order.cAction = "U";
                    order.bWizardUpdate = true;
                    order.iOrgId = OrgId;
                    order.iId = OrderId;
                    order.iEquipId = EquipId;

                    order.iStatusId = (int)WorkOrderStatus.Scheduled;

                    order.daScheduled = CorrectDate;

                    order.iTypeId = Convert.ToInt32(rblWOTypes.SelectedValue);
                    order.sDecs = tbNotes.Text;

                    order.iUserId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                    order.daUpdated = daCurrent;
                    order.daCreated = daCurrent;
                }
                if(OrderId == 0)OrderId = order.WorkOrderDetails();
                else order.WorkOrderDetails();

                if(tbNotes.Text.Length > 0)
                {
                    order.iNoteId = (int)ViewState["NoteId"];
                    order.iNoteTypeId = (int)NoteTypes.CreationNote;
                    order.iItemId = OrderId;
                    order.daCreated = daCurrent;
                    order.sNote = tbNotes.Text;
                    order.NoteDetails();
                }

                #endregion

                #region saving cutom fields
                if(ViewState["CustomFields"] != null)
                {
                    order.iId = OrderId;
                    dtCustomFields = (DataTable)ViewState["CustomFields"];

                    sDataGridName = repCustomFields.ClientID;

                    // getting data from Form and changing the dtCustomFields datatable
                    for(int i=0; i<dtCustomFields.Rows.Count; i++)
                    {
                        for(int j=0; j<Request.Form.Count; j++)
                        {
                            if((string)dtCustomFields.Rows[i]["TypeName"] == Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":inputTypeName"])
                            {
                                FieldType = _functions.TypeNameParser((string)dtCustomFields.Rows[i]["TypeName"]); // nvarchar1...n, ...
                                switch(FieldType)
                                {
                                    case DBFieldType._nvarchar:
                                        dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":tbValue"];
                                        break;
                                    case DBFieldType._int:
                                        dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":tbValue"];
                                        break;
                                    case DBFieldType._float:
                                        dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":tbValue"];
                                        break;
                                    case DBFieldType._datetime:
                                        dtCustomFields.Rows[i]["Value_String"] = new SqlDateTime(Convert.ToInt32(Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":adtValue_year"]),
                                            Convert.ToInt32(Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":adtValue_month"]),
                                            Convert.ToInt32(Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":adtValue_day"]));
                                        break;
                                    case DBFieldType._bit:
                                        if(Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":chValue"] != null)
                                        {
                                            dtCustomFields.Rows[i]["Value_String"] = "True";
                                        }
                                        else
                                        {
                                            dtCustomFields.Rows[i]["Value_String"] = "False";
                                        }
                                        break;
                                    case DBFieldType._ntext:
                                        dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":tbValue"];
                                        break;
                                    case DBFieldType._sql_variant:
                                        dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":tbValue"];
                                        break;
                                    case DBFieldType._lookup:
                                        dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":ddlValue"];
                                        break;
                                    default:
                                        dtCustomFields.Rows[i]["Value_String"] = Request.Form[sDataGridName + ":_ctl" + j.ToString() + ":tbValue"];
                                        break;
                                }
                            }
                        }
                    }

                    // saving data to database
                    order.WorkOrderDetail_CustomFields(_functions.SetDataToParameters(dtCustomFields));
                }
                #endregion

                // redirect to next screen
                if(IsPast)
                    Response.Redirect("wo_addInspections.aspx?id=" + OrderId.ToString() + "&back=past", false);
                else
                    Response.Redirect("wo_addRepairs.aspx?id=" + OrderId.ToString(), false);
            }
            catch(FormatException fex)
            {
                Session["lastpage"] = m_sLastPage;
                Session["error"] = _functions.ErrorMessage(108);
                Response.Redirect("error.aspx", 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();
                }
            }
        }
Ejemplo n.º 7
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            DateTime dtCurrentDate;
            try
            {
                SourcePageName = "wo_editAddInfo.aspx.cs";

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

                if(Request.QueryString["id"] == null || Request.QueryString["equipid"] == null)
                {
                    Session["lastpage"] = "wo_default.aspx";
                    Session["error"] = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    EquipId = Convert.ToInt32(Request.QueryString["equipid"]);
                    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;
                }
                if(EquipId == 0 && OrderId == 0)
                {
                    Session["lastpage"] = "wo_default.aspx";
                    Session["error"] = _functions.ErrorMessage(102);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                m_sLastPage = "wo_editAddInfo.aspx?id=" + OrderId.ToString() + "&equipid=" + EquipId.ToString();
                if(Request.QueryString["back"] != null)
                    if(Request.QueryString["back"] == "past")
                    {
                        IsPast = true;
                        this.PageTitle = "Create the Past Work Order";
                        m_sLastPage = "wo_editAddInfo.aspx?back=past&id=" + OrderId.ToString() + "&equipid=" + EquipId.ToString();
                    }

                NextBackControl.BackVisible = false;
                if(!IsPostBack)
                {
                    dtCurrentDate = DateTime.Now;
                    // getting the main (fixed) data
                    order = new clsWorkOrders();

                    rblWOTypes.DataSource = order.GetTypesList();
                    rblWOTypes.DataBind();

                    order.iOrgId = OrgId;
                    order.iEquipId = EquipId;
                    order.iId = OrderId;

                    if(order.GetInfoForWorkOrder() == -1)
                    {
                        Session["lastpage"] = "wo_default.aspx";
                        Session["error"] = _functions.ErrorMessage(102);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    lblEquipId.Text = order.sEquipId.Value;
                    if(order.iTypeId.Value != 0)
                        rblWOTypes.SelectedValue = order.iTypeId.Value.ToString();
                    if(!order.daScheduled.IsNull)
                        adtScheduled.Date = order.daScheduled.Value;
                    else
                        adtScheduled.Date = dtCurrentDate.AddMinutes(60-dtCurrentDate.Minute);

                    if(OrderId != 0)
                    {
                        order.cAction = "S";
                        order.iNoteId = 0;
                        order.iNoteTypeId = (int)NoteTypes.CreationNote;
                        order.iItemId = OrderId;
                        if(order.NoteDetails() != -1)
                        {
                            tbNotes.Text = order.sNote.Value;
                            ViewState["NoteId"] = order.iNoteId.Value;
                        }
                        else
                            ViewState["NoteId"] = 0;
                    }
                    else
                        ViewState["NoteId"] = 0;

                    ShowCustomFields();
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "wo_default.aspx";
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(user != null)
                    user.Dispose();
                if(order != null)
                    order.Dispose();
                if(equip != null)
                    equip.Dispose();
            }
        }
Ejemplo n.º 8
0
        private void btnSaveNote_Click(object sender, System.EventArgs e)
        {
            DateTime daCurrentDate;
            try
            {
                daCurrentDate = DateTime.Now;
                order = new clsWorkOrders();
                order.cAction = "U";
                order.iOrgId = OrgId;
                order.iNoteId = 0;
                order.iNoteTypeId = (int)NoteTypes.OperatorNote;
                order.iItemId = OrderId;
                order.iUserId = op.Id;
                order.daCreated = daCurrentDate;
                order.sNote = tbNotes.Text;
                order.NoteDetails();

                if(Operation == "CheckIn")
                {
                    order.iId = OrderId;
                    order.daCurrentDate = daCurrentDate;
                    order.iUserId = op.Id;
                    if(order.UpdateCheckInWorkOrder() == -1)
                    {
                        Session["lastpage"] = CurrentPage;
                        Session["error"] = _functions.ErrorMessage(120);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    else
                        Response.Redirect("ok_viewCheckIn.aspx?orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString(), false);
                }
                else
                {
                    if(Operation == "AddCommentReOpen")
                        Response.Redirect(BackPage + "&op=AddCommentReOpen", false);
                    else
                        Response.Redirect(BackPage, false);
                }

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