protected void btnDelete_Click(object sender, EventArgs e)
    {
        school_id = Convert.ToInt32(Request.QueryString["schoolID"]);

        qOrg_School school = new qOrg_School(school_id);
        school.Available = "No";
        school.MarkAsDelete = 1;
        school.Update();

        Response.Redirect("schools-list.aspx");
    }
    protected void btnSave_OnClick(object sender, System.EventArgs e)
    {
        Page.Validate("form");

        if (Page.IsValid)
        {
            int user_id = Convert.ToInt32(Context.Items["UserID"]);

            if (!String.IsNullOrEmpty(Request.QueryString["schoolID"]))
            {
                school_id = Convert.ToInt32(Request.QueryString["schoolID"]);

                qOrg_School school = new qOrg_School(school_id);

                school.School = txtName.Text;
                school.SchoolType = ddlType.SelectedValue;
                school.Address1 = txtAddress1.Text;
                school.Address2 = txtAddress2.Text;
                school.City = txtCity.Text;
                school.StateProvince = ddlState.SelectedValue;
                school.PostalCode = txtPostalCode.Text;
                school.Country = ddlCountry.SelectedValue;
                school.SchoolPhone = txtPhone.Text;
                if (!String.IsNullOrEmpty(ddlSchoolDistrict.SelectedValue))
                    school.SchoolDistrictID = Convert.ToInt32(ddlSchoolDistrict.SelectedValue);

                school.Update();
            }
            else
            {
                qOrg_School school = new qOrg_School();

                school.ScopeID = 1;
                school.Created = DateTime.Now;
                school.CreatedBy = user_id;
                school.LastModified = DateTime.Now;
                school.LastModifiedBy = user_id;
                school.Available = "Yes";
                school.MarkAsDelete = 0;
                school.School = txtName.Text;
                school.SchoolType = ddlType.SelectedValue;
                school.Available = rblAvailable.SelectedValue;
                school.Address1 = txtAddress1.Text;
                school.Address2 = txtAddress2.Text;
                school.City = txtCity.Text;
                school.StateProvince = ddlState.SelectedValue;
                school.Country = ddlCountry.SelectedValue;
                school.PostalCode = txtPostalCode.Text;
                school.SchoolPhone = txtPhone.Text;
                if (!String.IsNullOrEmpty(ddlSchoolDistrict.SelectedValue))
                    school.SchoolDistrictID = Convert.ToInt32(ddlSchoolDistrict.SelectedValue);

                school.Insert();

                school_id = school.SchoolID;
            }

            bool geo_coding_success = true;

            /*
            bool geo_coding_success;
            try
            {
                Quartz.Data.qDbs_CustomWorkflows qFlow = new Quartz.Data.qDbs_CustomWorkflows();
                int curr_user_id = Convert.ToInt32(Context.Items["UserID"]);
                string workflowSuccess = qFlow.RunWorkflow(108, 102, school_id, curr_user_id);
                geo_coding_success = true;
            }
            catch
            {
                geo_coding_success = false;
            }
             */

            if (!String.IsNullOrEmpty(Request.QueryString["schoolID"]))
            {
                if (geo_coding_success == true)
                {
                    lblMessage.Text = "*** Record Successfully Updated ***";
                    lblMessageBottom.Text = "*** Record Successfully Updated ***";
                    Response.Redirect(Request.Url.ToString() + "&mode=update-successful");
                }
                else
                {
                    //lblMessage.Text = "*** Record Successfully Updated BUT GeoCoding of the Address Failed ***";
                    //lblMessageBottom.Text = "*** Record Successfully Updated BUT GeoCoding of the Address Failed ***";
                    lblMessage.Text = "*** Record Successfully Updated ***";
                    lblMessageBottom.Text = "*** Record Successfully Updated ***";
                    Response.Redirect(Request.Url.ToString() + "?mode=add-successful&schoolID=" + school_id);
                }
            }
            else
            {
                Response.Redirect(Request.Url.ToString() + "?mode=add-successful&schoolID=" + school_id);
            }
        }
    }