protected void DeleteButtonModal_Click(object sender, EventArgs e)
    {
        sc.Open();
        string     deactivateOrg = "Update Organization set Status = 'Inactive', LastUpdatedBy = @LastUpdatedBy, LastUpdated = @LastUpdated where OrganizationID = @OrganizationID";
        SqlCommand deactivatecmd = new SqlCommand(deactivateOrg, sc);

        deactivatecmd.Parameters.AddWithValue("@LastUpdatedBy", Session["User"]);
        deactivatecmd.Parameters.AddWithValue("@LastUpdated", DateTime.Now);
        deactivatecmd.Parameters.AddWithValue("@OrganizationID", OrgGridView.SelectedRow.Cells[9].Text);
        deactivatecmd.ExecuteNonQuery();
        OrgGridView.DataBind();
        sc.Close();
    }
    protected void insertButton_Click(object sender, EventArgs e)
    {
        sc.Open();
        int    fk;
        string getOrgFK   = "Select OrganizationID from [dbo].[Organization] where OrganizationName = @OrganizationName";
        string addOrg     = "insert into [dbo].[Organization] values (@OrgAddress, @OrgCity, @OrgCounty, @OrgCountry, @PrimaryContactPerson, @OrgPhone, @OrgEmail, @LastUpdatedBy, @LastUpdated, @OrganizationName, @Status)";
        string addContact = "insert into [dbo].[ContactPerson] values(@ContactName, @ContactPhone, @ContactEmail, @OrganizationID)";

        SqlCommand addOrgcmd = new SqlCommand(addOrg, sc);

        addOrgcmd.Parameters.AddWithValue("@OrgAddress", HttpUtility.HtmlEncode(addOrgAddress.Text));
        addOrgcmd.Parameters.AddWithValue("@OrgCity", addCity.SelectedItem.Text);
        addOrgcmd.Parameters.AddWithValue("@OrgCounty", addCounty.SelectedItem.Text);
        addOrgcmd.Parameters.AddWithValue("@OrgCountry", "US");
        addOrgcmd.Parameters.AddWithValue("@PrimaryContactPerson", HttpUtility.HtmlEncode(addPerson.Text));
        addOrgcmd.Parameters.AddWithValue("@OrgPhone", HttpUtility.HtmlEncode(addPhone.Text));
        addOrgcmd.Parameters.AddWithValue("@OrgEmail", HttpUtility.HtmlEncode(addEmail.Text));
        addOrgcmd.Parameters.AddWithValue("@LastUpdatedBy", Session["User"]);
        addOrgcmd.Parameters.AddWithValue("@LastUpdated", DateTime.Today);
        addOrgcmd.Parameters.AddWithValue("@OrganizationName", HttpUtility.HtmlEncode(addOrgName.Text));
        addOrgcmd.Parameters.AddWithValue("@Status", HttpUtility.HtmlEncode("Active"));
        addOrgcmd.ExecuteNonQuery();

        SqlCommand fkcmd = new SqlCommand(getOrgFK, sc);

        fkcmd.Parameters.AddWithValue("@OrganizationName", HttpUtility.HtmlEncode(addOrgName.Text));
        SqlDataReader reader = fkcmd.ExecuteReader();

        reader.Read();
        fk = reader.GetInt32(0);
        reader.Close();

        SqlCommand addContact1cmd = new SqlCommand(addContact, sc);

        addContact1cmd.Parameters.AddWithValue("@ContactName", HttpUtility.HtmlEncode(addPerson.Text));
        addContact1cmd.Parameters.AddWithValue("@ContactPhone", HttpUtility.HtmlEncode(addPhone.Text));
        addContact1cmd.Parameters.AddWithValue("@ContactEmail", HttpUtility.HtmlEncode(addEmail.Text));
        addContact1cmd.Parameters.AddWithValue("@OrganizationID", HttpUtility.HtmlEncode(fk));
        addContact1cmd.ExecuteNonQuery();

        SqlCommand addContact2cmd = new SqlCommand(addContact, sc);

        addContact2cmd.Parameters.AddWithValue("@ContactName", HttpUtility.HtmlEncode(secondContactTXT.Text));
        addContact2cmd.Parameters.AddWithValue("@ContactPhone", HttpUtility.HtmlEncode(secondPhoneTXT.Text));
        addContact2cmd.Parameters.AddWithValue("@ContactEmail", HttpUtility.HtmlEncode(secondEmailTXT.Text));
        addContact2cmd.Parameters.AddWithValue("@OrganizationID", HttpUtility.HtmlEncode(fk));
        addContact2cmd.ExecuteNonQuery();

        OrgGridView.DataBind();
        sc.Close();
    }
    protected void UpdateButton_Click(object sender, EventArgs e)
    {
        sc.Open();
        string     updateOrg    = "Update [dbo].[Organization] set OrgAddress = @OrgAddress, OrgCity = @OrgCity, OrgCounty = @OrgCounty, PrimaryContactPerson =@ContactPerson, OrgPhone=@OrgPhone, OrgEmail=@OrgEmail, LastUpdatedBy = @LastUpdatedBy, LastUpdated = @LastUpdated, OrganizationName = @OrganizationName, Status = @Status where OrganizationID=@OrganizationID";
        SqlCommand updateOrgcmd = new SqlCommand(updateOrg, sc);

        updateOrgcmd.Parameters.AddWithValue("@OrgAddress", HttpUtility.HtmlEncode(EditOrgAddress.Text));
        updateOrgcmd.Parameters.AddWithValue("@OrgCity", EditProgramCity.SelectedItem.Text);
        updateOrgcmd.Parameters.AddWithValue("@OrgCounty", EditCounty.SelectedItem.Text);
        updateOrgcmd.Parameters.AddWithValue("@ContactPerson", HttpUtility.HtmlEncode(EditPerson.Text));
        updateOrgcmd.Parameters.AddWithValue("@OrgPhone", HttpUtility.HtmlEncode(EditPhone.Text));
        updateOrgcmd.Parameters.AddWithValue("@OrgEmail", HttpUtility.HtmlEncode(EditEmail.Text));
        updateOrgcmd.Parameters.AddWithValue("@LastUpdatedBy", Session["User"]);
        updateOrgcmd.Parameters.AddWithValue("@LastUpdated", DateTime.Now);
        updateOrgcmd.Parameters.AddWithValue("@OrganizationName", HttpUtility.HtmlEncode(EditOrgName.Text));
        updateOrgcmd.Parameters.AddWithValue("@OrganizationID", OrgGridView.SelectedRow.Cells[9].Text);
        updateOrgcmd.Parameters.AddWithValue("@Status", ddlStatus.SelectedItem.Value);
        updateOrgcmd.ExecuteNonQuery();
        OrgGridView.DataBind();
        sc.Close();
    }
 private void BindData()
 {
     OrgGridView.DataBind();
 }