protected void Page_Load(object sender, EventArgs e) { utility = new UtilityCAS(); bearCode = new BearCode(); ImageButtonRecalc.Attributes.Add("onclick", "javascript:return confirm('Recalc Status on All Records (this may take a while)?')"); if (Page.IsPostBack) { int totalRows = 0; try { totalRows = GridViewSearchResults.Rows.Count; } catch (SqlException sqle) { Logger.QuickLog(VariablesCAS.ERROR_LOG_FILE_NAME, sqle.Message, "Page_Load()", "int totalRows = dataGridView.Rows.Count"); } utility.SetRowChanged(totalRows); //rowChanged = new bool[totalRows]; if (GridViewSearchResults.SelectedRow != null) { if (GridViewSearchResults.SelectedRow.RowIndex != -1) { Session["rowSelected"] = GridViewSearchResults.SelectedRow.RowIndex.ToString(); } } } else { Session["defaultColumnWidth1"] = Hidden0.Value.ToString(); Session["defaultColumnWidth2"] = Hidden1.Value.ToString(); Session["defaultColumnWidth3"] = Hidden2.Value.ToString(); Session["defaultColumnWidth4"] = Hidden3.Value.ToString(); Session["defaultColumnWidth5"] = Hidden4.Value.ToString(); Session["defaultColumnWidth6"] = Hidden5.Value.ToString(); Session["defaultColumnWidth7"] = Hidden6.Value.ToString(); Session["defaultColumnWidth8"] = Hidden7.Value.ToString(); Session["defaultColumnWidth9"] = Hidden8.Value.ToString(); Session["defaultColumnWidth10"] = Hidden9.Value.ToString(); Session["rowSelected"] = "-1"; Session["BulkUpdate"] = "Off"; TextBoxBulkGLString.Enabled = false; TextBoxBulkGLString.Attributes.CssStyle.Add("background-color", "#AAB0B7"); PopulateVendors(DropDownListVendors); PopulateOfficeLocations(); } }
/// <summary> /// Sends 0 as the value for invalidTKOnly to the Stored Procedure /// SQL: <br /> /// cas_BEAR_get_APCostRecItem /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ImageButtonRecalc_Click(object sender, EventArgs e) { SqlConnection con = null; try { con = new SqlConnection(ConfigurationManager.ConnectionStrings["CASConnectionString"].ConnectionString); con.Open(); SqlCommand command = new SqlCommand("cas_BEAR_get_APCostRecItem", con); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@vendor", DropDownListVendors.SelectedValue); command.Parameters.AddWithValue("@processid", DropDownListProcessIDs.SelectedValue); command.Parameters.AddWithValue("@invalidTKOnly", "0"); command.Parameters.AddWithValue("@tkid", TextBoxTimekeeperID.Text.ToString()); command.Parameters.AddWithValue("@costOrGL", "B"); SqlDataReader reader = command.ExecuteReader(); int tempId = 0; String timekeeper = ""; String matter = ""; String costCode = ""; String glString = ""; int status = 0; UtilityCAS util = new UtilityCAS(); bool isCost = false; bool isGL = false; int i = 0; while (reader.Read()) { tempId = Convert.ToInt32(reader["TempId"].ToString()); timekeeper = reader["timekeep"].ToString(); matter = reader["matter"].ToString(); costCode = reader["CostCode"].ToString(); glString = reader["GLString"].ToString(); if (!glString.Equals("")) { isGL = true; } else if ((!matter.Equals("") || !costCode.Equals(""))) { isCost = true; } if (isCost) { //hardcode 0 in method to indicate that the current status code = 0. //This is done to reset the code and then to recalculate. status = util.GetStatusForSaveCost(0, timekeeper, matter, costCode); } if (isGL) { //hardcode 0 in method to indicate that the current status code = 0. //This is done to reset the code and then to recalculate. status = util.GetStatusForSaveGL(0, glString); } //update the status for the current record util.UpdateStatusCode(tempId, status); i++; } if (i > 0) { BindGrid(GridViewSearchResults.AllowPaging); i = 0; } } catch (SqlException sqle) { Logger.QuickLog(VariablesCAS.ERROR_LOG_FILE_NAME, sqle.Message, "ImageButtonRecalc_Click()", ""); } finally { con.Close(); } }