コード例 #1
0
ファイル: wo_viewDates.aspx.cs プロジェクト: bigWebApps/Fleet
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                SourcePageName = "wo_viewDates.aspx.cs";

                Header.MainMenuVisible = false;
                Header.Visible = false;

                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                OrderId = Convert.ToInt32(Request.QueryString["id"]);

                order = new clsWorkOrders();
                order.cAction = "S";
                order.iOrgId = OrgId;
                order.iId = OrderId;
                if(order.WorkOrderDetails() != -1)
                {
                    lblDateCreated.Text = order.daCreated.Value.ToLongDateString();
                    lblArrivalDate.Text = order.daArrival.IsNull?"":order.daArrival.Value.ToLongDateString();
                    lblDateScheduled.Text = order.daScheduled.IsNull?"":order.daScheduled.Value.ToLongDateString() + " " + order.daScheduled.Value.ToLongTimeString();
                    lblDateOpened.Text = order.daOpened.IsNull?"":order.daOpened.Value.ToLongDateString();
                    lblDateClosed.Text = order.daClosed.IsNull?"":order.daClosed.Value.ToLongDateString();
                    lblDepartureDate.Text = order.daDeparture.IsNull?"":order.daDeparture.Value.ToLongDateString();
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }
コード例 #2
0
        /// <summary>
        /// Procedure is updating the work order info
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btSave_FormSubmit(object sender, EventArgs e)
        {
            string sDataGridName;
            DBFieldType FieldType;
            DateTime daCurrentDate, daScheduled;
            try
            {
                #region saving the static data
                daCurrentDate = DateTime.Now;
                status = (WorkOrderStatus)ViewState["StatusId"];
                order = new clsWorkOrders();
                order.cAction = "U";
                order.bWizardUpdate = false;
                order.iOrgId = OrgId;
                order.iId = OrderId;
                order.iTypeId = Convert.ToInt32(rblWOTypes.SelectedValue);
                order.iTechId = Convert.ToInt32(ddlTech.SelectedValue);
                order.bStaying = Convert.ToBoolean(rblStaying.SelectedValue);
                order.sDropedOffBy = tbDroppedOffBy.Text;
                order.sReleasedTo = tbReleasedTo.Text;
                order.sCleanliness = tbCleanliness.Text;
                order.iUserId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);

                if(ViewState["ScheduledDate"] == null)
                {
                    order.daScheduled = _functions.CorrectDate(adtScheduled.Date);
                }
                else
                    order.daScheduled = (DateTime)ViewState["ScheduledDate"];
                if(trCheckInDate.Visible)
                    order.daArrival = _functions.CorrectDate(adtCheckIn.Date);
                if(trOpenedDate.Visible)
                    order.daOpened = _functions.CorrectDate(adtOpened.Date);
                if(trClosedDate.Visible)
                    order.daClosed = _functions.CorrectDate(adtClosed.Date);
                if(trCheckOutDate.Visible)
                    order.daDeparture = _functions.CorrectDate(adtCheckOut.Date);
                order.daUpdated = daCurrentDate;
                if(order.WorkOrderDetails() == -1)
                {
                    Session["lastpage"] = "wo_editWorkOrder.aspx?id=" + OrderId.ToString();
                    Session["error"] = _functions.ErrorMessage(120);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                #endregion

                if(status == WorkOrderStatus.Open || status == WorkOrderStatus.ReOpened)
                {
                    #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
                }
                Response.Redirect("wo_viewWorkOrder.aspx?id=" + OrderId.ToString() + "&#Main", false);
            }
            catch(FormatException fex)
            {
                Session["lastpage"] = "wo_editWorkOrder.aspx?id=" + OrderId.ToString();
                Session["error"] = _functions.ErrorMessage(108);
                Response.Redirect("error.aspx", false);
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "wo_editWorkOrder.aspx?id=" + OrderId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(order != null)
                {
                    order.Dispose();
                }
            }
        }
コード例 #3
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() + "&#Main");

                SaveCancelControl.ParentPageURL = this.ParentPageURL;

                if(!IsPostBack)
                {
                    order = new clsWorkOrders();
                    user = new clsUsers();
                    order.cAction = "S";
                    order.iOrgId = OrgId;
                    order.iId = OrderId;
                    user.iOrgId = OrgId;
                    user.iTypeId = (int)UserTypes.Technician;

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

                    ddlTech.DataSource = new DataView(user.GetUserListByType());
                    ddlTech.DataBind();

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

                    status = (WorkOrderStatus)order.iStatusId.Value;
                    opstatus = order.iOperatorStatusId.IsNull?WorkOrderOperatorStatus.Null:(WorkOrderOperatorStatus)order.iOperatorStatusId.Value;

                    ViewState["StatusId"] = status;

                    lblWorkOrderId.Text = order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString();
                    rblWOTypes.SelectedValue = order.iTypeId.Value.ToString();
                    hlEquipId.Text = order.sEquipId.Value;
                    hlEquipId.NavigateUrl = "e_view.aspx?id=" + order.iEquipId.Value.ToString();
                    hlSpareEquipId.Text = order.sSpareEquipId.Value;
                    hlChangeSpare.NavigateUrl = "wo_selectSpareEquip.aspx?id=" + OrderId.ToString() + "&back=edit";
                    if(order.iSpareEquipId.Value > 0)
                        hlSpareEquipId.NavigateUrl = "e_view.aspx?id=" + order.iSpareEquipId.Value.ToString();
                    if(order.iTechId.Value != 0)
                    {
                        ddlTech.Items.Remove(ddlTech.Items[0]);
                        if(ddlTech.Items.FindByValue(order.iTechId.Value.ToString()) != null)
                            ddlTech.SelectedValue = order.iTechId.Value.ToString();
                        else
                            Header.ErrorMessage = "Cannot find the assigned technician in the technician list";
                    }
                    lblOperator.Text = order.sOperatorName.Value;

                    if(order.bStaying.Value)
                        rblStaying.SelectedValue = "True";
                    else
                        rblStaying.SelectedValue = "False";
                    tbDroppedOffBy.Text = order.sDropedOffBy.Value;
                    tbReleasedTo.Text = order.sReleasedTo.Value;
                    tbCleanliness.Text = order.sCleanliness.Value;
                    adtScheduled.Date = order.daScheduled.Value;
                    lblCreatedDate.Text = order.daCreated.Value.ToLongDateString();
                    switch(status)
                    {
                        case WorkOrderStatus.Scheduled: // Scheduled status
                            hlChangeSpare.Enabled = false;
                            ddlTech.Enabled = false;
                            rblStaying.Enabled = false;
                            tbDroppedOffBy.Enabled = false;
                            tbCleanliness.Enabled = false;
                            tbReleasedTo.Enabled = false;
                            adtScheduled.Enabled = true;
                            html_ScheduledDate.Visible = true;
                            SaveCancelControl.EnableSave = true;
                            if(opstatus == WorkOrderOperatorStatus.Checked_In)
                            {
                                hlChangeSpare.Enabled = true;
                                trCheckInDate.Visible = true;
                                adtCheckIn.Date = order.daArrival.Value;
                            }
                            else
                                trCheckInDate.Visible = false;
                            trCheckOutDate.Visible = false;
                            trClosedDate.Visible = false;
                            trOpenedDate.Visible = false;
                            break;
                        case WorkOrderStatus.Open: // Opened status
                            ViewState["ScheduledDate"] = order.daScheduled.Value;
                            adtScheduled.Enabled = false;
                            html_ScheduledDate.Visible = false;
                            SaveCancelControl.EnableSave = true;
                            trCheckInDate.Visible = true;
                            adtCheckIn.Date = order.daArrival.Value;
                            trOpenedDate.Visible = true;
                            adtOpened.Date = order.daOpened.Value;
                            trCheckOutDate.Visible = false;
                            trClosedDate.Visible = false;
                            break;
                        case WorkOrderStatus.ReOpened: // Opened status
                            ViewState["ScheduledDate"] = order.daScheduled.Value;
                            adtScheduled.Enabled = false;
                            html_ScheduledDate.Visible = false;
                            SaveCancelControl.EnableSave = true;
                            trCheckInDate.Visible = true;
                            adtCheckIn.Date = order.daArrival.Value;
                            trOpenedDate.Visible = true;
                            adtOpened.Date = order.daOpened.Value;
                            trCheckOutDate.Visible = false;
                            trClosedDate.Visible = false;
                            break;
                        case WorkOrderStatus.Closed: // Closed Status
                            ViewState["ScheduledDate"] = order.daScheduled.Value;
                            hlChangeSpare.Enabled = false;
                            ddlTech.Enabled = false;
                            rblStaying.Enabled = false;
                            tbDroppedOffBy.Enabled = true;
                            adtScheduled.Enabled = false;
                            html_ScheduledDate.Visible = false;
                            tbCleanliness.Enabled = true;
                            tbReleasedTo.Enabled = true;
                            SaveCancelControl.EnableSave = true;
                            trCheckInDate.Visible = true;
                            adtCheckIn.Date = order.daArrival.Value;
                            trOpenedDate.Visible = true;
                            adtOpened.Date = order.daOpened.Value;
                            trClosedDate.Visible = true;
                            adtClosed.Date = order.daClosed.Value;
                            if(opstatus  == WorkOrderOperatorStatus.Checked_Out)
                            {
                                trCheckOutDate.Visible = true;
                                adtCheckOut.Date = order.daDeparture.Value;
                            }
                            else
                                trCheckOutDate.Visible = false;
                            break;

                    }
                    if(order.iOperatorId.Value == 6)
                        hlChangeSpare.Enabled = false;

                    ShowCustomFields();

                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = this.ParentPageURL;
                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();
            }
        }
コード例 #4
0
        private void EquipmentDetails()
        {
            try
            {
                if(OrderId != 0)
                {
                    order = new clsWorkOrders();
                    order.cAction = "S";
                    order.iOrgId = OrgId;
                    order.iId = OrderId;

                    if(order.WorkOrderDetails() == -1)
                    {
                        Session["lastpage"] = "wo_default.aspx?select=AddRoadside";
                        Session["error"] = _functions.ErrorMessage(120);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    if(ddlTech.Items.FindByValue(order.iTechId.Value.ToString()) != null)
                        ddlTech.SelectedValue = order.iTechId.Value.ToString();
                    EquipId = order.iEquipId.Value;
                }

                equip = new clsEquipment();
                equip.iOrgId = OrgId;
                equip.iId = EquipId;
                equip.cAction = "S";
                if(equip.EquipmentDetail() == -1)
                {
                    Session["lastpage"] = "wo_default.aspx?select=AddRoadside";
                    Session["error"] = _functions.ErrorMessage(102);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                lblOperator.Text = equip.sEquipOperator.Value;
                lblTempOperator.Text = equip.sTempOperator.Value;
                lblEquipId.Text = equip.sEquipId.Value;
                lblEquipType.Text = equip.sType.Value;
                lblMakeModel.Text = equip.sMakeModelName.Value;
                lblYear.Text = equip.iYear.Value.ToString();
                lblSerial.Text = equip.sVinSerial.Value;
                lblEquipId2.Text = equip.sEquipId.Value;
                lblEquipType2.Text = equip.sType.Value;

            }
            catch(Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
                if(equip != null)
                    equip.Dispose();
            }
        }
コード例 #5
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                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"]);
                    OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                }
                catch(FormatException fex)
                {
                    Session["lastpage"] = "wo_default.aspx";
                    Session["error"] = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                if(Request.QueryString["repairid"] != null)
                    RepairId = Convert.ToInt32(Request.QueryString["repairid"]);
                else
                    RepairId = 0;

                html_btnBack.Attributes.Add("onclick", "document.location='wo_viewWorkOrder.aspx?id=" + OrderId.ToString() + "&#TimeLog';");
                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());
                dtNow = DateTime.Now;
                if(!IsPostBack)
                {
                    rdiStartTime.SelectedDate = dtNow;
                    rdiStopTime.SelectedDate = dtNow;
                    order = new clsWorkOrders();
                    user = new clsUsers();
                    order.cAction = "S";
                    order.iOrgId = OrgId;
                    order.iId = OrderId;
                    user.iOrgId = OrgId;
                    user.iOrderId = OrderId;
                    user.iTypeId = (int)UserTypes.Technician;

                    DataTable dtTechList = user.GetUserListByType();
                    dtTechList.Rows[0].Delete();
                    ddlTechnicians.DataSource = new DataView(dtTechList);
                    ddlTechnicians.DataBind();

                    DataTable dtRepairList = order.GetRepairsShortList();
                    dtRepairList.Rows[0].Delete();
                    ddlRepairs.DataSource = new DataView(dtRepairList);
                    ddlRepairs.DataBind();

                    if(order.WorkOrderDetails() == -1)
                    {
                        Session["lastpage"] = this.ParentPageURL;
                        Session["error"] = _functions.ErrorMessage(120);
                        Response.Redirect("error.aspx", false);
                        return;
                    }

                    if(!user.IsTechnician(_functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true)))
                    {
                        Session["lastpage"] = this.ParentPageURL;
                        Session["error"] = _functions.ErrorMessage(131);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    lblWorkOrderId.Text = order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString();
                    lblEquipId.Text = order.sEquipId.Value;
                    lblOperator.Text = order.sOperatorName.Value;
                    lblTech.Text = order.sTechName.Value;
                    if(user.GetTechnicianInfo() != -1)
                    {
                        tbHourlyRate.Text = user.dmHourlyRate.Value.ToString("F");
                        if(!user.bTechCanViewHourlyRate.Value)
                        {
                            ViewState["HourlyRate"] = user.dmHourlyRate.Value;
                            html_tblMain.Rows[12].Visible = false;
                            html_trTotalCosts.Visible = false;
                        }
                        else
                        {
                            ViewState["HourlyRate"] = null;
                            html_tblMain.Rows[12].Visible = true;
                            html_trTotalCosts.Visible = true;
                        }
                    }
                    else
                    {
                        html_trTotalCosts.Visible = true;
                        html_tblMain.Rows[12].Visible = true;
                        tbHourlyRate.Text = "0.0";
                        ViewState["HourlyRate"] = null;
                    }
                    if(ddlTechnicians.Items.FindByValue(order.iTechId.Value.ToString()) != null)
                    {
                        ddlTechnicians.SelectedValue = order.iTechId.Value.ToString();
                    }
                    else
                    {
                        ddlTechnicians.SelectedIndex = 0;
                    }
                    if(ddlRepairs.Items.FindByValue(RepairId.ToString()) != null)
                    {
                        ddlRepairs.SelectedValue = RepairId.ToString();
                    }
                    else
                    {
                        ddlRepairs.SelectedIndex = 0;
                    }
                    order.iTechId = 0;
                    dtTimeLog = order.GetTimeLogList();
                    if(dtTimeLog.Rows.Count > 0)
                    {
                        repTimeLog.DataSource = new DataView(dtTimeLog);
                        repTimeLog.DataBind();
                        html_tblNoneTimeLog.Visible = false;
                        lblTotalHours.Text = order.sReportDesc.Value;
                        lblTotalCosts.Text = order.sDecs.Value;
                    }
                    else
                    {
                        html_tblNoneTimeLog.Visible = true;
                        repTimeLog.Visible = false;
                        html_trTotalHours.Visible = false;
                        html_trTotalCosts.Visible = false;
                    }
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = this.ParentPageURL;
                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();
            }
        }
コード例 #6
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 = ParentPageURL;
                SaveCancelControl.IsCancel = true;
                SaveCancelControl.CausesValidation = true;
                SaveCancelControl.ButtonText = "  Check-Out/Sign  ";

                if(!IsPostBack)
                {
                    order = new clsWorkOrders();
                    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(order.iStatusId.Value != (int)WorkOrderStatus.Closed)
                    {
                        Signature.sError = _functions.ErrorMessage(138);
                        Signature.Enabled = false;
                        tbReleasedTo.Enabled = false;
                        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;
                    lblDroppedOffBy.Text = order.sDropedOffBy.Value;
                    tbReleasedTo.Text = order.sReleasedTo.Value;
                    lblCleanliness.Text = order.sCleanliness.Value;
                    lblScheduledDate.Text = order.daScheduled.IsNull?"":order.daScheduled.Value.ToLongDateString();
                    if(order.daDeparture.IsNull)
                        adtCheckOut.Date = DateTime.Now;
                    else
                        adtCheckOut.Date = order.daDeparture.Value;

                    order.iItemId = OrderId;
                    order.iNoteTypeId = (int)NoteTypes.CheckOutNote;

                    repCheckOutNotes.DataSource = new DataView(order.GetNotesList());
                    repCheckOutNotes.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();
            }
        }
コード例 #7
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.IsCancel = true;
                SaveCancelControl.CausesValidation = true;
                SaveCancelControl.ButtonText = "  Check-In/Sign  ";

                if(!IsPostBack)
                {
                    order = new clsWorkOrders();
                    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;
                    }

                    WorkOrderStatus status = (WorkOrderStatus)order.iStatusId.Value;
                    WorkOrderOperatorStatus opstatus = order.iOperatorStatusId.IsNull?WorkOrderOperatorStatus.Null:(WorkOrderOperatorStatus)order.iOperatorStatusId.Value;

                    if(status != WorkOrderStatus.Scheduled && opstatus != WorkOrderOperatorStatus.Null)
                    {
                        Signature.sError = _functions.ErrorMessage(136);
                        tbDroppedOffBy.Enabled = false;
                        tbMileage.Enabled = false;
                        tbNotes.Enabled = false;
                        rblStaying.Enabled = false;
                        Signature.Enabled = false;
                        SaveCancelControl.EnableSave = false;
                    }
                    lblWorkOrderId.Text = order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString();
                    hlEquipId.Text = order.sEquipId.Value;
                    hlEquipId.NavigateUrl = "e_view.aspx?id=" + order.iEquipId.Value.ToString();
                    hlSpareEquipId.Text = order.sSpareEquipId.Value;
                    hlChangeSpare.NavigateUrl = "wo_selectSpareEquip.aspx?id=" + OrderId.ToString() + "&back=checkin";
                    if(order.iOperatorId.Value == 6)
                        hlChangeSpare.Enabled = false;
                    if(order.iSpareEquipId.Value > 0)
                        hlSpareEquipId.NavigateUrl = "e_view.aspx?id=" + order.iSpareEquipId.Value.ToString();
                    lblOperator.Text = order.sOperatorName.Value;
                    if(order.bStaying.Value)
                        rblStaying.SelectedValue = "True";
                    else
                        rblStaying.SelectedValue = "False";
                    tbDroppedOffBy.Text = order.sDropedOffBy.Value;
                    adtCheckIn.Date = DateTime.Now;
                    equip = new clsEquipment();
                    equip.iOrgId = OrgId;
                    equip.iId = order.iEquipId;
                    if(equip.GetEquipInfo() == -1)
                    {
                        Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();
                        Session["error"] = _functions.ErrorMessage(102);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    tbMileage.Text = equip.dmCurrentUnits.Value.ToString("F");
                    valRangeUnits.MinimumValue = equip.dmCurrentUnits.Value.ToString();
                    valRangeUnits.ErrorMessage = "Value must be greater than was " + equip.dmCurrentUnits.Value.ToString("F") + "<br>";
                    lblMeasure.Text = equip.sMeasure.Value;

                }
            }
            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();
                if(equip != null)
                    equip.Dispose();
            }
        }
コード例 #8
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            string sTypeName;
            string sDomenName;
            string sReportPath;
            try{
                int l_iCount;

                #region Header Section
                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;
                }

                if((string)Session["PathToViewOrder"] != "Monthly-Daily")
                    l_iCount = 2;
                else
                    l_iCount = 3;

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

                Header.AddBreadCrumb("Home", "/main.aspx");

                switch((string)Session["PathToViewOrder"])
                {
                    case "Monthly-Daily":
                        Header.AddBreadCrumb("Monthly Work Orders View", "/wo_showOrdersForMonthly.aspx");
                        Header.AddBreadCrumb("Daily Work Orders View", "/wo_showOrdersForDaily.aspx");
                        m_sLastPage = "wo_showOrdersForDaily.aspx";
                        break;
                    case "Monthly":
                        Header.AddBreadCrumb("Monthly Work Orders View", "/wo_showOrdersForMonthly.aspx");
                        m_sLastPage = "wo_showOrdersForMonthly.aspx";
                        break;
                    case "Daily":
                        Header.AddBreadCrumb("Daily Work Orders View", "/wo_showOrdersForDaily.aspx");
                        m_sLastPage = "wo_showOrdersForDaily.aspx";
                        break;
                    case "Today":
                        Header.AddBreadCrumb("Work Orders Overview", "/wo_showOrdersForToday.aspx");
                        m_sLastPage = "wo_showOrdersForToday.aspx";
                        break;
                    case "Weekly":
                        Header.AddBreadCrumb("Weekly Work Orders View", "/wo_showOrdersForWeekly.aspx");
                        m_sLastPage = "wo_showOrdersForWeekly.aspx";
                        break;
                    case "Scheduled":
                        Header.AddBreadCrumb("The Scheduled Orders", "/wo_showUnassignedOrders.aspx");
                        m_sLastPage = "wo_showUnassignedOrders.aspx";
                        break;
                    case "Completed":
                        Header.AddBreadCrumb("Completed Work Orders", "/wo_showCompletedOrders.aspx");
                        m_sLastPage = "wo_showCompletedOrders.aspx";
                        break;
                    case "EquipWOReport":
                        Header.AddBreadCrumb("Equipment Work Order Report", "/wo_viewEquipWorkOrderReport.aspx");
                        m_sLastPage = "wo_viewEquipWorkOrderReport.aspx";
                        break;
                    default:
                        Header.AddBreadCrumb("Work Orders Overview", "/wo_showOrdersForToday.aspx");
                        m_sLastPage = "wo_showOrdersForToday.aspx";
                        break;
                }
                Response.Cookies["bfp_navigate"].Value = Header.BrdCrumbsSerialization;
                Response.Cookies["bfp_navigate"].Path = "/";
                Response.Cookies["bfp_navigate"].Expires = DateTime.Now.AddYears(1);
                //Session["BrdCrumbs"] = arrBrdCrumbs;
                #endregion

                if(!IsPostBack)
                {
                    dtCustomFields = new DataTable();
                    dtCustomFields.Columns.Add("ValueName");
                    dtCustomFields.Columns.Add("Value");

                    order = new clsWorkOrders();
                    user = new clsUsers();
                    order.cAction = "S";
                    order.iOrgId = OrgId;
                    order.iId = OrderId;
                    if(order.WorkOrderDetails() == -1)
                    {
                        Session["lastpage"] = m_sLastPage;
                        Session["error"] = _functions.ErrorMessage(120);
                        Response.Redirect("error.aspx", false);
                        return;
                    }

                    #region Processing of the Operation Area

                    hlMainEdit.NavigateUrl = "wo_editWorkOrder.aspx?id=" + OrderId.ToString();
                    hlCloseOrder.NavigateUrl = "wo_closeWorkOrder.aspx?id=" + OrderId.ToString();
                    hlOpenOrder.NavigateUrl = "wo_openWorkOrder.aspx?id=" + OrderId.ToString();
                    hlDeleteOrder.NavigateUrl = "wo_deleteWorkOrder.aspx?id=" + OrderId.ToString();

                    hlCheckIn.NavigateUrl = "wo_viewCheckIn.aspx?id=" + OrderId.ToString();
                    hlCheckOut.NavigateUrl = "wo_viewCheckOut.aspx?id=" + OrderId.ToString();
                    hlTimeLog.NavigateUrl = "wo_updateTimeLog.aspx?id=" + OrderId.ToString();

                    hlReportedIssues.NavigateUrl = "wo_addRepairs.aspx?id=" + OrderId.ToString() + "&back=view";
                    hlPMItems.NavigateUrl  = "wo_addPreventiveMaintenance.aspx?id=" + OrderId.ToString() + "&back=view";
                    hlInspections.NavigateUrl = "wo_addInspections.aspx?id=" + OrderId.ToString() + "&back=view";

                    sReportPath = _functions.GetValueFromConfig("SQLRS.Folder");
                    hlPrintPartUsed.NavigateUrl = "ReportViewer.aspx?Report=" + sReportPath + "%2fPartsList&OrderId=" + OrderId.ToString() + "&OrgId=" + OrgId.ToString();
                    hlPrintOrderRequest.NavigateUrl = "ReportViewer.aspx?Report=" + sReportPath + "%2fWorkOrderRequest&OrderId=" + OrderId.ToString() + "&OrgId=" + OrgId.ToString();
                    hlPrintCompletedOrder.NavigateUrl = "ReportViewer.aspx?Report=" + sReportPath + "%2fCompletedOrder&OrderId=" + OrderId.ToString()+ "&OrgId=" + OrgId.ToString();

                    hlAddRepair.NavigateUrl = "wo_updateRepair.aspx?mode=Edit&repairid=0&inspectid=0&type=FREE&op=Repair&id=" + OrderId.ToString() + "&itemid=0";

                    status = (WorkOrderStatus)order.iStatusId.Value;
                    opstatus = order.iOperatorStatusId.IsNull?WorkOrderOperatorStatus.Null:(WorkOrderOperatorStatus)order.iOperatorStatusId.Value;

                    ViewState["status"] = status;
                    ViewState["opstatus"] = opstatus;
                    switch(status)
                    {
                        case WorkOrderStatus.Scheduled: // Scheduled status
                            hlMainEdit.Enabled = true;
                            hlMainEdit.Text = "[Change the Scheduled Date]";
                            hlReportedIssues.Enabled = true;
                            hlPMItems.Enabled = true;
                            hlInspections.Enabled = true;
                            hlCloseOrder.Enabled = false;
                            hlDeleteOrder.Enabled = true;
                            hlTimeLog.Enabled = false;
                            if(opstatus == WorkOrderOperatorStatus.Checked_In)
                            {
                                // check-in status
                                hlOpenOrder.Enabled = true;
                            }
                            else
                            {
                                // not check-in status
                                hlCheckIn.Enabled = true;
                            }
                            break;
                        case WorkOrderStatus.Open: // Opened status
                            hlMainEdit.Enabled = true;
                            hlReportedIssues.Enabled = true;
                            hlPMItems.Enabled = true;
                            hlInspections.Enabled = true;
                            hlPrintOrderRequest.Enabled = true;
                            hlPrintPartUsed.Enabled = true;
                            hlAddRepair.Enabled = true;
                            lbSaveNotes.Enabled = true;
                            hlTimeLog.Enabled = true;
                            break;
                        case WorkOrderStatus.ReOpened: // ReOpened status
                            hlMainEdit.Enabled = true;
                            hlReportedIssues.Enabled = true;
                            hlPMItems.Enabled = true;
                            hlInspections.Enabled = true;
                            hlPrintOrderRequest.Enabled = true;
                            hlPrintPartUsed.Enabled = true;
                            hlAddRepair.Enabled = true;
                            lbSaveNotes.Enabled = true;
                            hlTimeLog.Enabled = true;
                            break;
                        case WorkOrderStatus.Closed: // Closed Status
                            hlMainEdit.Enabled = true;
                            hlMainEdit.Text = "[Change the Order Dates]";
                            hlPrintCompletedOrder.Enabled = true;
                            hlPrintPartUsed.Enabled = true;
                            hlTimeLog.Enabled = true;
                            if(opstatus == WorkOrderOperatorStatus.Checked_In)
                            {
                                // check-in status
                                hlCheckOut.Enabled = true;
                            }
                            break;
                    }
                    #endregion

                    #region Processing of the Information Area
                    if(status == WorkOrderStatus.Closed)
                        Session["CurrentDay"] = order.daClosed.Value;
                    else
                        Session["CurrentDay"] = order.daScheduled.Value;
                    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;
                    lblStaying.Text = order.bStaying.IsNull?"not defined":(order.bStaying.Value?"Yes":"No");
                    lblSpare.Text = order.sSpareEquipId.Value;
                    lblTech.Text = order.sTechName.Value;
                    lblOperator.Text = order.sOperatorName.Value;
                    lblDroppedOffBy.Text = order.sDropedOffBy.Value;
                    lblReleasedTo.Text = order.sReleasedTo.Value;
                    lblCleanliness.Text = order.sCleanliness.Value;

                    hlServiceDates.Attributes.Add("onclick", "window.open('wo_viewDates.aspx?id=" + OrderId.ToString() + "', 'popupcal', 'width=350,height=200,left=' + event.screenX + ',top=' + event.screenY + ',scrollbars=no');");

                    // showing equipment info
                    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;
                    lblSerial.Text = order.sEquipVinSerial.Value;
                    lblUnits.Text = Convert.ToDouble(order.dmMileage.Value).ToString();
                    #endregion

                    #region Processing of the Issues Area
                    order.iTechId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                    dtPMItems = order.GetWorkOrderPMItems();
                    if(dtPMItems.Rows.Count > 0)
                        html_tblNonePMItems.Visible = false;
                    else
                        html_tblNonePMItems.Visible = true;
                    repPMItems.DataSource = new DataView(dtPMItems);
                    repPMItems.DataBind();

                    dtIssues = order.GetWorkOrderReportedIssues();
                    if(dtIssues.Rows.Count > 0)
                        html_tblNoneIssues.Visible = false;
                    else
                        html_tblNoneIssues.Visible = true;

                    repIssues.DataSource = new DataView(dtIssues);
                    repIssues.DataBind();

                    dtInspections = order.GetWorkOrderInspections();
                    if(dtInspections.Rows.Count > 0)
                        html_tblNoneInspections.Visible = false;
                    else
                        html_tblNoneInspections.Visible = true;
                    repInspections.DataSource = new DataView(dtInspections);
                    repInspections.DataBind();
                    #endregion

                    #region Processing of the Serviced Repairs Area and the Time Log Area
                    ShowRepairList();
                    #endregion

                    #region Processing of the Notes Area
                    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();

                    order.iNoteTypeId = (int)NoteTypes.TechnicianNote;
                    repTechNotes.DataSource = new DataView(order.GetNotesList());
                    repTechNotes.DataBind();
                    #endregion

                    #region Processing of the Signatures Area
                    order.iDocumentId = OrderId;
                    order.iDocumentTypeId = (int)DocumentTypes.WorkOrderCheckedIn;
                    if(order.GetSignedDocument() != -1)
                    {
                        lblSignCheckInBy.Text = order.sUserName.Value;
                        lblSignCheckInByUnder.Text = order.sUserName.Value;
                        lblSignDateCheckInBy.Text = order.daReportDate.Value.ToShortDateString() + " " + order.daReportDate.Value.ToShortTimeString();
                    }
                    else
                    {
                        lblSignCheckInBy.Text = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                    }
                    order.iDocumentTypeId = (int)DocumentTypes.WorkOrderReOpened;
                    if(order.GetSignedDocument() != -1)
                    {
                        lblSignOpenedBy.Text = order.sUserName.Value;
                        lblSignOpenedByUnder.Text = order.sUserName.Value;
                        lblSignDateOpenedBy.Text = order.daReportDate.Value.ToShortDateString() + " " + order.daReportDate.Value.ToShortTimeString();
                    }
                    else
                    {
                        order.iDocumentTypeId = (int)DocumentTypes.WorkOrderOpen;
                        if(order.GetSignedDocument() != -1)
                        {
                            lblSignOpenedBy.Text = order.sUserName.Value;
                            lblSignOpenedByUnder.Text = order.sUserName.Value;
                            lblSignDateOpenedBy.Text = order.daReportDate.Value.ToShortDateString() + " " + order.daReportDate.Value.ToShortTimeString();
                        }
                        else
                        {
                            lblSignOpenedBy.Text = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                        }
                    }
                    if(status == WorkOrderStatus.Closed)
                    {
                        order.iDocumentTypeId = (int)DocumentTypes.WorkOrderClosed;
                        if(order.GetSignedDocument() != -1)
                        {
                            lblSignClosedBy.Text = order.sUserName.Value;
                            lblSignClosedByUnder.Text = order.sUserName.Value;
                            lblSignDateClosedBy.Text = order.daReportDate.Value.ToShortDateString() + " " + order.daReportDate.Value.ToShortTimeString();
                        }
                    }
                    if(opstatus == WorkOrderOperatorStatus.Checked_Out)
                    {
                        order.iDocumentTypeId = (int)DocumentTypes.WorkOrderCheckedOut;
                        if(order.GetSignedDocument() != -1)
                        {
                            lblSignCheckOutBy.Text = order.sUserName.Value;
                            lblSignCheckOutByUnder.Text = order.sUserName.Value;
                            lblSignDateCheckOutBy.Text = order.daReportDate.Value.ToShortDateString() + " " + order.daReportDate.Value.ToShortTimeString();
                        }
                    }
                    #endregion

                    #region Processing of the Custom Fields
                    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 = OrgId;
                                                    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 = OrgId;
                                                    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 = OrgId;
                                                    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"] = m_sLastPage;
                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();
            }
        }
コード例 #9
0
ファイル: wo_preview.aspx.cs プロジェクト: bigWebApps/Fleet
        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();
            }
        }
コード例 #10
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();
            }
        }
コード例 #11
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"] = "ok_mainMenu.aspx";
                    Session["error"] = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    OrderId = Convert.ToInt32(Request.QueryString["id"]);
                    sBackPage = Request.QueryString["back"];
                    //EquipId = Convert.ToInt32(Request.QueryString["equipid"]);
                }
                catch(FormatException fex)
                {
                    Session["lastpage"] = "ok_mainMenu.aspx";
                    Session["error"] = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }

                sBackURL = "ok_mainMenu.aspx";
                if(sBackPage == "mainmenu2")
                    sBackURL = "ok_mainMenu2.aspx";
                if(sBackPage == "authcredentials")
                    sBackURL = "ok_authCredentials.aspx?orderid=" + OrderId.ToString();
                btnBack.Attributes.Add("onclick","javascript:document.location='" + sBackURL + "'");
                if(!IsPostBack)
                {
                    order = new clsWorkOrders();
                    order.cAction = "S";
                    order.iOrgId = OrgId;
                    order.iId = OrderId;
                    if(order.WorkOrderDetails() == -1)
                    {
                        Session["lastpage"] = "ok_mainMenu.aspx";
                        Session["error"] = _functions.ErrorMessage(120);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    EquipId = order.iEquipId.Value;
                    lblWorkOrderN.Text = order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString();
                    lblStatus.Text = order.sStatusId.Value;
                    lblOperatorStatus.Text = order.sOperatorStatus.Value;
                    lblOperator.Text = order.sOperatorName.Value;
                    lblEquipId.Text = order.sEquipId.Value;
                    lblType.Text = order.sEquipTypeName.Value;

                    //Header.AddMainMenuItem("<nobr>Deactivate Operator Kiosk Terminal</nobr>", "/selectMode.aspx");
                    if(((WorkOrderStatus)order.iStatusId.Value == WorkOrderStatus.Scheduled) &&
                        ((WorkOrderOperatorStatus)order.iOperatorStatusId.Value == WorkOrderOperatorStatus.Null))
                    {
                        // Arrival Check-In
                        tblMain.Rows[4].Visible = false;
                        tblMain.Rows[5].Visible = false;
                        tblMain.Rows[6].Visible = false;
                        tblMain.Rows[7].Visible = false;
                        Response.Redirect("ok_selectEquipment.aspx?orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString(), false);
                        //Header.AddMainMenuItem("Arrival Check-In", "/ok_authCredentials.aspx?op=CheckIn&orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString());
                    }
                    else if(((WorkOrderStatus)order.iStatusId.Value == WorkOrderStatus.Scheduled) &&
                        ((WorkOrderOperatorStatus)order.iOperatorStatusId.Value == WorkOrderOperatorStatus.Checked_In))
                    {
                        // Add Issues and Check-Out Spare
                        tblMain.Rows[3].Visible = false;
                        tblMain.Rows[4].Visible = false;
                        tblMain.Rows[5].Visible = false;
                        //Header.AddMainMenuItem("Add Reported Issue", "/ok_authCredentials.aspx?op=AddIssue&orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString());
                        if(order.iSpareEquipId.Value != 0)
                        {
                            btnCheckOutSpare.Value = " Recheck-Out Spare ";
                            //Header.AddMainMenuItem("Recheck-Out Spare", "/ok_authCredentials.aspx?op=CheckOutSpare&orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString());
                        }
                        //else
                        //Header.AddMainMenuItem("Check-Out Spare", "/ok_authCredentials.aspx?op=CheckOutSpare&orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString());
                    }
                    else if((WorkOrderStatus)order.iStatusId.Value == WorkOrderStatus.Open ||
                        (WorkOrderStatus)order.iStatusId.Value == WorkOrderStatus.ReOpened)
                    {
                        // Add Issues and Check-Out Spare
                        tblMain.Rows[3].Visible = false;
                        tblMain.Rows[4].Visible = false;
                        tblMain.Rows[5].Visible = false;
                        if(order.iSpareEquipId.Value != 0)
                        {
                            btnCheckOutSpare.Value = " Recheck-Out Spare ";
                            //Header.AddMainMenuItem("Recheck-Out Spare", "/ok_authCredentials.aspx?op=CheckOutSpare&orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString());
                        }
                        //else
                        //Header.AddMainMenuItem("Check-Out Spare", "/ok_authCredentials.aspx?op=CheckOutSpare&orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString());
                    }
                    else if(((WorkOrderStatus)order.iStatusId.Value == WorkOrderStatus.Closed) &&
                        ((WorkOrderOperatorStatus)order.iOperatorStatusId.Value == WorkOrderOperatorStatus.Checked_In))
                    {
                        // Departure Check-Out and ReOpen
                        tblMain.Rows[3].Visible = false;
                        tblMain.Rows[6].Visible = false;
                        tblMain.Rows[7].Visible = false;
                        //Header.AddMainMenuItem("Departure Check-Out", "/ok_authCredentials.aspx?op=CheckOut&orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString());
                    }
                    else if(((WorkOrderStatus)order.iStatusId.Value == WorkOrderStatus.Closed) &&
                        ((WorkOrderOperatorStatus)order.iOperatorStatusId.Value == WorkOrderOperatorStatus.Checked_Out))
                    {
                        // ReOpen Work Order
                        tblMain.Rows[3].Visible = false;
                        tblMain.Rows[4].Visible = false;
                        tblMain.Rows[6].Visible = false;
                        tblMain.Rows[7].Visible = false;
                    }
                    else
                    {
                        tblMain.Rows[3].Visible = false;
                        tblMain.Rows[4].Visible = false;
                        tblMain.Rows[5].Visible = false;
                        tblMain.Rows[6].Visible = false;
                        tblMain.Rows[7].Visible = false;
                    }
                    btnCheckIn.Attributes.Add("onclick", "javascript:document.location='ok_selectEquipment.aspx?orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString() + "&back=maindetails'");
                    btnCheckOut.Attributes.Add("onclick", "javascript:document.location='ok_selectWorkOrder.aspx?id=" + OrderId.ToString() + "'");
                    btnReOpen.Attributes.Add("onclick", "javascript:document.location='ok_reopenWorkOrder.aspx?id=" + OrderId.ToString() + "'");
                    btnCheckOutSpare.Attributes.Add("onclick", "javascript:document.location='ok_selectSpareEquip.aspx?op=CheckOutSpare&orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString() + "'");
                    btnAddIssue.Attributes.Add("onclick","javascript:document.location='ok_addIssues.aspx?op=AddIssue&orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString() + "'");
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = sBackURL;
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }
コード例 #12
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());

                html_btnNo.Attributes.Add("onclick", "javascript:document.location='wo_viewWorkOrder.aspx?id=" + OrderId.ToString() + "'");

                if(!IsPostBack)
                {
                    order = new clsWorkOrders();
                    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;
                    }
                    lblEquipId.Text = order.sEquipId.Value;
                    lblWorkOrderId.Text = order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString();
                    lblTech.Text = order.sTechName.Value;
                    lblOperator.Text = order.sOperatorName.Value;
                    if((WorkOrderStatus)order.iStatusId.Value != WorkOrderStatus.Closed)
                    {
                        if(order.GetDeleteAbleOrder() == 1)
                            btnYes.Enabled = true;
                        else
                        {
                            btnYes.Enabled = false;
                            Header.ErrorMessage = _functions.ErrorMessage(146);
                        }
                    }
                    else
                    {
                        btnYes.Enabled = false;
                        Header.ErrorMessage = _functions.ErrorMessage(145);
                    }
                }
            }
            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();
            }
        }
コード例 #13
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();
                }
            }
        }