Exemplo n.º 1
0
    protected void btnClassDelete_Click(object sender, EventArgs e)
    {
        try
        {
            Button btnDeleteClass = (sender as Button);
            int    schoolId       = Convert.ToInt32(hdnSchoolId.Value);

            // delete from datatable

            DataRow lRowSelect = dtClasses.Select("SchoolId=" + schoolId)[0];
            if (lRowSelect != null)
            {
                lRowSelect.Delete();
            }
            grdClasses.DataSource = dtClasses;
            grdClasses.DataBind();

            //Delete from database
            objSchoolAdmin.DeleteSchoolOfClassAdmin(Convert.ToInt32(hdn_ClassAdminId.Value), schoolId);
        }
        catch (Exception ex)
        {
            Helper.Log(ex.Message, "Delete Class ");
        }
    }
Exemplo n.º 2
0
    protected void btnRemoveClasses_Click(object sender, EventArgs e)
    {
        int    SchoolId     = 0;
        int    ClassAdminId = 0;
        string ClassIds     = "";
        int    resCount     = 0;

        if (hdnSchoolId.Value != "")
        {
            SchoolId = Convert.ToInt32(hdnSchoolId.Value);
        }
        if (hdn_ClassAdminId.Value != "")
        {
            ClassAdminId = Convert.ToInt32(hdn_ClassAdminId.Value);
        }

        foreach (ListItem item in chkListClasses.Items)
        {
            if (item.Selected)
            {
                int res = objSchoolAdmin.DeleteClassAdminClasses(ClassAdminId, SchoolId, Convert.ToInt32(item.Value));
                if (res > 0)
                {
                    resCount++;
                }
            }
            else
            {
                ClassIds += "," + item.Text.ToString();
            }
        }

        if (resCount > 0)
        {
            HttpCookie ce = new HttpCookie("ContentSaved");
            if (resCount == 1)
            {
                ce.Value = resCount.ToString() + (string)GetLocalResourceObject("MsgClassRemoved");//" Class has been successfully removed!";
            }
            else
            {
                ce.Value = resCount.ToString() + (string)GetLocalResourceObject("MsgClassesRemoved"); //" Classes has been successfully removed!";
            }
            Response.Cookies.Add(ce);

            Response.Redirect("ClassAdmin.aspx");
        }
        else
        {
            try
            {
                // delete from datatable
                DataRow lRowSelect = dtClasses.Select("SchoolId=" + SchoolId)[0];
                if (lRowSelect != null)
                {
                    lRowSelect.Delete();
                }
                grdClasses.DataSource = dtClasses;
                grdClasses.DataBind();

                //Delete from database
                objSchoolAdmin.DeleteSchoolOfClassAdmin(ClassAdminId, SchoolId);
            }
            catch (Exception ex)
            {
                Helper.Log(ex.Message, "Delete Class ");
            }
        }
    }