protected void Page_Load(object sender, EventArgs e) { RetrieveFromDB rtrvDB = new RetrieveFromDB(); if (!IsPostBack) { String fiscalYear = (String)Session["FiscalYear"]; DataTable costDriverstbl = DTable(); Session["CostDriversTbl"] = costDriverstbl; DataTable costDriversAdded = CostDriversRightPanel(); Session["CostDriversAdded"] = costDriversAdded; DataSet ds = rtrvDB.GetCostDriversTypes(); SelectCostDriverDropDownList.DataSource = ds.Tables[0]; SelectCostDriverDropDownList.DataTextField = "costDriver"; SelectCostDriverDropDownList.DataValueField = "costDriver"; SelectCostDriverDropDownList.DataBind(); SelectCostDriverLabel.Text = "Select Cost Driver " + fiscalYear; AddedCostDrivers(); } }
protected void SelectButton_Click(object sender, EventArgs e) { Alert.Visible = false; Error.Visible = false; CostToAllocateTextBox.Text = ""; SubmitCostDriverPanel.Visible = true; SubmitCostDriverLabel.Text = SelectCostDriverDropDownList.SelectedValue; RetrieveFromDB rtrvDB = new RetrieveFromDB(); TextBox tbox = new TextBox(); String fiscalYear = (String)Session["FiscalYear"]; DataSet ds1 = rtrvDB.DisplaySupportUnitMetricsEdit(fiscalYear, SelectCostDriverDropDownList.SelectedValue); DataSet ds2 = rtrvDB.GetCostToAllocate(fiscalYear, SelectCostDriverDropDownList.SelectedValue); if (ds2.Tables[0].Rows.Count > 0) { SubmitCostDriverGridView.DataSource = ds1; SubmitCostDriverGridView.DataBind(); CostToAllocateTextBox.Text = ds2.Tables[0].Rows[0][0].ToString(); for (int row = 0; row < SubmitCostDriverGridView.Rows.Count; row++) { tbox = (TextBox)SubmitCostDriverGridView.Rows[row].FindControl("PercentageTextBox"); if (ds1.Tables[0].Rows[row][3].ToString() != "") { tbox.Text = (double.Parse(ds1.Tables[0].Rows[row][3].ToString())*100).ToString(); } tbox = (TextBox)SubmitCostDriverGridView.Rows[row].FindControl("TotalMetricTextBox"); tbox.Text = ds1.Tables[0].Rows[row][4].ToString(); tbox = (TextBox)SubmitCostDriverGridView.Rows[row].FindControl("MetricsTextBox"); tbox.Text = ds1.Tables[0].Rows[row][5].ToString(); } } else { DataSet ds = rtrvDB.GetCostDriversTypes(SelectCostDriverDropDownList.SelectedValue); SubmitCostDriverGridView.DataSource = ds; SubmitCostDriverGridView.DataBind(); } DataTable costDriversTbl = (DataTable)Session["CostDriversTbl"]; int index = 0; for (int i = 0; i < costDriversTbl.Rows.Count; i++) { if (costDriversTbl.Rows[i][0].ToString() == SelectCostDriverDropDownList.SelectedValue) { tbox = (TextBox)SubmitCostDriverGridView.Rows[index].FindControl("PercentageTextBox"); if (costDriversTbl.Rows[i][2].ToString() != "") { tbox.Text = (Double.Parse (costDriversTbl.Rows[i][2].ToString())*100).ToString(); } tbox = (TextBox)SubmitCostDriverGridView.Rows[index].FindControl("TotalMetricTextBox"); tbox.Text = costDriversTbl.Rows[i][3].ToString(); tbox = (TextBox)SubmitCostDriverGridView.Rows[index].FindControl("MetricsTextBox"); tbox.Text = costDriversTbl.Rows[i][4].ToString(); CostToAllocateTextBox.Text = costDriversTbl.Rows[i][5].ToString(); index = index + 1; } } index = 0; }