protected void Page_Load(object sender, EventArgs e) { StoredProcedures sp = new StoredProcedures(); if (!IsPostBack) { string userType = (string)Session["UserType"]; if (userType == null) { Response.Redirect("Login.aspx?category=User", true); } else { String fiscalYear = (String)Session["FiscalYear"]; DataTable costDriverstbl = DTable(); Session["CostDriversTbl"] = costDriverstbl; DataTable costDriversAdded = CostDriversRightPanel(); Session["CostDriversAdded"] = costDriversAdded; DataSet ds = sp.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; StoredProcedures sp = new StoredProcedures(); TextBox tbox = new TextBox(); String fiscalYear = (String)Session["FiscalYear"]; DataSet ds1 = sp.DisplaySupportUnitMetricsEdit(fiscalYear, SelectCostDriverDropDownList.SelectedValue); DataSet ds2 = sp.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 = sp.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; }