Exemple #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string storedProcedureName             = "dbo.pInsLoginRequest";
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("@Name", TextBoxName.Text);
            parameters.Add("@EmailAddress", TextBoxEmailAddress.Text);
            parameters.Add("@LoginName", TextBoxLoginName.Text);
            parameters.Add("@NewOrReactivate", TextBoxNewOrReactivate.Text);
            parameters.Add("@ReasonForAccess", TextBoxReason.Text);
            parameters.Add("@DateNeededBy", TextBoxDateNeededBy.Text);

            var error = StoredProcedureExecutor.Execute(storedProcedureName, parameters);

            if (!String.IsNullOrEmpty(error))
            {
                Response.Write("An error occured while adding the login request to the database.  Exception is: " + error);
            }
        }
        protected void ButtonRegister_Click(object sender, EventArgs e)
        {
            string error = "";

            LabelStatus.Text = "";
            bool registrationAttempted = false;

            foreach (GridViewRow row in GridView1.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    CheckBox chkRow = (row.Cells[0].FindControl("chkCtrl") as CheckBox);

                    if (chkRow.Checked)
                    {
                        registrationAttempted = true;
                        string storedProcedureName = "dbo.pInsClassStudents";

                        Dictionary <string, string> parameters = new Dictionary <string, string>();

                        parameters.Add("@ClassID", row.Cells[1].Text);
                        parameters.Add("@StudentID", Session["StudentID"].ToString());

                        error = StoredProcedureExecutor.Execute(storedProcedureName, parameters);

                        if (!String.IsNullOrEmpty(error))
                        {
                            LabelStatus.Text = error;
                        }
                    }
                }
            }

            if (String.IsNullOrEmpty(error) && registrationAttempted)
            {
                LabelStatus.Text = "  Successfully registered!";
            }

            GridView1.DataBind();
        }