Example #1
0
        private void btNext_FormSubmit(object sender, EventArgs e)
        {
            try
            {

                order = new clsWorkOrders();
                order.iOrgId = OrgId;
                order.iId = OrderId;
                CheckOutEquipment();
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "ok_viewNotes.aspx?id=" + OrderId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }
 private void btnSave_Click(object sender, System.EventArgs e)
 {
     try
     {
         order = new clsWorkOrders();
         order.cAction = "U";
         if(((DateTime)ViewState["Date"]).CompareTo(adtLastTime.Date) <= 0)
         {
             lblError.Text = "The date cannot more then " + ((DateTime)ViewState["Date"]).ToShortDateString();
         }
         else
         {
             order.iInspectHistoryId = HistoryId;
             order.iOrgId = OrgId;
             order.iInspectSchedDetailId = InspectSchedDetailId;
             order.iId = OrderId;
             order.iEquipId = (Int32)ViewState["EquipId"];
             order.daDateHistory = adtLastTime.Date;
             if(order.InspectHistoryDetail() != -1)
             {
                 // closing the current window and reloading the parent window
                 sOnLoad = "window.close();opener.document.formSelectInspect.submit();";
                 Session["reload"] = true;
             }
         }
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
     }
     finally
     {
         if(order != null)
             order.Dispose();
     }
 }
Example #3
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                SourcePageName = "wo_viewDates.aspx.cs";

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

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

                order = new clsWorkOrders();
                order.cAction = "S";
                order.iOrgId = OrgId;
                order.iId = OrderId;
                if(order.WorkOrderDetails() != -1)
                {
                    lblDateCreated.Text = order.daCreated.Value.ToLongDateString();
                    lblArrivalDate.Text = order.daArrival.IsNull?"":order.daArrival.Value.ToLongDateString();
                    lblDateScheduled.Text = order.daScheduled.IsNull?"":order.daScheduled.Value.ToLongDateString() + " " + order.daScheduled.Value.ToLongTimeString();
                    lblDateOpened.Text = order.daOpened.IsNull?"":order.daOpened.Value.ToLongDateString();
                    lblDateClosed.Text = order.daClosed.IsNull?"":order.daClosed.Value.ToLongDateString();
                    lblDepartureDate.Text = order.daDeparture.IsNull?"":order.daDeparture.Value.ToLongDateString();
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }
Example #4
0
        private void btNext_FormSubmit(object sender, EventArgs e)
        {
            try
            {
                order = new clsWorkOrders();
                order.iOrgId = OrgId;
                order.iId = OrderId;
                order.sInitials = Signature.sInitials;
                order.sPIN = Signature.sPIN;
                order.daCurrentDate = DateTime.Now;
                switch(order.SigningWorkOrderOpen())
                {
                    case -1:
                        Signature.sError = _functions.ErrorMessage(140);
                        break;
                    case -2:
                        Session["lastpage"] = "wo_preview.aspx?id=" + OrderId.ToString();
                        Session["error"] = _functions.ErrorMessage(120);
                        Response.Redirect("error.aspx", false);
                        return;
                    case 0:
                        // redirect to the finish screen
                        BackFinishScreen finish = new BackFinishScreen();

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

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

                        finish.bContinueVisible = false;

                        finish.bViewVisible = true;
                        finish.sViewText = "[View the Opened Work Order]";
                        finish.sViewURL = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();

                        finish.bAdditionalVisible = false;

                        finish.bPrintVisible = true;
                        finish.sPrintText = "[Print the Opened Work Order]";
                        finish.sPrintURL = "ReportViewer.aspx?Report=FleetProReports%2fWorkOrderRequest&rs:Command=Render&rc:Parameters=false&OrderId=" + OrderId.ToString() + "&OrgId=" + OrgId.ToString();

                        Session["BackFinish"] = finish;

                        Response.Redirect("wo_finish.aspx", false);
                        break;
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "wo_preview.aspx?id=" + OrderId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }
 private void btnReport_Click(object sender, System.EventArgs e)
 {
     try
     {
         order = new clsWorkOrders();
         order.iOrgId = OrgId;
         order.sEquipId = tbEquipId.Text;
         order.daMinDate = adtStartDate.Date;
         order.daMaxDate = adtEndDate.Date;
         order.iTypeId = Convert.ToInt32(ddlWOTypes.SelectedValue);
         order.iRepairCatId = Convert.ToInt32(ddlRepairCats.SelectedValue);
         order.iTechId = Convert.ToInt32(ddlTech.SelectedValue);
         order.iOperatorId = Convert.ToInt32(ddlOperators.SelectedValue);
         DataTable dtReport = order.GetEquipWorkOrderReport();
         repWorkOrders.DataSource = new DataView(dtReport);
         repWorkOrders.DataBind();
         double dmTotalCost = 0.0;
         foreach(DataRow _row in dtReport.Rows)
         {
             dmTotalCost += Convert.ToDouble(_row["TotalCost"]);
         }
         lblTotalCost.Text = "$" + dmTotalCost.ToString();
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "wo_viewEquipWorkOrderReport.aspx";
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(order != null)
             order.Dispose();
     }
 }
        private void btSave_FormSubmit(object sender, EventArgs e)
        {
            try{
                OrderId = (int)ViewState["OrderId"];
                RepairId = (int)ViewState["RepairId"];
                InspectId = (int)ViewState["InspectId"];

                order = new clsWorkOrders();
                order.cAction = "U";
                order.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                order.iId = OrderId;
                order.iRepairId = RepairId;
                order.sRepairDesc = tbNotes.Text;
                if(ddlRepairItems.SelectedValue != "0")
                    order.iRepairItemId = Convert.ToInt32(ddlRepairItems.SelectedValue);
                if(order.RepairCommonDetails() == -1)
                {
                    Session["lastpage"] = "wo_editPartsUsed.aspx?id=" + OrderId.ToString() + "&repairid=" + RepairId.ToString() + "&inspectid=" + InspectId.ToString();
                    Session["error"] = _functions.ErrorMessage(123);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                if(InspectId != 0)
                    Response.Redirect("wo_viewCompleteInspection.aspx?id=" + OrderId.ToString()+ "&inspectid=" + InspectId.ToString(), false);
                else
                    Response.Redirect("wo_viewWorkOrder.aspx?id=" + OrderId.ToString(), false);
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "wo_editPartsUsed.aspx?id=" + OrderId.ToString() + "&repairid=" + RepairId.ToString() + "&inspectid=" + InspectId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }
Example #7
0
 private void dgRepairs_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
 {
     try
     {
         dgRepairs.EditItemIndex = e.Item.ItemIndex;
         order = new clsWorkOrders();
         order.iOrgId = OrgId;
         ShowIssues(OrderId);
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = m_sBackUrl;
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(order != null)
             order.Dispose();
     }
 }
Example #8
0
        /// <summary>
        /// The common procedure what will save filled Repair 
        // and his used parts both Add mode and Edit mode.
        /// </summary>
        private void UpdateRepair(bool newRepair)
        {
            double Hours = 0.0;
            try
            {
                //				if(tbNotes.Text.Length > 0)
                //				{
                if (tbMinutes.Text.Length > 0 && Convert.ToDouble(tbMinutes.Text) >= 60)
                {
                    Header.ErrorMessage = _functions.ErrorMessage(206);
                    return;
                }
                if (tbHours.Text.Length > 0 || tbMinutes.Text.Length > 0)
                {
                    if (tbHours.Text.Length > 0) Hours += Convert.ToDouble(tbHours.Text);
                    if (tbMinutes.Text.Length > 0) Hours += Convert.ToDouble(tbMinutes.Text) / 60;
                }
                if (Hours >= 1000)
                {
                    Header.ErrorMessage = _functions.ErrorMessage(203);
                    return;
                }
                order = new clsWorkOrders();
                order.iOrgId = OrgId;
                order.iId = OrderId;
                order.sTypeService = sType;
                order.iItemId = ItemId;
                if (ServiceResult == "Repair")
                    order.iServiceResultId = (int)ServiceResults._Repaired;
                else
                    order.iServiceResultId = (int)ServiceResults._Replaced;
                if (Mode) // Add mode
                {
                    order.iRepairId = 0;
                }
                else // Edit mode
                    order.iRepairId = RepairId;

                if (RepairId == 0 && newRepair)
                {
                    order.iRepairId = preRepairId;
                    order.iInsert = true;
                }

                order.sRepairDesc = tbNotes.Text;
                order.iRepairItemId = Convert.ToInt32(ddlRepairItems.SelectedValue);
                order.iRepairCatId = Convert.ToInt32(ddlRepairCats.SelectedValue);
                if (order.UpdateRepair() == -1)
                {
                    Session["lastpage"] = sCurrentPage;
                    Session["error"] = _functions.ErrorMessage(128);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                RepairId = order.iRepairId.Value;
                // saving the parts for entered repair
                dtParts = (DataTable)ViewState["PartsUsed"];
                foreach (DataRow item in dtParts.Rows)
                {
                    if ((int)item["IsNew"] == 1)
                    {
                        order.cAction = "U";
                        order.iPartUsedId = 0;
                        order.iPartUsedQty = (int)item["Qty"];
                        order.sPartUsedStock = (string)item["Stock"];
                        order.sPartUsedDesc = (string)item["Desc"];
                        order.dmPartUsedCost = (decimal)item["Cost"];
                        order.PartsUsedDetails();
                    }
                    if ((int)item["IsDeleted"] == 1)
                    {
                        order.cAction = "D";
                        order.iPartUsedId = (int)item["Id"];
                        if (order.PartsUsedDetails() == -1)
                        {
                            Session["lastpage"] = sCurrentPage;
                            Session["error"] = _functions.ErrorMessage(125);
                            Response.Redirect("error.aspx", false);
                            return;
                        }
                    }
                }
                if (Mode && html_chNewRepair.Checked && sType == "II")
                {
                    order.iInspectItemId = ItemId;
                    foreach (RepeaterItem item in repReportedIssues.Items)
                    {
                        CheckBox cbTmp = (CheckBox)item.FindControl("cbIssue");
                        if (cbTmp.Checked && cbTmp.Enabled)
                        {
                            order.iReportedIssueId = Convert.ToInt32(cbTmp.Attributes["CommandArgument"]);
                            order.SetAssociationsIssue();
                        }
                    }
                }
                if (Hours > 0.0)
                {
                    user = new clsUsers();
                    user.iOrgId = OrgId;
                    user.iOrderId = OrderId;
                    if (user.GetTechnicianInfo() != -1)
                    {
                        order.cAction = "U";
                        order.iTimeLogId = 0;
                        order.iTechId = user.iId;
                        order.daStartTime = SqlDateTime.Null;
                        order.daStopTime = SqlDateTime.Null;
                        order.dmHours = Convert.ToDecimal(Hours);
                        order.dmHourlyRate = user.dmHourlyRate;
                        order.sNote = tbNotes.Text;
                        order.TimeLogDetails();
                    }
                }
                //				}
                //				else
                //					lblRequestor.Visible = true;
            }
            catch (FormatException fex)
            {
                Header.ErrorMessage = _functions.ErrorMessage(205);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                if (user != null)
                    user.Dispose();
                if (order != null)
                    order.Dispose();
            }
        }
Example #9
0
        private void btSave_FormSubmit(object sender, EventArgs e)
        {
            DateTime daCurrentDate;
            try
            {
                daCurrentDate = DateTime.Now;
                order = new clsWorkOrders();
                order.iOrgId = OrgId;
                order.iId = OrderId;
                order.sInitials = Signature.sInitials;
                order.sPIN = Signature.sPIN;
                order.dmMileage = Convert.ToDecimal(tbMileage.Text);
                order.bStaying = Convert.ToBoolean(rblStaying.SelectedValue);
                order.sDropedOffBy = tbDroppedOffBy.Text;
                order.daCurrentDate = _functions.CorrectDate(adtCheckIn.Date);
                if(order.SigningEquipmentCheckIn() == -1)
                {
                    Signature.sError = _functions.ErrorMessage(140);
                }
                else
                {
                    order.cAction = "U";
                    order.iNoteId = 0;
                    order.iItemId = OrderId;
                    order.daCreated = daCurrentDate;

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

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

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

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

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

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

                    finish.bAdditionalVisible = false;

                    finish.bPrintVisible = false;

                    Session["BackFinish"] = finish;

                    Response.Redirect("wo_finish.aspx", false);
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "wo_viewCheckIn.aspx?id=" + OrderId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }
 private void btNext_FormSubmit(object sender, EventArgs e)
 {
     try
     {
         DateTime dtCurrentTime = DateTime.Now;
         order = new clsWorkOrders();
         order.iOrgId = OrgId;
         order.iId = OrderId;
         order.iOperatorId = op.Id;
         if(Operation == "AddIssueReOpen")
             order.iReOpenCategoryId = 2; //Forgot to report an issue
         else if(Operation == "AddCommentReOpen")
             order.iReOpenCategoryId = 1; //Issue not resolved
         else
         {
             Header.ErrorMessage = _functions.ErrorMessage(166);
             return;
         }
         order.daCurrentDate = dtCurrentTime;
         if(order.UpdateReOpenWorkOrder() == -1)
         {
             Session["lastpage"] = "ok_reopenWorkOrder.aspx?id=" + OrderId.ToString() + "&op=Issue";
             Session["error"] = _functions.ErrorMessage(120);
             Response.Redirect("error.aspx", false);
             return;
         }
         order.iUserId = op.Id;
         if(order.SigningWorkOrderReOpen() == -1)
         {
             Session["lastpage"] = "ok_reopenWorkOrder.aspx?id=" + OrderId.ToString() + "&op=Issue";
             Session["error"] = _functions.ErrorMessage(120);
             Response.Redirect("error.aspx", false);
             return;
         }
         Response.Redirect("ok_viewReOpen.aspx?id=" + OrderId.ToString(), false);
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "ok_reopenWorkOrder.aspx?id=" + OrderId.ToString() + "&op=Issue";
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(order != null)
             order.Dispose();
     }
 }
 /// <summary>
 /// Saving the history for current PM item
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSave_Click(object sender, System.EventArgs e)
 {
     try
     {
         order = new clsWorkOrders();
         order.cAction = "U";
         order.iPMHistoryId = HistoryId;
         order.iOrgId = OrgId;
         order.iSchedDetailId = SchedDetailId;
         order.iId = OrderId;
         order.iEquipId = (Int32)ViewState["EquipId"];
         if(tblMain.Rows[4].Visible == false)
             order.daDateHistory = DateTime.Now;
         else
             order.daDateHistory = adtLastTime.Date;
         if(tblMain.Rows[5].Visible == false)
             order.dmUnitsHistory = (SqlDecimal)0;
         else
             order.dmUnitsHistory = Convert.ToDecimal(tbUnits.Text);
         if(order.PMHistoryDetail() != -1)
         {
             // closing current window and relaod parent window
             sOnLoad = "window.close();opener.document.formAddPMItems.submit();";
             Session["reload"] = true;
         }
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
     }
     finally
     {
         if(order != null)
             order.Dispose();
     }
 }
Example #12
0
        private void btnAddRepair_Click(object sender, System.EventArgs e)
        {
            try
            {
                order = new clsWorkOrders();
                equip = new clsEquipment();
                equip.iId = EquipId;
                equip.iOrgId = OrgId;
                order.cAction = "U";
                order.iOrgId = OrgId;
                order.iEquipId = EquipId;
                order.iReportedIssueId = 0;
                order.iRepairCatId = Convert.ToInt32(ddlCategory.SelectedValue);
                order.sReportDesc = tbDesc.Text;
                order.iId = SqlInt32.Null;
                order.iServiceResultId = SqlInt32.Null;
                order.iServiceCheckId = SqlInt32.Null;
                order.iRepairMultId = SqlInt32.Null;
                if(order.WorkOrderReportedIssuesDetail() == -1)
                {
                    Session["lastpage"] = sCurrentPage;
                    Session["error"] = _functions.ErrorMessage(121);
                    Response.Redirect("error.aspx", false);
                }
                tbDesc.Text = "";
                ddlCategory.SelectedIndex = 0;

                ShowIssues();
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = sCurrentPage;
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(equip != null)
                    equip.Dispose();
                if(order != null)
                    order.Dispose();
            }
        }
Example #13
0
        private void dgUnAssignedIssues_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            try
            {
                order = new clsWorkOrders();
                equip = new clsEquipment();
                equip.iId = EquipId;
                equip.iOrgId = OrgId;
                order.cAction = "S";
                order.iOrgId = OrgId;
                order.iReportedIssueId = Convert.ToInt32(((Label)e.Item.FindControl("lblReportIssueId")).Text);
                if(order.WorkOrderReportedIssuesDetail() == -1)
                {
                    Session["lastpage"] = sCurrentPage;
                    Session["error"] = _functions.ErrorMessage(121);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                order.cAction = "U";
                order.sReportDesc = ((TextBox)e.Item.FindControl("tbIssueName")).Text;
                if(order.WorkOrderReportedIssuesDetail() == -1)
                {
                    Session["lastpage"] = sCurrentPage;
                    Session["error"] = _functions.ErrorMessage(121);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                dgUnAssignedIssues.EditItemIndex = -1;

                ShowIssues();
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = sCurrentPage;
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(equip != null)
                    equip.Dispose();
                if(order != null)
                    order.Dispose();
            }
        }
 /// <summary>
 /// Procedure is showing completed work orders on screen
 /// </summary>
 private void ShowCompletedOrders()
 {
     try
     {
         order = new clsWorkOrders();
         order.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
         order.sEquipId = ""; //tbEquipId.Text;
         order.iOperatorId = 0; //Convert.ToInt32(ddlDrivers.SelectedValue);
         dgCompletedWorkOrders.DataSource = new DataView(order.GetWOCompletedList());
         dgCompletedWorkOrders.DataBind();
     }
     catch(Exception ex)
     {
         throw new Exception(ex.Message, ex);
     }
     finally
     {
         if(order != null)
             order.Dispose();
     }
 }
        private void ShowWorkOrders()
        {
            try
            {
                lblCurrentDate.Text = dtCurrentDate.ToLongDateString();
                order = new clsWorkOrders();
                order.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                switch(dtCurrentDate.DayOfWeek)
                {
                    case DayOfWeek.Monday:
                        l_iWeekDay = 0;
                        break;
                    case DayOfWeek.Tuesday:
                        l_iWeekDay = 1;
                        break;
                    case DayOfWeek.Wednesday:
                        l_iWeekDay = 2;
                        break;
                    case DayOfWeek.Thursday:
                        l_iWeekDay = 3;
                        break;
                    case DayOfWeek.Friday:
                        l_iWeekDay = 4;
                        break;
                    case DayOfWeek.Saturday:
                        l_iWeekDay = 5;
                        break;
                    case DayOfWeek.Sunday:
                        l_iWeekDay = 6;
                        break;
                }
                lblMondayDate.Text = "Monday " + dtCurrentDate.AddDays(-(l_iWeekDay)).ToShortDateString();
                lblTuesdayDate.Text = "Tuesday " + dtCurrentDate.AddDays(1-l_iWeekDay).ToShortDateString();
                lblWednesdayDate.Text = "Wednesday " + dtCurrentDate.AddDays(2-l_iWeekDay).ToShortDateString();
                lblThursdayDate.Text = "Thursday " + dtCurrentDate.AddDays(3-l_iWeekDay).ToShortDateString();
                lblFridayDate.Text = "Friday " + dtCurrentDate.AddDays(4-l_iWeekDay).ToShortDateString();
                lblWeekendDate.Text = "Saturday/Sunday " + dtCurrentDate.AddDays(5-l_iWeekDay).ToShortDateString() + " - " + dtCurrentDate.AddDays(6-l_iWeekDay).ToShortDateString();

                order.daMaxDate = dtCurrentDate.AddDays(7-l_iWeekDay);
                order.daMinDate = dtCurrentDate.AddDays(-(l_iWeekDay));
                dtWorkOrders = order.GetWOListForDate();
                // Monday
                dwOrderMonday = new DataView(dtWorkOrders);
                dwOrderMonday.RowFilter = "[WeekDay] = 2";
                dgWorkOrdersMonday.DataSource = dwOrderMonday;
                dgWorkOrdersMonday.DataBind();
                // Tuesday
                dwOrderTuesday = new DataView(dtWorkOrders);
                dwOrderTuesday.RowFilter = "[WeekDay] = 3";
                dgWorkOrdersTuesday.DataSource = dwOrderTuesday;
                dgWorkOrdersTuesday.DataBind();
                // Wednesday
                dwOrderWednesday = new DataView(dtWorkOrders);
                dwOrderWednesday.RowFilter = "[WeekDay] = 4";
                dgWorkOrdersWednesday.DataSource = dwOrderWednesday;
                dgWorkOrdersWednesday.DataBind();
                // Thursday
                dwOrderThursday = new DataView(dtWorkOrders);
                dwOrderThursday.RowFilter = "[WeekDay] = 5";
                dgWorkOrdersThursday.DataSource = dwOrderThursday;
                dgWorkOrdersThursday.DataBind();
                // Friday
                dwOrderFriday = new DataView(dtWorkOrders);
                dwOrderFriday.RowFilter = "[WeekDay] = 6";
                dgWorkOrdersFriday.DataSource = dwOrderFriday;
                dgWorkOrdersFriday.DataBind();
                // Weekend
                dwOrderWeekend = new DataView(dtWorkOrders);
                dwOrderWeekend.RowFilter = "[WeekDay] in (1,7)";
                dgWorkOrdersWeekend.DataSource = dwOrderWeekend;
                dgWorkOrdersWeekend.DataBind();

                Session["CurrentDay"] = dtCurrentDate;
            }
            catch(Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }
        private void SelectXmlTimeSheet()
        {
            XslTransform trans = null;
            XmlDocument doc = null;
            XsltArgumentList agr = null;
            string _input;
            TimeSpan times;
            int iTime = 0;
            try
            {
                GetTimeFromRS(ref iTime);

                times = Cal.SelectedDate.Subtract(new DateTime(1970, 1, 1));
                order = new clsWorkOrders();
                order.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                order.daCurrentDate = Cal.SelectedDate;
                doc = new XmlDocument();
                doc.LoadXml(order.GetWOListForTime());
                trans = new XslTransform();
                trans.Load(Server.MapPath("ShowTime.xsl"));
                agr = new XsltArgumentList();
                agr.AddParam("selected", "", ((long)(times.Ticks/10000)).ToString());
                agr.AddParam("formname", "", (string)ViewState["formname"]);
                agr.AddParam("id", "", (string)ViewState["id"]);
                agr.AddParam("postBack", "", (string)ViewState["postBack"]);
                agr.AddParam("TimeSelected", "", iTime);
                xmlTimeSheet.Document = doc;
                xmlTimeSheet.Transform = trans;
                xmlTimeSheet.TransformArgumentList = agr;

            }
            catch(Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }
Example #17
0
 private void dgRepairs_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
 {
     try
     {
         switch(e.CommandName)
         {
             case "Unassign":
                 order = new clsWorkOrders();
                 order.cAction = "S";
                 order.iOrgId = OrgId;
                 order.iReportedIssueId = Convert.ToInt32(e.Item.Cells[0].Text);
                 if(order.WorkOrderReportedIssuesDetail() == -1)
                 {
                     Session["lastpage"] = m_sBackUrl;
                     Session["error"] = _functions.ErrorMessage(121);
                     Response.Redirect("error.aspx", false);
                     return;
                 }
                 order.cAction = "U";
                 order.iLastWorkOrderId = order.iId;
                 order.iId = SqlInt32.Null;
                 order.WorkOrderReportedIssuesDetail();
                 ShowIssues(OrderId);
                 break;
             case "Delete":
                 order = new clsWorkOrders();
                 order.cAction = "D";
                 order.iOrgId = OrgId;
                 order.iReportedIssueId = Convert.ToInt32(e.Item.Cells[0].Text);
                 if(order.WorkOrderReportedIssuesDetail() == -1)
                 {
                     Session["lastpage"] = m_sBackUrl;
                     Session["error"] = _functions.ErrorMessage(121);
                     Response.Redirect("error.aspx", false);
                     return;
                 }
                 ShowIssues(OrderId);
                 break;
             default:
                 break;
         }
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = m_sBackUrl;
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(order != null)
             order.Dispose();
     }
 }
 /// <summary>
 /// Procedure is showing all work orders for current date
 /// </summary>
 private void ShowWorkOrders()
 {
     try
     {
         lblCurrentDate.Text = dtCurrentDate.ToLongDateString();
         order = new clsWorkOrders();
         order.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
         order.daMaxDate = dtCurrentDate.AddDays(1);
         order.daMinDate = dtCurrentDate;
         dgWorkOrders.DataSource = new DataView(order.GetWOListForDate());
         dgWorkOrders.DataBind();
         Session["CurrentDay"] = dtCurrentDate;
     }
     catch(Exception ex)
     {
         throw new Exception(ex.Message, ex);
     }
     finally
     {
         if(order != null)
             order.Dispose();
     }
 }
        /// <summary>
        /// Procedure is adding a new work order into database and redirecting to finish screen
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btNext_FormSubmit(object sender, EventArgs e)
        {
            string sDataGridName;
            DBFieldType FieldType;
            DateTime daTmpForFixBug, daCurrent;
            try
            {
                daCurrent = DateTime.Now;
                if(adtScheduled.Date < daCurrent)
                {
                    lblErrorScheduled.Text = "The Scheduled date must be in future";
                    return;
                }
                order = new clsWorkOrders();
                order.iOrgId = OrgId;
                order.iEquipId = EquipId;
                if(adtScheduled.Date.Hour == 0 || adtScheduled.Date.Hour == 12)
                {
                    daTmpForFixBug = adtScheduled.Date;
                    if(daTmpForFixBug.Hour == 0)daTmpForFixBug = daTmpForFixBug.AddHours(12);
                    else daTmpForFixBug = daTmpForFixBug.AddHours(-12);
                }
                else
                    daTmpForFixBug = adtScheduled.Date;
                order.daScheduled = daTmpForFixBug;
                order.iInspectSchedDetailId = InspectSchedDetailId;
                order.iUserId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                order.daCurrentDate = daCurrent;
                order.SetInspectWorkOrder();

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

                BackFinishScreen finish = new BackFinishScreen();

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

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

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

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

                finish.bAdditionalVisible = false;

                finish.bPrintVisible = false;

                Session["BackFinish"] = finish;

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

            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "wo_addInspectForecast.aspx?equipid=" + EquipId.ToString() + "&sid=" + InspectSchedDetailId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }
 /// <summary>
 /// Selecting or creating of the Work Order for 
 /// current Equipment if for current equipment there aren't 
 /// the scheduled work order then it will be created. 
 /// If there are one work order then select him. 
 /// If them more than one then we are selecting the one that has 
 /// the scheduled time by closer to the current moment.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btNext_FormSubmit(object sender, EventArgs e)
 {
     try
     {
         order = new clsWorkOrders();
         order.iOrgId = OrgId;
         order.iId = OrderId;
         order.iEquipId = EquipId;
         order.daCurrentDate = DateTime.Now;
         order.dmMileage = Convert.ToDecimal(tbUnits.Text);
         order.iUserId = op.Id;
         order.SelectWorkOrder();
         Response.Redirect("ok_addIssues.aspx?orderid=" + order.iId.Value.ToString() + "&equipid=" + EquipId.ToString(), false);
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "ok_editCurrentUnits.aspx?orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString();
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(order != null)
             order.Dispose();
     }
 }
Example #21
0
        private void lbSaveNotes_Click(object sender, System.EventArgs e)
        {
            try
            {
                Header.BodyOnloadScript  = "javascript:document.location='#Notes'";
                //Header.Render();

                order = new clsWorkOrders();
                order.cAction = "U";
                order.iOrgId = OrgId;
                order.iNoteId = 0;
                order.iNoteTypeId = (int)NoteTypes.TechnicianNote;
                order.iItemId = OrderId;
                order.daCreated = DateTime.Now;
                order.sNote = tbNotes.Text;
                order.iUserId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                order.NoteDetails();
                tbNotes.Text = "";
                order.iNoteTypeId = (int)NoteTypes.TechnicianNote;
                repTechNotes.DataSource = new DataView(order.GetNotesList());
                repTechNotes.DataBind();
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }
Example #22
0
        private void btnAddTimeLog_Click(object sender, System.EventArgs e)
        {
            try
            {
                double Hours = 0.0;
                DateTime daStartTime, daStopTime;
                TimeSpan tsDiff = new TimeSpan(0);
                daStopTime = rdiStopTime.SelectedDate;
                daStartTime = rdiStartTime.SelectedDate;

                if(tbHours.Text.Length > 0 || tbMinutes.Text.Length > 0)
                {
                    if(tbHours.Text.Length > 0) Hours += Convert.ToDouble(tbHours.Text);
                    if(tbMinutes.Text.Length > 0) Hours += Convert.ToDouble(tbMinutes.Text)/60;
                }
                else
                {
                    // get hours from the difference betweent the Stop and Start time entries
                    if(daStopTime <= daStartTime)
                    {
                        Header.ErrorMessage = _functions.ErrorMessage(204);
                        return;
                    }
                    else
                    {
                        tsDiff = daStopTime - daStartTime;
                        Hours = tsDiff.TotalHours;
                    }
                }
                if(Hours >= 1000)
                {
                    Header.ErrorMessage = _functions.ErrorMessage(203);
                    return;
                }
                order = new clsWorkOrders();
                order.cAction = "U";
                order.iTimeLogId = 0;
                order.iOrgId = OrgId;
                order.iId = OrderId;
                order.iRepairId = Convert.ToInt32(ddlRepairs.SelectedValue);
                order.iTechId = Convert.ToInt32(ddlTechnicians.SelectedValue);
                if(tsDiff.Ticks != 0)
                {
                    order.daStartTime = daStartTime;
                    order.daStopTime = daStopTime;
                }
                else
                {
                    order.daStartTime = SqlDateTime.Null;
                    order.daStopTime = SqlDateTime.Null;
                }
                order.dmHours = Convert.ToDecimal(Hours);
                if(ViewState["HourlyRate"] == null)
                    order.dmHourlyRate = Convert.ToDecimal(tbHourlyRate.Text);
                else
                    order.dmHourlyRate = Convert.ToDecimal(ViewState["HourlyRate"]);
                order.sNote = tbNote.Text;
                order.TimeLogDetails();
                //order.Dispose();
                //order = new clsWorkOrders();
                //order.iOrgId = OrgId;
                tbHourlyRate.Text = "";
                tbHours.Text = "";
                tbMinutes.Text = "";
                tbNote.Text = "";
                rdiStartTime.SelectedDate = dtNow;
                rdiStopTime.SelectedDate = dtNow;
                Response.Redirect("wo_updateTimeLog.aspx?id=" + OrderId.ToString() + "&repairid=" + RepairId.ToString(), false);
            }
            catch(FormatException fex)
            {
                Header.ErrorMessage = _functions.ErrorMessage(108);
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "wo_updateTimeLog.aspx?id=" + OrderId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }
Example #23
0
 /// <summary>
 /// the common procedure of saving for all associations in the Add mode in database
 /// </summary>
 private void SaveAssociations()
 {
     try
     {
         order = new clsWorkOrders();
         order.iOrgId = OrgId;
         order.iId = OrderId;
         order.sTypeService = sType;
         order.iItemId = ItemId;
         if (ServiceResult == "Repair")
             order.iServiceResultId = (int)ServiceResults._Repaired;
         else
             order.iServiceResultId = (int)ServiceResults._Replaced;
         foreach (RepeaterItem item in repRepairs.Items)
         {
             order.iRepairId = Convert.ToInt32(((LinkButton)item.FindControl("lbEditRepair")).CommandArgument);
             order.bChecked = ((CheckBox)item.FindControl("cbRepair")).Checked;
             order.SetAssociationsRepair();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex);
     }
     finally
     {
         if (order != null)
             order.Dispose();
     }
 }
 private void btNext_FormSubmit(object sender, EventArgs e)
 {
     DateTime daCurrentDate;
     try
     {
         UserId = Convert.ToInt32(ddlTech.SelectedValue);
         daCurrentDate = DateTime.Now;
         order = new clsWorkOrders();
         order.iOrgId = OrgId;
         order.iEquipId = EquipId;
         order.daCurrentDate = daCurrentDate;
         order.iUserId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
         order.iId = OrderId;
         order.iTechId = UserId;
         order.SetRoadsideWorkOrder();
         OrderId = order.iId.Value;
         Response.Redirect("wo_selectSpareEquip.aspx?select=AddRoadside&id=" + OrderId.ToString() + "&equipid=" + EquipId.ToString(), false);
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "wo_selectOperator.aspx?equipid=" + EquipId.ToString() + "&orderid=" + OrderId.ToString();
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(order != null)
             order.Dispose();
     }
 }
Example #25
0
        /// <summary>
        /// Procedure close the work order detail
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btSave_FormSubmit(object sender, EventArgs e)
        {
            DateTime daCurrentDate;
            try
            {
                daCurrentDate = DateTime.Now;
                order = new clsWorkOrders();
                order.iOrgId = OrgId;
                order.iId = OrderId;
                order.sInitials = Signature.sInitials;
                order.sPIN = Signature.sPIN;
                order.sReleasedTo = tbReleasedTo.Text;
                order.daCurrentDate = _functions.CorrectDate(adtCheckOut.Date);
                // signing the Check-Out of Equipment by Technician
                if(order.SigningEquipmentCheckOut() == -1)
                {
                    Signature.sError = _functions.ErrorMessage(140);
                }
                else
                {
                    equip = new clsEquipment();
                    equip.iOrgId = OrgId;
                    equip.iUserId = order.iUserId;
                    equip.iOrderId = OrderId;
                    equip.iId = System.Data.SqlTypes.SqlInt32.Null;
                    equip.sNote = "";
                    equip.EquipSpareTo(false);

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

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

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

                    finish.bContinueVisible = false;

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

                    finish.bAdditionalVisible = false;

                    finish.bPrintVisible = false;

                    Session["BackFinish"] = finish;

                    Response.Redirect("wo_finish.aspx", false);
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "wo_viewCheckOut.aspx?id=" + OrderId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(equip != null)
                    equip.Dispose();
                if(order != null)
                    order.Dispose();
            }
        }
Example #26
0
        private void btNext_FormSubmit(object sender, EventArgs e)
        {
            try
            {
                order = new clsWorkOrders();

                if(ddlCategory.SelectedIndex != 0 && tbDesc.Text.Length != 0)
                {
                    order.cAction = "U";
                    order.iOrgId = OrgId;
                    order.iReportedIssueId = 0;
                    order.iRepairCatId = Convert.ToInt32(ddlCategory.SelectedValue);
                    order.sReportDesc = tbDesc.Text;
                    order.iId = OrderId;
                    order.iServiceResultId = SqlInt32.Null;
                    order.iServiceCheckId = SqlInt32.Null;
                    order.iRepairMultId = SqlInt32.Null;
                    if(order.WorkOrderReportedIssuesDetail() == -1)
                    {
                        Session["lastpage"] = m_sBackUrl;
                        Session["error"] = _functions.ErrorMessage(121);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                }
                if(m_sBack == "open")
                    Response.Redirect("wo_addPreventiveMaintenance.aspx?id=" + OrderId.ToString(), false);
                else
                {
                    // redirect to finish screen
                    order.iOrgId = OrgId;
                    order.iId = OrderId;

                    if(order.GetWorkOrderId() == -1)
                    {
                        Session["lastpage"] = m_sBackUrl;
                        Session["error"] = _functions.ErrorMessage(102);
                        Response.Redirect("error.aspx", false);
                        return;
                    }

                    BackFinishScreen finish = new BackFinishScreen();
                    finish.sMainText = "The Work Order " + order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString() + " has been created successfully!";

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

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

                    finish.bViewVisible = true;
                    finish.sViewText = "[View the Scheduled Work Order]";
                    finish.sViewURL = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();

                    finish.bAdditionalVisible = true;
                    finish.sAdditionalText = "[Create a New Work Order]";
                    finish.sAdditionalURL = "wo_default.aspx";

                    finish.bPrintVisible = false;

                    Session["BackFinish"] = finish;

                    Response.Redirect("wo_finish.aspx", false);
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = m_sBackUrl;
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }
Example #27
0
 private void btnYES_Click(object sender, System.EventArgs e)
 {
     try
     {
         order = new clsWorkOrders();
         order.iOrgId = OrgId;
         order.iId = OrderId;
         order.bStaying = true;
         if(order.UpdateStayingWorkOrder() == -1)
         {
             Session["lastpage"] = "ok_editStaying.aspx?orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString();
             Session["error"] = _functions.ErrorMessage(120);
             Response.Redirect("error.aspx", false);
         }
         else
             Response.Redirect("ok_editNote.aspx?orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString(), false);
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "ok_editStaying.aspx?orderid=" + OrderId.ToString() + "&equipid=" + EquipId.ToString();
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(order != null)
             order.Dispose();
     }
 }
 /// <summary>
 /// Procedure is processing the inspections on screen, i.e. to add or delete 
 /// if them check boxes was selected/unselected
 /// </summary>
 private void ProcessingItems()
 {
     try
     {
         order = new clsWorkOrders();
         order.iOrgId = OrgId;
         order.iId = OrderId;
         foreach(DataGridItem item in dgInspections.Items)
         {
             if(((CheckBox)item.FindControl("chAdd")).Enabled)
             {
                 if(IsPast)
                     order.daCurrentDate = ((DateTime)ViewState["WorkOrderCreatedDate"]);
                 else
                     order.daCurrentDate = DateTime.Now;
                 order.iInspectSchedDetailId = Convert.ToInt32(item.Cells[0].Text);
                 order.iWOInspectionId = Convert.ToInt32(item.Cells[1].Text);
                 order.bChecked = ((CheckBox)item.FindControl("chAdd")).Checked;
                 order.UpdateInspection();
             }
         }
     }
     catch(Exception ex)
     {
         throw new Exception(ex.Message, ex);
     }
     finally
     {
         if(order != null)
             order.Dispose();
     }
 }
Example #29
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();
                }
            }
        }
Example #30
0
        private void btnAddPart_Click(object sender, System.EventArgs e)
        {
            try
            {
                OrderId = (int)ViewState["OrderId"];
                RepairId = (int)ViewState["RepairId"];
                InspectId = (int)ViewState["InspectId"];

                order = new clsWorkOrders();
                order.cAction = "U";
                order.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                order.iPartUsedId = 0;
                order.iRepairId = RepairId;
                order.iPartUsedQty = Convert.ToInt32(tbQty.Text);
                order.sPartUsedStock = tbStock.Text;
                order.sPartUsedDesc = tbDesc.Text;
                if(tbCost.Text.Length > 0)
                    order.dmPartUsedCost = Convert.ToDecimal(tbCost.Text);
                order.PartsUsedDetails();
                tbQty.Text = "";
                tbStock.Text = "";
                tbDesc.Text = "";
                tbCost.Text = "";
                dgParts.DataSource = new DataView(order.GetPartsUsedList());
                dgParts.DataBind();
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "wo_editPartsUsed.aspx?id=" + OrderId.ToString() + "&repairid=" + RepairId.ToString() + "&inspectid=" + InspectId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }