protected void gvNewPoints_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { int index = gvNewPoints.EditIndex; int iTemp; int UserID = 0; int OppID = 0; double dblTemp = 0; double CP = 0; if (int.TryParse(Session["UserID"].ToString(), out iTemp)) { UserID = iTemp; } HiddenField hidPointID = (HiddenField)gvNewPoints.Rows[e.RowIndex].FindControl("hidPointID"); if (int.TryParse(hidPointID.Value.ToString(), out iTemp)) { OppID = iTemp; } string strComments = ""; if (Session["EditMode"].ToString() == "Edit") { GridViewRow row = gvNewPoints.Rows[index]; TextBox txtComments = row.FindControl("tbStaffComments") as TextBox; strComments = txtComments.Text; TextBox txtCP = row.FindControl("txtNewCPValue") as TextBox; if (double.TryParse(txtCP.Text.ToString(), out dblTemp)) { CP = dblTemp; } Session["EditMode"] = "Assign"; } else { Label lblCPValue = (Label)gvPoints.Rows[e.RowIndex].FindControl("lblCPValue"); Label lblStaffComents = (Label)gvPoints.Rows[e.RowIndex].FindControl("lblStaffComments"); if (double.TryParse(lblCPValue.Text, out dblTemp)) { CP = dblTemp; } strComments = lblStaffComents.Text; } Classes.cPoints Point = new Classes.cPoints(); Point.UpdateTentativeOpportunity(UserID, OppID, CP, strComments, 80); // 80 - Tentative --> 68 - Ready to send --> 69 Sent to campaign // Audit status 78 - Emailed } catch (Exception ex) { string l = ex.Message; } gvNewPoints.EditIndex = -1; FillGridNewPoints(); }
protected void btnAddNewReg_Click(object sender, EventArgs e) { // Add new player "Add" button to change from tentative to ready to send btnPreview.Visible = true; ddlRegistrant.Enabled = true; ddlEvent.Enabled = true; ddlDescription.Enabled = true; ddlRegistrant.SelectedIndex = 0; btnAddNewRegCancel.Visible = false; btnAddNewReg.Visible = false; gvNewPoints.Visible = false; btnEditNewPoints.Visible = true; // Update the opportunities as ready to send int UserID = 0; if (Session["UserID"] != null) { int.TryParse(Session["UserID"].ToString(), out UserID); } Classes.cPoints Point = new Classes.cPoints(); foreach (GridViewRow gvrow in gvNewPoints.Rows) { try { int index = gvNewPoints.EditIndex; int iTemp; double dblTemp = 0; double CP = 0; HiddenField hidCPOpp = (HiddenField)gvNewPoints.Rows[gvrow.RowIndex].FindControl("hidPointID"); int intCPOpp = 0; if (int.TryParse(hidCPOpp.Value.ToString(), out iTemp)) { intCPOpp = iTemp; } string strComments = ""; GridViewRow row = gvNewPoints.Rows[gvrow.RowIndex]; Label lblCPValue = (Label)gvNewPoints.Rows[gvrow.RowIndex].FindControl("lblNewCPValue"); Label lblStaffComments = (Label)gvNewPoints.Rows[gvrow.RowIndex].FindControl("lblStaffComments"); strComments = lblStaffComments.Text; if (double.TryParse(lblCPValue.Text.ToString(), out dblTemp)) { CP = dblTemp; } else { string jsString = "alert('Point value must be a number.');"; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "MyApplication", jsString, true); return; } Point.UpdateTentativeOpportunity(UserID, intCPOpp, CP, strComments, 68); } catch (Exception ex) { string l = ex.Message; } } gvPoints.EditIndex = -1; FillGrid(hidUserName.Value, hidCampaignID.Value); }