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(); } } }
private void dgParts_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { try { if (e.CommandName == "Delete") { OrderId = (int)ViewState["OrderId"]; RepairId = (int)ViewState["RepairId"]; order = new clsWorkOrders(); order.cAction = "D"; order.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); order.iPartUsedId = Convert.ToInt32(e.Item.Cells[0].Text); order.iRepairId = RepairId; if (order.PartsUsedDetails() == -1) { Session["lastpage"] = "wo_editPartsUsed.aspx?id=" + OrderId.ToString() + "&repairid=" + RepairId.ToString(); Session["error"] = _functions.ErrorMessage(125); Response.Redirect("error.aspx", false); return; } 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(); Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if (order != null) { order.Dispose(); } } }
private void Page_Load(object sender, System.EventArgs e) { try { string [,] arrBrdCrumbs; SourcePageName = "wo_editPartsUsed.aspx.cs"; if (Request.QueryString["id"] == null || Request.QueryString["repairid"] == null) { Session["lastpage"] = "main.aspx"; Session["error"] = _functions.ErrorMessage(104); Response.Redirect("error.aspx", false); return; } try { OrderId = Convert.ToInt32(Request.QueryString["id"]); RepairId = Convert.ToInt32(Request.QueryString["repairid"]); if (Request.QueryString["inspectid"] != null) { InspectId = Convert.ToInt32(Request.QueryString["inspectid"]); } else { InspectId = 0; } } catch (FormatException fex) { Session["lastpage"] = "main.aspx"; Session["error"] = _functions.ErrorMessage(105); Response.Redirect("error.aspx", false); return; } ViewState["OrderId"] = OrderId; ViewState["RepairId"] = RepairId; ViewState["InspectId"] = InspectId; arrBrdCrumbs = ConvertBreadCrumbs(((string[, ])Session["BrdCrumbs"]), "wo_viewWorkOrder.aspx?id=" + OrderId.ToString(), "Work Order Detail"); if (InspectId != 0) { arrBrdCrumbs = ConvertBreadCrumbs(arrBrdCrumbs, "wo_viewCompleteInspection.aspx?id=" + OrderId.ToString() + "&inspectid=" + InspectId.ToString(), "The Inspection"); } PageTitle = "Enter Notes and Parts"; Header.BrdCrumbs = ParseBreadCrumbs(arrBrdCrumbs, PageTitle); Header.PageTitle = PageTitle; SaveCancelControl.CausesValidation = false; SaveCancelControl.ButtonText = " Save "; SaveCancelControl.ParentPageURL = ParentPageURL; if (ViewState["VisibleCancel"] != null) { SaveCancelControl.IsCancel = (bool)ViewState["VisibleCancel"]; } if (!IsPostBack) { order = new clsWorkOrders(); order.cAction = "S"; order.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); dsRepairItemsCats = order.GetRepairItemsAndCats(); dsRepairItemsCats.Relations.Add(new DataRelation("Cats_Items", dsRepairItemsCats.Tables["Table"].Columns["Id"], dsRepairItemsCats.Tables["Table1"].Columns["CatId"])); ddlRepairCats.DataSource = dsRepairItemsCats; ddlRepairCats.DataBind(); ddlRepairItems.DataSource = dsRepairItemsCats; ddlRepairItems.DataBind(); ListLink.DataBind(); order.iId = OrderId; order.iRepairId = RepairId; if (order.RepairCommonDetails() == -1) { if (InspectId != 0) { Session["lastpage"] = "wo_viewCompleteInspection.aspx?id=" + OrderId.ToString() + "&inspectid=" + InspectId.ToString(); } else { Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString(); } Session["error"] = _functions.ErrorMessage(123); Response.Redirect("error.aspx", false); return; } if (order.iRepairItemId.Value == 0 && order.sRepairDesc.Value == "") { SaveCancelControl.IsCancel = false; ViewState["VisibleCancel"] = false; } else { ViewState["VisibleCancel"] = true; } ddlRepairCats.SelectedValue = order.iRepairCatId.Value.ToString(); ddlRepairItems.SelectedValue = order.iRepairItemId.Value.ToString(); tbNotes.Text = order.sRepairDesc.Value; dgSources.DataSource = new DataView(order.GetSourceList()); dgSources.DataBind(); dgParts.DataSource = new DataView(order.GetPartsUsedList()); dgParts.DataBind(); } } catch (Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); if (InspectId != 0) { Session["lastpage"] = "wo_viewCompleteInspection.aspx?id=" + OrderId.ToString() + "&inspectid=" + InspectId.ToString(); } else { 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(); } } }
private void Page_Load(object sender, System.EventArgs e) { try { OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); if (Request.QueryString["repairid"] != null && !string.IsNullOrEmpty(Request.QueryString["repairid"])) { RepairId = Convert.ToInt32(Request.QueryString["repairid"]); } if (Request.QueryString["mode"] == null || Request.QueryString["id"] == null || Request.QueryString["repairid"] == null) { Session["lastpage"] = "main.aspx"; Session["error"] = _functions.ErrorMessage(104); Response.Redirect("error.aspx", false); return; } try { if (Request.QueryString["mode"] == "Add") { Mode = true; } else { Mode = false; } OrderId = Convert.ToInt32(Request.QueryString["id"]); if (Request.QueryString["inspectid"] != null) { InspectId = Convert.ToInt32(Request.QueryString["inspectid"]); } else { InspectId = 0; } if (Request.QueryString["itemid"] != null) { ItemId = Convert.ToInt32(Request.QueryString["itemid"]); } else { ItemId = 0; } if (Request.QueryString["type"] != null) { sType = Request.QueryString["type"]; //RI, PMI, II, FREE } else { sType = ""; } if (Request.QueryString["op"] != null) { ServiceResult = Request.QueryString["op"]; //Repair, Replace } else { ServiceResult = ""; } sCurrentPage = "wo_updateRepair.aspx?mode=" + (Mode ? "Add" : "Edit") + "&id=" + OrderId.ToString() + "&repairid=" + RepairId.ToString() + "&inspectid=" + InspectId.ToString() + "&itemid=" + ItemId.ToString() + "&type=" + sType + "&op=" + ServiceResult; } 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() + "&#Repairs"); if (sType == "II") // if came from Inspetion screen { Header.AddBreadCrumb("Inspection Detail", "/wo_viewCompleteInspection.aspx?id=" + OrderId.ToString() + "&inspectid=" + InspectId.ToString()); sLastPage = "wo_viewCompleteInspection.aspx?id=" + OrderId.ToString() + "&inspectid=" + InspectId.ToString(); } else { sLastPage = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString() + "&#Repairs"; } if (Mode) { this.PageTitle = "Update Repair"; } else if (sType == "FREE") { this.PageTitle = "Add Repair"; } else { this.PageTitle = "Edit Repair"; } Header.AddJavaScriptFile("/wo_updateRepair.js"); Header.BodyOnloadScript = "javascript:CheckEditMode();"; SaveCancelControl.CausesValidation = false; SaveCancelControl.ButtonText = " Save & Back "; SaveCancelControl.IsCancel = false; ddlRepairCats.Attributes.Add("onchange", "javascript:ValidRepairItems();"); ddlRepairItems.Attributes.Add("onchange", "javascript:ValidRepairItems();"); clsWorkOrders orders = new clsWorkOrders(); string key = orders.GetIntegrationKey(this.OrgId); clsUsers user = new clsUsers(); user.cAction = "S"; user.iOrgId = OrgId; user.iId = _functions.GetUserOrgId(Context.User.Identity.Name, true); user.UserDetails(); if (RepairId == 0) { preRepairId = orders.GetRepairPreId(); preRepairId++; } WarehousePanel.Visible = false; //if (string.IsNullOrEmpty(key)) // WarehousePanel.Visible = false; //else //{ // string url = String.Format(_functions.GetValueFromConfig("WarehouseListnerPage") + "?action=create&key={0}&app=fleet&roid={1}&riid={2}&rufn={3}&ruln={4}&rue={5}&ron={6}&rofn={7}&shipto={8}&shiploc={9}", key, RepairId > 0 ? RepairId.ToString() : preRepairId.ToString(), string.Empty, user.sFirstName.Value, user.sLastName.Value, user.sEmail.Value, "Work Order", OrderId.ToString(), user.sFirstName.Value + " " + user.sLastName.Value, string.Empty); // string windowOpenScript = "function openWindow() { window.open('" + url + "','Warehouse','height=600,width=900,toolbar=0,status=1,location=0,menubar=0,scrollbars=1,resizable=1'); }"; // if (!Page.ClientScript.IsClientScriptBlockRegistered("openWindow")) // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "openWindow", windowOpenScript, true); //} if (!IsPostBack) { order = new clsWorkOrders(); order.cAction = "S"; order.iOrgId = OrgId; order.iId = OrderId; order.iRepairId = RepairId; dsRepairItemsCats = order.GetRepairItemsAndCats(); dsRepairItemsCats.Relations.Add(new DataRelation("Cats_Items", dsRepairItemsCats.Tables["Table"].Columns["Id"], dsRepairItemsCats.Tables["Table1"].Columns["CatId"])); ddlRepairCats.DataSource = dsRepairItemsCats; ddlRepairCats.DataBind(); ddlRepairItems.DataSource = dsRepairItemsCats; ddlRepairItems.DataBind(); ListLink.DataBind(); if (Mode) // Add Mode { order.sTypeService = sType; order.iItemId = ItemId; if (sType == "II") { lblTableTitle.Text = "Please check the following to update any reported issues associated with this Inspection item"; DataTable dtReportedIssues = order.GetReportedIssuesListUpdate(); if (dtReportedIssues.Rows.Count > 0) { repReportedIssues.DataSource = new DataView(dtReportedIssues); repReportedIssues.DataBind(); } else { lblTableTitle.Text = "Serviced Repairs"; repReportedIssues.Visible = false; } } else { lblTableTitle.Text = "Serviced Repairs"; repReportedIssues.Visible = false; } // showing all repaires with associations repRepairs.DataSource = new DataView(order.GetRepairsListUpdate()); repRepairs.DataBind(); order.GetIssueInfo(); lblSourceType.Text = order.sTypeService.Value; lblRepairCategory.Text = order.sRepairCatName.Value; lblIssue.Text = order.sServiceName.Value; } else // Edit Mode { // hidding the controls for Edit mode tblSource.Visible = false; lblTableTitle.Text = "Repair"; repRepairs.Visible = false; html_chNewRepair.Visible = false; lblTableFooter.Visible = false; RepairLogsLinksPanel.Visible = false; // getting repair's info order.RepairCommonDetails(); ddlRepairCats.SelectedValue = order.iRepairCatId.Value.ToString(); ddlRepairItems.SelectedValue = order.iRepairItemId.Value.ToString(); tbNotes.Text = order.sRepairDesc.Value; } dtParts = order.GetPartsUsedList(); ViewState["PartsUsed"] = dtParts; dwParts = new DataView(dtParts); dwParts.RowFilter = "IsDeleted=0"; repParts.DataSource = dwParts; repParts.DataBind(); } } catch (Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = sLastPage; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if (order != null) { order.Dispose(); } } }