/// 处理记录状态枚举转换
        /// <summary>
        /// 处理记录状态枚举转换
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public string GetProcessWorkStatusEnumStr(string workOrderStatus, string isReturnVisit)
        {
            WorkOrderStatus w = (WorkOrderStatus)Enum.Parse(typeof(WorkOrderStatus), workOrderStatus);

            if (w == WorkOrderStatus.Processed)
            {
                int r = CommonFunction.ObjectToInteger(isReturnVisit, -1);
                if (r == -1)
                {
                    return(BLL.Util.GetEnumOptText(typeof(WorkOrderStatus), (int)w));
                }
                else if (r == 0)
                {
                    return("未回访");
                }
                else if (r == 1)
                {
                    return("已回访");
                }
                else
                {
                    return("");
                }
            }
            else
            {
                return(BLL.Util.GetEnumOptText(typeof(WorkOrderStatus), (int)w));
            }
        }
Пример #2
0
        public async Task <IActionResult> Edit(string id, [Bind("WorkOrderStatusId,StatusDescription,Color")] WorkOrderStatus workOrderStatus)
        {
            if (id != workOrderStatus.WorkOrderStatusId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(workOrderStatus);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WorkOrderStatusExists(workOrderStatus.WorkOrderStatusId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(workOrderStatus));
        }
Пример #3
0
 public CreateWorkOrderEvent(Guid id, DateTime createDate, DateTime?startDate, DateTime?completeDate, WorkOrderStatus status)
 {
     SourceId     = id;
     CreateDate   = createDate;
     StartDate    = startDate;
     CompleteDate = completeDate;
     Status       = status;
     EventType    = GetType().Name;
 }
Пример #4
0
 /// 发送邮件给接收人和抄送人
 /// <summary>
 /// 发送邮件给接收人和抄送人
 /// </summary>
 /// <param name="jsondata"></param>
 /// <param name="sysinfo"></param>
 /// <param name="worderinfo"></param>
 public void SendEMail(WOrderProcessJsonData jsondata, SysRightUserInfo sysinfo, WOrderInfoInfo worderinfo)
 {
     try
     {
         //状态校验
         WorkOrderStatus status = (WorkOrderStatus)worderinfo.WorkOrderStatus_Value;
         if (status == WorkOrderStatus.Pending || status == WorkOrderStatus.Processing || status == WorkOrderStatus.Untreated)
         {
             //查询邮件地址
             string[] ccUserID = jsondata.Recevicer.Select(x => x.UserID_Out.ToString()).ToArray();
             string[] toUserID = jsondata.ExtendRecev.Select(x => x.UserID_Out.ToString()).ToArray();
             List <SysRightUserInfo> cc_sysinfos = BLL.EmployeeSuper.Instance.GetSysRightUserInfo(string.Join(",", ccUserID));
             List <SysRightUserInfo> to_sysinfos = BLL.EmployeeSuper.Instance.GetSysRightUserInfo(string.Join(",", toUserID));
             //邮箱
             string[] cc_email = cc_sysinfos.Where(x => !string.IsNullOrEmpty(x.Email)).Select(x => x.Email).ToArray();
             string[] to_email = to_sysinfos.Where(x => !string.IsNullOrEmpty(x.Email)).Select(x => x.Email).ToArray();
             //查询个人用户信息
             CustTypeEnum ctype = CustTypeEnum.T01_个人;
             DataTable    dt    = BLL.WOrderInfo.Instance.GetCBInfoByPhone(worderinfo.CBID_Value, "");
             if (dt != null && dt.Rows.Count > 0)
             {
                 ctype = (CustTypeEnum)CommonFunction.ObjectToInteger(dt.Rows[0]["CustCategoryID"]);
             }
             //获取工单类型
             WOrderCategoryEnum wtype = (WOrderCategoryEnum)worderinfo.CategoryID_Value;
             //测试数据
             //cc_email = new string[] { "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" };
             //to_email = new string[] { "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" };
             //邮件正文1
             string body1 = "你有一张<strong style='color:red;'>" + BLL.Util.GetEnumOptText(typeof(CustTypeEnum), (int)ctype) +
                            BLL.Util.GetEnumOptText(typeof(WOrderCategoryEnum), (int)wtype) + "</strong>工单!";
             //邮件正文2
             string body2 = worderinfo.Content_Value;
             //cc系统地址
             string weburl = BitAuto.Utils.Config.ConfigurationUtil.GetAppSettingValue("ExitAddress");
             //发邮件
             if (cc_email.Length > 0)
             {
                 WOrderInfo.LogToLog4("工单处理发送邮件:接收人" + string.Join(";", cc_email));
                 string title = "您有一张工单[" + worderinfo.OrderID_Value + "]待处理";
                 string a     = "<a href='" + weburl + "/WOrderV2/WOrderProcess.aspx?OrderID=" + worderinfo.OrderID_Value + "'>工单处理</a>";
                 EmailHelper.Instance.SendMail(title, cc_email, new string[] { body1, body2, a }, "WOrderV2");
             }
             if (to_email.Length > 0)
             {
                 WOrderInfo.LogToLog4("工单处理发送邮件:抄送人" + string.Join(";", to_email));
                 string title = "您有一张工单[" + worderinfo.OrderID_Value + "]待查看";
                 string a     = "<a href='" + weburl + "/WOrderV2/WorkOrderView.aspx?OrderID=" + worderinfo.OrderID_Value + "'>工单查看</a>";
                 EmailHelper.Instance.SendMail(title, to_email, new string[] { body1, body2, a }, "WOrderV2");
             }
         }
     }
     catch (Exception ex)
     {
         WOrderInfo.ErrorToLog4("工单处理发送邮件异常", ex);
     }
 }
Пример #5
0
        public async Task <IActionResult> Create([Bind("WorkOrderStatusId,StatusDescription,Color")] WorkOrderStatus workOrderStatus)
        {
            if (ModelState.IsValid)
            {
                _context.Add(workOrderStatus);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(workOrderStatus));
        }
Пример #6
0
        public async Task <ValidationResult> UpdateStatus(Guid shopId, Guid orderId, WorkOrderStatus workOrderStatus)
        {
            var order = await workOrderRepository.ReadAsync(shopId, orderId);

            if (order == null || order.DocumentStatus != WorkOrderDocumentStatus.Saved)
            {
                return(ValidationResult.Fail("notFound", $"Order with id {orderId} not found"));
            }

            order.Status = workOrderStatus;

            await workOrderRepository.WriteAsync(shopId, order);

            return(ValidationResult.Success());
        }
Пример #7
0
 public CreateWorkOrderCommand(
     string objectNumber,
     string address,
     string description,
     DateTimeOffset?startDate,
     DateTimeOffset?endDate,
     WorkOrderStatus status)
 {
     ObjectNumber = objectNumber;
     Address      = address;
     Description  = description;
     StartDate    = startDate;
     EndDate      = endDate;
     Status       = status;
 }
        /// 权限验证
        /// <summary>
        /// 权限验证
        /// </summary>
        /// <returns></returns>
        private bool ValidateRight(WOrderProcessRightJsonData right)
        {
            string             msg  = "";
            WOrderOperTypeEnum oper = WOrderOperTypeEnum.None;

            bool a = BLL.WOrderProcess.Instance.ValidateWOrderProcessRight(OrderID, ref msg, ref oper, out WOrderInfo, right);

            if (a == false)
            {
                BLL.Util.CloseCurrentPageAfterAlert(Response, msg);
                return(false);
            }
            else
            {
                TitleName    = "工单" + BLL.Util.GetEnumOptText(typeof(WOrderOperTypeEnum), (int)oper);
                WOrderStatus = (WorkOrderStatus)WOrderInfo.WorkOrderStatus_Value;
                CRMCustID    = WOrderInfo.CRMCustID_Value;
                return(true);
            }
        }
Пример #9
0
        public ActionResult ChangeWorkorderStatus(StatusModel model)
        {
            _log.InfoFormat("Method: ChangeWorkorderStatus. Id: {0}, Status {1}", model.Id, model.Status);
            var workorder = repository.SearchFor <SageWorkOrder>(x => x.WorkOrder == model.Id).FirstOrDefault();

            if (workorder == null)
            {
                return(Error("Workorder not found", $"There is no workorders with id {model.Id}. workorder == null"));
            }

            var sageStatus = model.Status == WorkOrderStatus.Closed ?
                             WorkOrderStatus.ByStatus(WorkOrderStatus.Closed) :
                             WorkOrderStatus.ByStatus(WorkOrderStatus.Open);
            var result = sageApiProxy.EditWorkOrderStatus(model.Id, sageStatus.ToString());

            if (!result.IsSucceed)
            {
                return(Error("Was not able to save workorder to sage",
                             $"EditWorkOrderStatus method IsSucceed==false. {result.ErrorMassage}."));
            }

            workorder.Status = model.Status;
            repository.Update(workorder);
            _hub.UpdateSageWorkOrder(workorder);
            _log.InfoFormat("Workorder ({0}) status changed. Status: {1}. Repository updated", workorder.Name, model.Status);
            notification.SendNotification($"Workorder {workorder.Name} change status by {model.Status}");
            if (model.Status == WorkOrderStatus.WorkComplete)
            {
                _hub.ShowAlert(new SweetAlertModel()
                {
                    Message = $"Workorder #{workorder.WorkOrder} closed",
                    Title   = "Workorder completed",
                    Type    = "success"
                });
            }
            return(Success());
        }
Пример #10
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();
            }
        }
Пример #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"] = "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();
                }
            }
        }
Пример #12
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();
                }
            }
        }
 public static void WaitValue(this OrderStatusSelector orderStatusSelector, WorkOrderStatus status)
 {
     orderStatusSelector.Selector.Text.Wait().EqualTo(status.GetDescription());
 }
Пример #14
0
 public WorkOrderBuilder WithStatus(WorkOrderStatus status)
 {
     workOrder.Status = status;
     return(this);
 }
Пример #15
0
        //private PromotionResult PromoteToCertified()
        //{
        //    PromotionResult promotionResult = new PromotionResult();
        //    promotionResult.Success = true;
        //    if (WorkOrderStatus != WorkOrderStatus.Certifying)
        //    {
        //        promotionResult.Success = false;
        //        promotionResult.Message = "Failed to promote the work order to Certified status because its current status prevented it.";
        //    }
        //    if (String.IsNullOrWhiteSpace(CertificationRequirements))
        //    {
        //        promotionResult.Success = false;
        //        promotionResult.Message = "Failed to promote the work order to Certified status because Certification Requirements were not present.";
        //    }
        //    else if (Parts.Count == 0 || Labors.Count == 0)
        //    {
        //        promotionResult.Success = false;
        //        promotionResult.Message = "Failed to promote the work order to Certified status because it did not contain at least one part and at least one labor item.";
        //    }
        //    else if (Parts.Count(p => p.IsInstalled == false) > 0 || Labors.Count(l => l.PercentComplete < 100) > 0)
        //    {
        //        promotionResult.Success = false;
        //        promotionResult.Message = "Failed to promote the work order to Certified status because not all parts have been installed and labor completed.";
        //    }
        //    if (promotionResult.Success)
        //    {
        //        WorkOrderStatus = WorkOrderStatus.Certified;
        //        promotionResult.Message = String.Format("Work order {0} successfully promoted to status {1}.", WorkOrderId, WorkOrderStatus);
        //    }
        //    return promotionResult;
        //}
        private PromotionResult PromoteToApproved()
        {
            PromotionResult promotionResult = new PromotionResult();
            promotionResult.Success = true;

            if (WorkOrderStatus != WorkOrderStatus.Approving && WorkOrderStatus != WorkOrderStatus.Certified)
            {
                promotionResult.Success = false;
                promotionResult.Message = "Failed to promote the work order to Approved status because its current status prevented it.";
            }

            if (promotionResult.Success)
            {
                WorkOrderStatus = WorkOrderStatus.Approved;
                promotionResult.Message = String.Format("Work order {0} successfully promoted to status {1}.", WorkOrderId, WorkOrderStatus);
            }

            return promotionResult;
        }
Пример #16
0
        private PromotionResult DemoteToCreated()
        {
            PromotionResult promotionResult = new PromotionResult();
            promotionResult.Success = true;

            if (WorkOrderStatus != WorkOrderStatus.Approving)
            {
                promotionResult.Success = false;
                promotionResult.Message = "Failed to demote the work order to Created status because its current status prevented it.";
            }

            if (String.IsNullOrWhiteSpace(ReworkNotes))
            {
                promotionResult.Success = false;
                promotionResult.Message = "Failed to demote the work order to Created status because Rework Notes must be present.";
            }

            if (promotionResult.Success)
            {
                WorkOrderStatus = WorkOrderStatus.Created;
                promotionResult.Message = String.Format("Work order {0} successfully demoted to status {1}.", WorkOrderId, WorkOrderStatus);
            }

            return promotionResult;
        }
Пример #17
0
        public ActionResult SaveWorkOrder(WorkOrderModel model)
        {
            _log.InfoFormat("Method: SaveWorkOrder. Model ID {0}", model.Id);

            if (model.Emploee == 0)
            {
                return(Error("Employee is required"));
            }
            if (model.Location == null)
            {
                return(Error("Location is required"));
            }
            if (model.Problem == null)
            {
                return(Error("Problem is required"));
            }


            var workorder = new SageWorkOrder()
            {
                ARCustomer           = model.Customer,
                Location             = model.Location,
                CallType             = model.Calltype,
                CallDate             = model.Calldate.GetLocalDate(),
                Problem              = model.Problem,
                RateSheet            = model.Ratesheet,
                Employee             = model.Emploee.ToString(),
                EstimatedRepairHours = Convert.ToDecimal(model.Estimatehours),
                NottoExceed          = model.Nottoexceed,
                Comments             = model.Locationcomments,
                CustomerPO           = model.Customerpo,
                PermissionCode       = model.Permissiocode,
                PayMethod            = model.Paymentmethods,
                WorkOrder            = model.WorkOrder,
                Id        = model.Id,
                Status    = WorkOrderStatus.ById(model.Status),
                JCJob     = model.JCJob,
                Contact   = model.Contact,
                Equipment = model.Equipment
            };

            var workOrderResult = _sageApiProxy.EditWorkOrder(workorder);

            workOrderResult.Entity.LocationNumber = long.Parse(model.Location);
            if (!workOrderResult.IsSucceed)
            {
                _log.ErrorFormat("Was not able to update workorder to sage. !result.IsSucceed");
                return(Error("Was not able to update workorder to sage"));
            }

            if (model.Emploee != 0)
            {
                var assignmentDb     = _repository.SearchFor <SageAssignment>(x => x.WorkOrder == model.WorkOrder).Single();
                var editedAssignment = new AssignmentViewModel();
                editedAssignment.Employee             = model.Emploee;
                editedAssignment.EndDate              = model.AssignmentDate.Date.Add((model.AssignmentTime).TimeOfDay).AddHours(assignmentDb.EstimatedRepairHours.AsDouble() == 0 ? 1 : assignmentDb.EstimatedRepairHours.AsDouble());
                editedAssignment.EstimatedRepairHours = workorder.EstimatedRepairHours.ToString();
                editedAssignment.Id           = assignmentDb.Id;
                editedAssignment.ScheduleDate = model.AssignmentDate.Date.Add((model.AssignmentTime).TimeOfDay);
                editedAssignment.WorkOrder    = assignmentDb.WorkOrder;
                _scheduleService.CerateAssignment(editedAssignment);

                var locations    = _repository.GetAll <SageLocation>().ToArray();
                var itemLocation = locations.FirstOrDefault(l => l.Name == workOrderResult.Entity.Location);
                workOrderResult.Entity.ScheduleDate = model.AssignmentDate.Date.Add((model.AssignmentTime).TimeOfDay);
                workOrderResult.Entity.Latitude     = itemLocation.Latitude;
                workOrderResult.Entity.Longitude    = itemLocation.Longitude;
            }

            this.ResolveWorkOrderItems(model);
            this.ResolveWorkOrderNotes(model);

            workOrderResult.Entity.Status         = WorkOrderStatus.ById(model.Status);
            workOrderResult.Entity.Id             = workorder.Id;
            workOrderResult.Entity.IsValid        = true;
            workOrderResult.Entity.WorkOrderItems = _sageApiProxy.GetWorkorderItemsByWorkOrderId(workorder.WorkOrder).Entities;
            workOrderResult.Entity.WorkNotes      = this._sageApiProxy.GetNotes(workorder.WorkOrder).Entities;
            _repository.Update(workOrderResult.Entity);

            _log.InfoFormat("Repository update workorder. Name {0}, ID {1}", workorder.Name, workorder.Id);
            _hub.UpdateWorkOrder(model);
            if (model.Status == WorkOrderStatus.WorkCompleteId)
            {
                _hub.ShowAlert(new SweetAlertModel()
                {
                    Message = $"Workorder #{model.WorkOrder} closed",
                    Title   = "Workorder completed",
                    Type    = "success"
                });
            }
            return(Success());
        }
Пример #18
0
        private void repInspections_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
        {
            try
            {
                if(e.CommandName.Length > 0)
                {
                    status = (WorkOrderStatus)ViewState["status"];
                    opstatus = (WorkOrderOperatorStatus)ViewState["opstatus"];

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

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

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

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

                            ShowRepairList();
                        }
                    }
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }
Пример #19
0
 public WOrderProcess(string orderid, WorkOrderStatus status)
 {
     OrderId         = orderid;
     WorkOrderStatus = status;
 }
Пример #20
0
        private PromotionResult PromoteToProcessing()
        {
            if (WorkOrderStatus == WorkOrderStatus.Created || WorkOrderStatus == WorkOrderStatus.Rejected)
            {
                WorkOrderStatus = WorkOrderStatus.Processing;
            }

            PromotionResult promotionResult = new PromotionResult();
            promotionResult.Success = WorkOrderStatus == WorkOrderStatus.Processing;

            if (promotionResult.Success)
                promotionResult.Message = String.Format("Work order {0} successfully claimed by {1} and promoted to status {2}.",
                    WorkOrderId,
                    HttpContext.Current.User.Identity.Name,
                    WorkOrderStatus);
            else
                promotionResult.Message = "Failed to promote the work order to Processing status because its current status prevented it.";

            return promotionResult;
        }
Пример #21
0
        private PromotionResult PromoteToProcessed()
        {
            PromotionResult promotionResult = new PromotionResult();
            promotionResult.Success = true;

            if (WorkOrderStatus != WorkOrderStatus.Processing)
            {
                promotionResult.Success = false;
                promotionResult.Message = "Failed to promote the work order to Processed status because its current status prevented it.";
            }
            else if (Parts.Count == 0 || Labors.Count == 0)
            {
                promotionResult.Success = false;
                promotionResult.Message = "Failed to promote the work order to Processed status because it did not contain at least one part and at least one labor item.";
            }
            else if (String.IsNullOrWhiteSpace(Description))
            {
                promotionResult.Success = false;
                promotionResult.Message = "Failed to promote the work order to Processed status because it requires a Description.";
            }

            if (promotionResult.Success)
            {
                WorkOrderStatus = WorkOrderStatus.Processed;
                promotionResult.Message = String.Format("Work order {0} successfully promoted to status {1}.", WorkOrderId, WorkOrderStatus);
            }

            return promotionResult;
        }
Пример #22
0
        private PromotionResult PromoteToCreated()
        {
            PromotionResult promotionResult = new PromotionResult();
            promotionResult.Success = true;

            if (WorkOrderStatus != WorkOrderStatus.Creating)
            {
                promotionResult.Success = false;
                promotionResult.Message = "Failed to promote the work order to Created status because its current status prevented it.";
            }
            else if (String.IsNullOrWhiteSpace(TargetDateTime.ToString()) ||
                String.IsNullOrWhiteSpace(DropDeadDateTime.ToString()) ||
                String.IsNullOrWhiteSpace(Description))
            {
                promotionResult.Success = false;
                promotionResult.Message = "Failed to promote the work order to Created status because it requires a Target Date, Drop Dead Date, and Description.";
            }

            if (promotionResult.Success)
            {
                WorkOrderStatus = WorkOrderStatus.Created;
                promotionResult.Message = String.Format("Work order {0} successfully promoted to status {1}.", WorkOrderId, WorkOrderStatus);
            }

            return promotionResult;
        }
Пример #23
0
        private PromotionResult PromoteToCertified()
        {
            PromotionResult promotionResult = new PromotionResult { Success = true };
            promotionResult = CertifyingTest(promotionResult);
            promotionResult = CertificationRequirementsTest(promotionResult);
            promotionResult = OnePartAndLaborTest(promotionResult);
            promotionResult = PartsInstalledLaborCompleteTest(promotionResult);

            if (promotionResult.Success)
            {
                WorkOrderStatus = WorkOrderStatus.Certified;
                promotionResult.Message = String.Format("Work order {0} successfully promoted to status {1}.", WorkOrderId, WorkOrderStatus);
            }

            return promotionResult;
        }
Пример #24
0
        private void repPMItems_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
        {
            int ServiceCheckId;
            int ServiceResultId;
            try
            {
                if(e.CommandName.Length > 0)
                {
                    status = (WorkOrderStatus)ViewState["status"];
                    opstatus = (WorkOrderOperatorStatus)ViewState["opstatus"];

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

                    Header.BodyOnloadScript = "javascript:document.location='#Issues'";
                    //Header.Render();

                    ItemId = Convert.ToInt32(((Label)e.Item.FindControl("PMItemId")).Text);
                    ServiceCheckId = Convert.ToInt32(((Label)e.Item.FindControl("ServiceCheckId")).Text);
                    ServiceResultId = Convert.ToInt32(((Label)e.Item.FindControl("ServiceResultId")).Text);
                    order = new clsWorkOrders();
                    order.iOrgId = OrgId;
                    order.iId = OrderId;
                    order.iPMItemId = ItemId;
                    switch(e.CommandName)
                    {
                        case "Delete":
                            order.cAction = "D";
                            int iResult = order.WorkOrderPMItemsDetail();
                            if(iResult < 0)
                            {
                                Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();
                                if(iResult == -1)
                                    Session["error"] = _functions.ErrorMessage(123);
                                else
                                    Session["error"] = _functions.ErrorMessage(126);
                                Response.Redirect("error.aspx", false);
                            }
                            break;
                        case "OK":	// if the status already okay then ServiceCheckId = null else
                            // see what was status of ServiceResultId, if more than 0 then ServiceResultId = null
                            if(ServiceCheckId == (int)ServiceChecks._CheckOK)
                            {
                                order.iServiceCheckId = SqlInt32.Null;
                                order.iServiceResultId = SqlInt32.Null;
                            }
                            else
                            {
                                order.iServiceCheckId = (int)ServiceChecks._CheckOK;
                                order.iServiceResultId = ServiceResultId;
                            }
                            if(order.SetPMItemChecks() == -1)
                            {
                                Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();
                                Session["error"] = _functions.ErrorMessage(133);
                                Response.Redirect("error.aspx", false);
                                return;
                            }
                            break;
                        case "FAIR":
                            if(ServiceCheckId == (int)ServiceChecks._CheckFair)
                            {
                                order.iServiceCheckId = SqlInt32.Null;
                                order.iServiceResultId = SqlInt32.Null;
                            }
                            else
                            {
                                order.iServiceCheckId = (int)ServiceChecks._CheckFair;
                                order.iServiceResultId = ServiceResultId;
                            }
                            if(order.SetPMItemChecks() == -1)
                            {
                                Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();
                                Session["error"] = _functions.ErrorMessage(133);
                                Response.Redirect("error.aspx", false);
                                return;
                            }
                            break;
                        case "RepairNeeded":
                            if(ServiceCheckId == (int)ServiceChecks._CheckRepairs_Needed)
                            {
                                order.iServiceCheckId = SqlInt32.Null;
                                order.iServiceResultId = ServiceResultId;
                            }
                            else
                            {
                                order.iServiceCheckId = (int)ServiceChecks._CheckRepairs_Needed;
                                order.iServiceResultId = SqlInt32.Null;
                            }
                            if(order.SetPMItemChecks() == -1)
                            {
                                Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();
                                Session["error"] = _functions.ErrorMessage(133);
                                Response.Redirect("error.aspx", false);
                                return;
                            }
                            break;
                        case "NoService":
                            if(ServiceResultId > 0) // значит ремонт у этого итема был и мы удаляем его
                            {
                                order.iServiceCheckId = (int)ServiceChecks._CheckRepairs_Needed;
                                order.iServiceResultId = ServiceResultId;
                                if(order.SetPMItemChecks() == -1)
                                {
                                    Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();
                                    Session["error"] = _functions.ErrorMessage(133);
                                    Response.Redirect("error.aspx", false);
                                    return;
                                }
                            }
                            break;
                        case "Repaired":
                            Response.Redirect("wo_updateRepair.aspx?mode=Add&repairid=0&inspectid=0&type=PMI&op=Repair&id=" + OrderId.ToString() + "&itemid=" + ItemId.ToString(), false);
                            return;
                        case "Replaced":
                            Response.Redirect("wo_updateRepair.aspx?mode=Add&repairid=0&inspectid=0&type=PMI&op=Replace&id=" + OrderId.ToString() + "&itemid=" + ItemId.ToString(), false);
                            return;
                        default:
                            break;
                    }
                    order.cAction = "S";
                    order.iId = OrderId;
                    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();

                    ShowRepairList();
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }
Пример #25
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();
            }
        }
Пример #26
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();
                }
            }
        }
Пример #27
0
        public PromotionResult RelinquishWorkListItem()
        {
            PromotionResult promotionResult = new PromotionResult { Success = true };

            if (CurrentWorkerId == null || Status.Substring(Status.Length - 3, 3) != "ing")
            {
                promotionResult.Success = false;
                promotionResult.Message = String.Format("Work order {0} cannot be relinquished because it is not currently being worked on.", WorkOrderId);
            }

            if (promotionResult.Success)
            {
                CurrentWorker = null;
                CurrentWorkerId = null;

                switch (WorkOrderStatus)
                {
                    case WorkOrderStatus.Processing:
                        WorkOrderStatus = WorkOrderStatus.Created;
                        break;

                    case WorkOrderStatus.Certifying:
                        WorkOrderStatus = WorkOrderStatus.Processed;
                        break;

                    case WorkOrderStatus.Approving:
                        WorkOrderStatus = WorkOrderStatus.Certified;
                        break;
                }

                promotionResult.Message = String.Format("Work order {0} was successfully relinquished and its status was reset to {1}.", WorkOrderId, Status);
            }

            Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, EntityFormalNamePlural, WorkOrderId, HttpContext.Current.User.Identity.Name, null);

            return promotionResult;
        }
Пример #28
0
        ///  处理权限验证
        /// <summary>
        ///  处理权限验证
        /// </summary>
        /// <param name="orderid"></param>
        /// <param name="orderstatus"></param>
        /// <param name="lastrecid"></param>
        /// <param name="ordercreateuserid"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public WOrderOperTypeEnum ValidateWOrderProcessRight(string orderid, int orderstatus, int lastrecid, int ordercreateuserid, ref string message, WOrderProcessRightJsonData right = null)
        {
            message = "";
            WOrderOperTypeEnum oper = WOrderOperTypeEnum.None;
            //登录id
            int loginuserid = BLL.Util.GetLoginUserID();

            //处理权限验证方式(默认:采用当前登录人的id验证)
            if (right == null || Enum.IsDefined(typeof(WOrderProcessRightTypeEnum), right.RightType_Out) == false)
            {
                right = new WOrderProcessRightJsonData()
                {
                    RightType   = (int)WOrderProcessRightTypeEnum.R01_人员ID,
                    RightData   = "",
                    LoginUserID = loginuserid,
                    OrderID     = orderid
                };
            }
            else
            {
                //校验right有效性
                if (right.OrderID != orderid || right.LoginUserID != loginuserid)
                {
                    message = "参数中的权限数据有效性不正确!";
                    return(oper);
                }
            }
            /// 审核权限
            bool PendingRight = BLL.Util.CheckRight(loginuserid, "SYS024BUT102102B");
            /// 处理权限
            bool ProcessRight = BLL.Util.CheckRight(loginuserid, "SYS024BUT102102C");
            /// 回访权限
            bool ReturnRight = BLL.Util.CheckRight(loginuserid, "SYS024BUT102102D");

            if (string.IsNullOrEmpty(orderid))
            {
                message = "传入参数工单ID不正确!";
                return(oper);
            }
            WorkOrderStatus status = (WorkOrderStatus)Enum.Parse(typeof(WorkOrderStatus), orderstatus.ToString());

            switch (status)
            {
            case WorkOrderStatus.Pending:
                //审核
            {
                if (PendingRight)
                {
                    oper = WOrderOperTypeEnum.L03_审核;
                    return(oper);
                }
                else
                {
                    message = "您没有此工单的审核权限!";
                    return(oper);
                }
            }

            case WorkOrderStatus.Untreated:
            case WorkOrderStatus.Processing:
                //处理权限
            {
                //有权限+是创建人+是否上一步处理记录制定的接收人
                if (ProcessRight ||
                    loginuserid == ordercreateuserid ||
                    BLL.WOrderToAndCC.Instance.IsToPersonForNumber(orderid, lastrecid, right))
                {
                    oper = WOrderOperTypeEnum.L04_处理;
                    return(oper);
                }
                else
                {
                    message = "您没有此工单的处理权限!";
                    return(oper);
                }
            }

            case WorkOrderStatus.Processed:
                //回访权限
            {
                if (ReturnRight)
                {
                    if (BLL.WOrderProcess.Instance.IsHasReturnForProcess(orderid) == false)
                    {
                        oper = WOrderOperTypeEnum.L05_回访;
                        return(oper);
                    }
                    else
                    {
                        message = "此工单已经回访过了!";
                        return(oper);
                    }
                }
                else
                {
                    message = "您没有此工单的回访权限!";
                    return(oper);
                }
            }

            case WorkOrderStatus.Completed:
                message = "无法处理已完成的工单!";
                return(oper);

            case WorkOrderStatus.Closed:
                message = "无法处理已关闭的工单!";
                return(oper);

            default:
                message = "工单状态不正确!";
                return(oper);
            }
        }
 public static void SelectByValue(this OrderStatusSelector orderStatusSelector, WorkOrderStatus status)
 {
     orderStatusSelector.Overlay.Container.Click();
     orderStatusSelector.Selector.ItemListPresent.Wait().EqualTo(true);
     orderStatusSelector.Selector.GetMenuItemList <Button>().First(x => x.Text.Get() == status.GetDescription()).Click();
 }
Пример #30
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();
                }
            }
        }
 public UpdateWorkOrderStatusEvent(Guid id, WorkOrderStatus status)
 {
     SourceId = id;
     Status   = status;
 }