private void Page_Load(object sender, System.EventArgs e) { try { if(Request.QueryString["id"] == null) { Session["lastpage"] = "wo_default.aspx"; Session["error"] = _functions.ErrorMessage(104); Response.Redirect("error.aspx", false); return; } try { OrderId = Convert.ToInt32(Request.QueryString["id"]); OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); } catch(FormatException fex) { Session["lastpage"] = "wo_default.aspx"; Session["error"] = _functions.ErrorMessage(105); Response.Redirect("error.aspx", false); return; } if(Request.QueryString["repairid"] != null) RepairId = Convert.ToInt32(Request.QueryString["repairid"]); else RepairId = 0; html_btnBack.Attributes.Add("onclick", "document.location='wo_viewWorkOrder.aspx?id=" + OrderId.ToString() + "&#TimeLog';"); if (Request.Cookies.Count > 0 && Request.Cookies["bfp_navigate"] != null) Header.BrdCrumbsSerialization = Request.Cookies["bfp_navigate"].Value; Header.AddBreadCrumb("Work Order Detail", "/wo_viewWorkOrder.aspx?id=" + OrderId.ToString()); dtNow = DateTime.Now; if(!IsPostBack) { rdiStartTime.SelectedDate = dtNow; rdiStopTime.SelectedDate = dtNow; order = new clsWorkOrders(); user = new clsUsers(); order.cAction = "S"; order.iOrgId = OrgId; order.iId = OrderId; user.iOrgId = OrgId; user.iOrderId = OrderId; user.iTypeId = (int)UserTypes.Technician; DataTable dtTechList = user.GetUserListByType(); dtTechList.Rows[0].Delete(); ddlTechnicians.DataSource = new DataView(dtTechList); ddlTechnicians.DataBind(); DataTable dtRepairList = order.GetRepairsShortList(); dtRepairList.Rows[0].Delete(); ddlRepairs.DataSource = new DataView(dtRepairList); ddlRepairs.DataBind(); if(order.WorkOrderDetails() == -1) { Session["lastpage"] = this.ParentPageURL; Session["error"] = _functions.ErrorMessage(120); Response.Redirect("error.aspx", false); return; } if(!user.IsTechnician(_functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true))) { Session["lastpage"] = this.ParentPageURL; Session["error"] = _functions.ErrorMessage(131); Response.Redirect("error.aspx", false); return; } lblWorkOrderId.Text = order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString(); lblEquipId.Text = order.sEquipId.Value; lblOperator.Text = order.sOperatorName.Value; lblTech.Text = order.sTechName.Value; if(user.GetTechnicianInfo() != -1) { tbHourlyRate.Text = user.dmHourlyRate.Value.ToString("F"); if(!user.bTechCanViewHourlyRate.Value) { ViewState["HourlyRate"] = user.dmHourlyRate.Value; html_tblMain.Rows[12].Visible = false; html_trTotalCosts.Visible = false; } else { ViewState["HourlyRate"] = null; html_tblMain.Rows[12].Visible = true; html_trTotalCosts.Visible = true; } } else { html_trTotalCosts.Visible = true; html_tblMain.Rows[12].Visible = true; tbHourlyRate.Text = "0.0"; ViewState["HourlyRate"] = null; } if(ddlTechnicians.Items.FindByValue(order.iTechId.Value.ToString()) != null) { ddlTechnicians.SelectedValue = order.iTechId.Value.ToString(); } else { ddlTechnicians.SelectedIndex = 0; } if(ddlRepairs.Items.FindByValue(RepairId.ToString()) != null) { ddlRepairs.SelectedValue = RepairId.ToString(); } else { ddlRepairs.SelectedIndex = 0; } order.iTechId = 0; dtTimeLog = order.GetTimeLogList(); if(dtTimeLog.Rows.Count > 0) { repTimeLog.DataSource = new DataView(dtTimeLog); repTimeLog.DataBind(); html_tblNoneTimeLog.Visible = false; lblTotalHours.Text = order.sReportDesc.Value; lblTotalCosts.Text = order.sDecs.Value; } else { html_tblNoneTimeLog.Visible = true; repTimeLog.Visible = false; html_trTotalHours.Visible = false; html_trTotalCosts.Visible = false; } } } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = this.ParentPageURL; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(user != null) user.Dispose(); if(order != null) order.Dispose(); } }
/// <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(); } }
private void ddlTechnicians_SelectedIndexChanged(object sender, System.EventArgs e) { try { user = new clsUsers(); user.iOrgId = OrgId; user.iOrderId = OrderId; user.iId = Convert.ToInt32(ddlTechnicians.SelectedValue); if(user.GetTechnicianInfo() != -1) { tbHourlyRate.Text = user.dmHourlyRate.Value.ToString("F"); if(!user.bTechCanViewHourlyRate.Value) { ViewState["HourlyRate"] = user.dmHourlyRate.Value; html_tblMain.Rows[12].Visible = false; html_trTotalCosts.Visible = false; } else { ViewState["HourlyRate"] = null; html_tblMain.Rows[12].Visible = true; html_trTotalCosts.Visible = true; } } else { html_tblMain.Rows[12].Visible = true; html_trTotalCosts.Visible = true; tbHourlyRate.Text = "0.0"; ViewState["HourlyRate"] = null; } } 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(user != null) user.Dispose(); } }
/// <summary> /// DataBinding te RepairList and PartsList /// </summary> private void ShowRepairList() { try { order.iOrgId = OrgId; order.iId = OrderId; order.iTechId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true); dtRepairs = order.GetRepairsList(); if(dtRepairs.Rows.Count > 0) html_tblNoneRepairs.Visible = false; else html_tblNoneRepairs.Visible = true; repRepairs.DataSource = new DataView(dtRepairs); repRepairs.DataBind(); dtPartsUsed = order.GetPartsUsedListForOrder(); if(dtPartsUsed.Rows.Count > 0) html_tblNoneParts.Visible = false; else html_tblNoneParts.Visible = true; repPartsUsed.DataSource = new DataView(dtPartsUsed); repPartsUsed.DataBind(); if(order.GetCompleteAbleOrder() == 1) hlCloseOrder.Enabled = true; else hlCloseOrder.Enabled = false; if(order.GetDeleteAbleOrder() == 1) hlDeleteOrder.Enabled = true; else hlDeleteOrder.Enabled = false; order.iId = OrderId; order.iTechId = 0; DataTable dtTimeLog = order.GetTimeLogList(); if(dtTimeLog.Rows.Count > 0) { repTimeLog.DataSource = new DataView(dtTimeLog); repTimeLog.DataBind(); html_tblNoneTimeLog.Visible = false; lblTotalHours.Text = order.sReportDesc.Value; lblTotalCosts.Text = order.sDecs.Value; user = new clsUsers(); user.iOrgId = OrgId; user.iOrderId = OrderId; if(user.GetTechnicianInfo() != -1) if(!user.bTechCanViewHourlyRate.Value) html_trTotalCosts.Visible = false; else html_trTotalCosts.Visible = true; } else { repTimeLog.Visible = false; html_tblNoneTimeLog.Visible = true; html_trTotalHours.Visible = false; html_trTotalCosts.Visible = false; } } catch(Exception ex) { throw new Exception(ex.Message, ex); } }