/// <summary> /// GetNextId /// </summary> /// <param name="actualCostsNavigatorTDS">actualCostsNavigatorTDS</param> /// <param name="currentRefID">currentRefID</param> /// <returns>nextRefID</returns> public static int GetNextId(ActualCostsNavigatorTDS actualCostsNavigatorTDS, int currentRefID) { int nextRefID = currentRefID; for (int i = 0; i < actualCostsNavigatorTDS.HotelCosts.DefaultView.Count; i++) { if ((int)actualCostsNavigatorTDS.HotelCosts.DefaultView[i]["RefID"] == currentRefID) { if (i == actualCostsNavigatorTDS.HotelCosts.DefaultView.Count - 1) { nextRefID = currentRefID; } else { nextRefID = (int)actualCostsNavigatorTDS.HotelCosts.DefaultView[i + 1]["RefID"]; } break; } } return nextRefID; }
// //////////////////////////////////////////////////////////////////////// // PRIVATE METHODS // /// <summary> /// GetPreviousId /// </summary> /// <param name="actualCostsNavigatorTDS">actualCostsNavigatorTDS</param> /// <param name="currentRefID">currentRefID</param> /// <returns>prevRefID</returns> public static int GetPreviousId(ActualCostsNavigatorTDS actualCostsNavigatorTDS, int currentRefID) { int prevRefID = currentRefID; for (int i = 0; i < actualCostsNavigatorTDS.HotelCosts.DefaultView.Count; i++) { if ((int)actualCostsNavigatorTDS.HotelCosts.DefaultView[i]["RefID"] == currentRefID) { if (i == 0) { prevRefID = currentRefID; } else { prevRefID = (int)actualCostsNavigatorTDS.HotelCosts.DefaultView[i - 1]["RefID"]; } break; } } return prevRefID; }
private ActualCostsNavigatorTDS SubmitSearch() { // Values to search int projectId = Convert.ToInt32(ddlProject.SelectedValue); int clientId = Convert.ToInt32(ddlClient.SelectedValue); string textForSearch = tbxTextForSearch.Text; string category = ddlCategory.SelectedValue; ActualCostsNavigatorTDS actualCostsNavigatorTDSForSearch = new ActualCostsNavigatorTDS(); // Retrieve Where clause if (category == "All") { // ... subcontractors LoadBySubcontractor(projectId, clientId, textForSearch, actualCostsNavigatorTDSForSearch, -1); // ... hotels LoadByHotel(projectId, clientId, textForSearch, actualCostsNavigatorTDSForSearch, -1); // ... insurance LoadByInsurance(projectId, clientId, textForSearch, actualCostsNavigatorTDSForSearch, -1); // ... bonding LoadByBonding(projectId, clientId, textForSearch, actualCostsNavigatorTDSForSearch, -1); // ... others LoadByOther(projectId, clientId, textForSearch, actualCostsNavigatorTDSForSearch, "LoadAll"); } else { if (category == "Subcontractors") { int subcontractorId = Convert.ToInt32(ddlSubcontractor.SelectedValue); LoadBySubcontractor(projectId, clientId, textForSearch, actualCostsNavigatorTDSForSearch, subcontractorId); } else { if (category == "Hotels") { int hotelId = Convert.ToInt32(ddlHotels.SelectedValue); LoadByHotel(projectId, clientId, textForSearch, actualCostsNavigatorTDSForSearch, hotelId); } else { if (category == "Insurance") { int insuranceCompanyId = Convert.ToInt32(ddlInsurance.SelectedValue); LoadByInsurance(projectId, clientId, textForSearch, actualCostsNavigatorTDSForSearch, insuranceCompanyId); } else { if (category == "Bonding") { int bondingCompanyId = Convert.ToInt32(ddlBonding.SelectedValue); LoadByBonding(projectId, clientId, textForSearch, actualCostsNavigatorTDSForSearch, bondingCompanyId); } else { LoadByOther(projectId, clientId, textForSearch, actualCostsNavigatorTDSForSearch, category); } } } } } return actualCostsNavigatorTDSForSearch; }
/// <summary> /// InitData /// </summary> protected override void InitData() { _data = new ActualCostsNavigatorTDS(); }
private void LoadBySubcontractor(int projectId, int clientId, string textForSearch, ActualCostsNavigatorTDS actualCostsNavigatorTDSForSearch, int subcontractorId) { string whereClause = GetWhereClauseForSubcontractor(subcontractorId, projectId, clientId, textForSearch); string orderByClause = GetOrderByClause(); ActualCostsNavigatorSubcontractorCosts actualCostsNavigatorSubcontractorCosts = new ActualCostsNavigatorSubcontractorCosts(actualCostsNavigatorTDSForSearch); actualCostsNavigatorSubcontractorCosts.Load(whereClause, orderByClause); }
private void LoadByOther(int projectId, int clientId, string textForSearch, ActualCostsNavigatorTDS actualCostsNavigatorTDSForSearch, string category) { bool loadAll = false; if (category == "LoadAll") loadAll = true; string whereClause = GetWhereClauseForOther(category, projectId, clientId, textForSearch, loadAll); string orderByClause = GetOrderByClause(); ActualCostsNavigatorOtherCosts actualCostsNavigatorOtherCosts = new ActualCostsNavigatorOtherCosts(actualCostsNavigatorTDSForSearch); actualCostsNavigatorOtherCosts.Load(whereClause, orderByClause); }
private void LoadByInsurance(int projectId, int clientId, string textForSearch, ActualCostsNavigatorTDS actualCostsNavigatorTDSForSearch, int insuranceCompanyId) { string whereClause = GetWhereClauseForInsurance(insuranceCompanyId, projectId, clientId, textForSearch); string orderByClause = GetOrderByClause(); ActualCostsNavigatorInsuranceCompaniesCosts actualCostsNavigatorInsuranceCompaniesCosts = new ActualCostsNavigatorInsuranceCompaniesCosts(actualCostsNavigatorTDSForSearch); actualCostsNavigatorInsuranceCompaniesCosts.Load(whereClause, orderByClause); }
// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_ACTUAL_COSTS_ADMIN"]))) { // Security check if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_ACTUAL_COSTS_VIEW"]))) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } // Validate query string if ((string)Request.QueryString["source_page"] == null) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in actual_costs_navigator.aspx"); } } // Tag Page hdfCompanyId.Value = Session["companyID"].ToString(); tkrdpStartDate.SelectedDate = DateTime.Now; tkrdpEndDate.SelectedDate = DateTime.Now; Session.Remove("subcontractorCostsNewDummy"); Session.Remove("hotelCostsNewDummy"); Session.Remove("insuranceCompaniesCostsNewDummy"); Session.Remove("bondingCompaniesCostsNewDummy"); Session.Remove("OtherCostsNewDummy"); // ... for conditions ddlCategory.SelectedIndex = 0; tbxTextForSearch.Visible = true; ddlSubcontractor.Visible = false; ddlHotels.Visible = false; ddlInsurance.Visible = false; ddlBonding.Visible = false; // RestoreNavigator RestoreNavigatorState(); // If coming from // ... actual_costs_navigator.aspx or actual_costs_navigator2.aspx if ((Request.QueryString["source_page"] == "actual_costs_navigator.aspx") || (Request.QueryString["source_page"] == "actual_costs_navigator2.aspx")) { actualCostsNavigatorTDS = (ActualCostsNavigatorTDS)Session["actualCostsNavigatorTDS"]; } // ... actual_costs_edit.aspx, actual_costs_summary.aspx or actual_costs_delete.aspx if ((Request.QueryString["source_page"] == "actual_costs_edit.aspx") || (Request.QueryString["source_page"] == "actual_costs_summary.aspx") || (Request.QueryString["source_page"] == "actual_costs_delete.aspx")) { RestoreNavigatorState(); if (Request.QueryString["update"] == "no") { actualCostsNavigatorTDS = (ActualCostsNavigatorTDS)Session["actualCostsNavigatorTDS"]; } else { // ... Delete store data Session.Contents.Remove("actualCostsNavigatorTDS"); // ... Search data with updates actualCostsNavigatorTDS = SubmitSearch(); // ... store datasets Session["actualCostsNavigatorTDS"] = actualCostsNavigatorTDS; } } Session["actualCostsNavigatorTDS"] = actualCostsNavigatorTDS; Session["subcontractorCosts"] = actualCostsNavigatorTDS.SubcontractorCosts; Session["hotelCosts"] = actualCostsNavigatorTDS.HotelCosts; Session["insuranceCompaniesCosts"] = actualCostsNavigatorTDS.InsuranceCompaniesCosts; Session["bondingCompaniesCosts"] = actualCostsNavigatorTDS.BondingCompaniesCosts; Session["otherCosts"] = actualCostsNavigatorTDS.OtherCosts; // ... For total rows // ... ... for the subcontractors total rows if (actualCostsNavigatorTDS.SubcontractorCosts.Rows.Count > 0) { lblSubcontratorRowsLabel.Text = " Total Subcontractors Rows: " + actualCostsNavigatorTDS.SubcontractorCosts.Rows.Count; } // ... ... for the hotels total rows if (actualCostsNavigatorTDS.HotelCosts.Rows.Count > 0) { lblHotelRowsLabel.Text = " Total Hotel Rows: " + actualCostsNavigatorTDS.HotelCosts.Rows.Count; } // ... ... for the insurance companies total rows if (actualCostsNavigatorTDS.InsuranceCompaniesCosts.Rows.Count > 0) { lblInsuranceRowsLabel.Text = " Total Insurance Companies Rows: " + actualCostsNavigatorTDS.InsuranceCompaniesCosts.Rows.Count; } // ... ... for the bonding companies total rows if (actualCostsNavigatorTDS.BondingCompaniesCosts.Rows.Count > 0) { lblBondingRowsLabel.Text = " Total Bonding Companies Rows: " + actualCostsNavigatorTDS.BondingCompaniesCosts.Rows.Count; } // ... ... for the other total rows if (actualCostsNavigatorTDS.OtherCosts.Rows.Count > 0) { lblOtherRowsLabel.Text = " Total Other Costs Rows: " + actualCostsNavigatorTDS.OtherCosts.Rows.Count; } // Make grids visible if (actualCostsNavigatorTDS.SubcontractorCosts.Rows.Count <= 0) { pnlGrid.Visible = false; } if (actualCostsNavigatorTDS.HotelCosts.Rows.Count <= 0) { pnlHotelGrid.Visible = false; } if (actualCostsNavigatorTDS.InsuranceCompaniesCosts.Rows.Count <= 0) { pnlInsuranceGrid.Visible = false; } if (actualCostsNavigatorTDS.BondingCompaniesCosts.Rows.Count <= 0) { pnlBondingGrid.Visible = false; } if (actualCostsNavigatorTDS.OtherCosts.Rows.Count <= 0) { pnlOtherGrid.Visible = false; } } else { // Restore searched data (if any) actualCostsNavigatorTDS = (ActualCostsNavigatorTDS)Session["actualCostsNavigatorTDS"]; subcontractorCosts = actualCostsNavigatorTDS.SubcontractorCosts; hotelCosts = actualCostsNavigatorTDS.HotelCosts; insuranceCompaniesCosts = actualCostsNavigatorTDS.InsuranceCompaniesCosts; bondingCompaniesCosts = actualCostsNavigatorTDS.BondingCompaniesCosts; otherCosts = actualCostsNavigatorTDS.OtherCosts; // ... For total rows // ... ... for the subcontractors total rows if (actualCostsNavigatorTDS.SubcontractorCosts.Rows.Count > 0) { lblSubcontratorRowsLabel.Text = " Total Subcontractors Rows: " + actualCostsNavigatorTDS.SubcontractorCosts.Rows.Count; } // ... ... for the hotels total rows if (actualCostsNavigatorTDS.HotelCosts.Rows.Count > 0) { lblHotelRowsLabel.Text = " Total Hotel Rows: " + actualCostsNavigatorTDS.HotelCosts.Rows.Count; } // ... ... for the insurance companies total rows if (actualCostsNavigatorTDS.InsuranceCompaniesCosts.Rows.Count > 0) { lblInsuranceRowsLabel.Text = " Total Insurance Companies Rows: " + actualCostsNavigatorTDS.InsuranceCompaniesCosts.Rows.Count; } // ... ... for the bonding companies total rows if (actualCostsNavigatorTDS.BondingCompaniesCosts.Rows.Count > 0) { lblBondingRowsLabel.Text = " Total Bonding Companies Rows: " + actualCostsNavigatorTDS.BondingCompaniesCosts.Rows.Count; } // ... ... for the other total rows if (actualCostsNavigatorTDS.OtherCosts.Rows.Count > 0) { lblOtherRowsLabel.Text = " Total Other Costs Rows: " + actualCostsNavigatorTDS.OtherCosts.Rows.Count; } // Make grids visible if (actualCostsNavigatorTDS.SubcontractorCosts.Rows.Count <= 0) { pnlGrid.Visible = false; } if (actualCostsNavigatorTDS.HotelCosts.Rows.Count <= 0) { pnlHotelGrid.Visible = false; } if (actualCostsNavigatorTDS.InsuranceCompaniesCosts.Rows.Count <= 0) { pnlInsuranceGrid.Visible = false; } if (actualCostsNavigatorTDS.BondingCompaniesCosts.Rows.Count <= 0) { pnlBondingGrid.Visible = false; } if (actualCostsNavigatorTDS.OtherCosts.Rows.Count <= 0) { pnlOtherGrid.Visible = false; } } }
private void LoadForSubcontractors(mReport1 master, ActualCostsNavigatorTDS actualCostsNavigatorTDS) { LiquiForce.LFSLive.BL.LabourHours.ActualCosts.ActualCostsNavigatorSubcontractorCosts actualCostsNavigatorSubcontractorCosts = new LiquiForce.LFSLive.BL.LabourHours.ActualCosts.ActualCostsNavigatorSubcontractorCosts(actualCostsNavigatorTDS); if (actualCostsNavigatorSubcontractorCosts.Table.Rows.Count > 0) { // ... Set properties to master page master.Data = actualCostsNavigatorSubcontractorCosts.Data; master.Table = actualCostsNavigatorSubcontractorCosts.TableName; /*if (master.Format == "pdf") {*/ master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ActualCosts.ActualCostsPrintSearchResultsReport(); LoginGateway loginGateway = new LoginGateway(); int loginId = Convert.ToInt32(Session["loginID"]); int companyId = Convert.ToInt32(Session["companyID"]); loginGateway.LoadByLoginId(loginId, companyId); string user = loginGateway.GetLastName(loginId, companyId) + " " + loginGateway.GetFirstName(loginId, companyId); master.SetParameter("User", user.Trim()); // Report format master.Report.PrintOptions.PaperOrientation = PaperOrientation.Landscape; master.Report.PrintOptions.PaperSize = PaperSize.PaperLegal; // Make sections visible string category = Request.QueryString["category"]; // Load Data if (category == "All") { ((Section)master.Report.ReportDefinition.Sections["sDetailSubcontractorCosts"]).SectionFormat.EnableSuppress = false; ((Section)master.Report.ReportDefinition.Sections["sDetailHotelCosts"]).SectionFormat.EnableSuppress = false; ((Section)master.Report.ReportDefinition.Sections["sDetailsInsuranceCosts"]).SectionFormat.EnableSuppress = false; ((Section)master.Report.ReportDefinition.Sections["sDetailBondingCosts"]).SectionFormat.EnableSuppress = false; ((Section)master.Report.ReportDefinition.Sections["sDetailOtherCosts"]).SectionFormat.EnableSuppress = false; } else { ((Section)master.Report.ReportDefinition.Sections["sDetailSubcontractorCosts"]).SectionFormat.EnableSuppress = false; ((Section)master.Report.ReportDefinition.Sections["sDetailHotelCosts"]).SectionFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["sDetailsInsuranceCosts"]).SectionFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["sDetailBondingCosts"]).SectionFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["sDetailOtherCosts"]).SectionFormat.EnableSuppress = true; } /* else { master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ActualCosts.ActualCostsPrintSearchResultsReportExport(); }*/ } }