protected void btnSave_Click(object sender, ImageClickEventArgs e) { int intRecordsAffected = 0; int eventID = Request.QueryString["eventid"].ToInt(); string eventName = txtEventName.Text; int eventDivisionID = ddlDivision.SelectedValue.ToInt(); int eventCategoryID = ddlCategory.SelectedValue.ToInt(); int maxPoint = txtMaxPoints.Text.ToInt(); int winnerTeamID = ddlWinner.SelectedValue.ToInt(); int sortOrder = txtOrder.Text.ToInt(); string modifiedBy = Request.Cookies["Speedo"]["UserName"].ToString(); intRecordsAffected = DALPortal.UpdateEvent(eventID, eventName, eventDivisionID, eventCategoryID, maxPoint, winnerTeamID, sortOrder, true, modifiedBy); }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { int intRecordsAffected = 0; int eventID = Request.QueryString["eventid"].ToInt(); string eventName = txtEventName.Text; int eventDivisionID = ddlDivision.SelectedValue.ToInt(); int eventCategoryID = ddlCategory.SelectedValue.ToInt(); int maxPoint = txtMaxPoints.Text.ToInt(); int winnerTeamID = ddlWinner.SelectedValue.ToInt(); int sortOrder = txtOrder.Text.ToInt(); string modifiedBy = Request.Cookies["Speedo"]["UserName"].ToString(); intRecordsAffected = DALPortal.UpdateEvent(eventID, eventName, eventDivisionID, eventCategoryID, maxPoint, winnerTeamID, sortOrder, true, modifiedBy); using (SqlConnection cn = new SqlConnection(clsSpeedo.SpeedoConnectionString)) { SqlCommand cmd = cn.CreateCommand(); cn.Open(); if (chkActive.Checked == true) { //added by charlie bachiller May 18, 2012 if (chkActive.Checked == true) { cmd.CommandText = "UPDATE Portal.EventsActive SET IsActive='0'"; cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); cmd.CommandText = "UPDATE Portal.EventsActive SET IsActive='1' WHERE EventID=@EventID"; cmd.Parameters.Add(new SqlParameter("@EventID", eventID)); cmd.Parameters.Add(new SqlParameter("@IsActive", chkActive.Checked == true ? "1" : "0")); cmd.ExecuteNonQuery(); } else { cmd.CommandText = "SELECT EventID FROM Portal.EventsActive WHERE EventID=@EventID AND IsActive='1'"; cmd.Parameters.Add(new SqlParameter("@EventID", eventID)); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { cmd.CommandText = "UPDATE Portal.EventsActive SET IsActive='0'"; cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); } cmd.Parameters.Clear(); } } else { cmd.CommandText = "SELECT EventID FROM Portal.EventsActive WHERE EventID=@EventID AND IsActive='1'"; cmd.Parameters.Add(new SqlParameter("@EventID", eventID)); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { dr.Close(); cmd.CommandText = "UPDATE Portal.EventsActive SET IsActive='0'"; cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); } cmd.Parameters.Clear(); } } Response.Redirect("EventMenu.aspx"); }