protected void rptListGrade_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            try
            {
                lblmsg1.Text        = "";
                lblsuccessmsg1.Text = "";
                if (e.CommandName == "modify")
                {
                    bindControlsGrade(e.CommandArgument.ToString());
                    Page.ClientScript.RegisterStartupScript(GetType(), "popupDesi", "<SCRIPT LANGUAGE='javascript'>javascript:openPopUp('newModal');</script>");
                }
                if (e.CommandName == "remove")
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "popupDesi", "<SCRIPT LANGUAGE='javascript'>javascript:openPopUp('newModal');</script>");
                    string qry = "SELECT TOP 1 1 FROM tblmstgrade where ID=" + e.CommandArgument.ToString() + " and Grade  in (select Grade from tblmstEmployee where orgid=tblmstgrade.orgid)";
                    MyCLS.clsExecuteStoredProcSql clsESPSql = new MyCLS.clsExecuteStoredProcSql();
                    DataTable dt = clsESPSql.ExecQuery(qry);
                    if (dt != null)
                    {
                        if (dt.Rows.Count > 0)
                        {
                            lblmsg1.Text      = "Can not be deleted, Already in use! ";
                            lblmsg1.ForeColor = System.Drawing.Color.Red;
                            return;
                        }
                    }

                    int    res   = clsESPSql.DeleteSYData(" where ID=" + e.CommandArgument.ToString() + " and  Grade not in (select Grade from tblmstEmployee where orgid=tblmstgrade.orgid)", "tblmstgrade");
                    string strpg = Request.Url.ToString();
                    lblmsg1.Text      = "Deleted Successfuly";
                    lblmsg1.ForeColor = System.Drawing.Color.Red;
                    bindGridGradedata();
                    Page.ClientScript.RegisterStartupScript(GetType(), "desiSubmit", "<SCRIPT LANGUAGE='javascript'>javascript:openPopUp('newModal');</script>");
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemple #2
0
        protected void deleteUser(object sender, EventArgs e)
        {
            // Get the value

            LinkButton gvTemp    = (LinkButton)sender;
            LinkButton lnkremove = (LinkButton)gvTemp.FindControl("lnkremove");

            try
            {
                bool isValid = Membership.DeleteUser(lnkremove.CommandArgument, true);
                if (isValid)
                {
                    if (Roles.IsUserInRole(lnkremove.CommandArgument))
                    {
                        Roles.RemoveUserFromRole(lnkremove.CommandArgument, "DataEntry");
                    }

                    lblErrorMessage.Text = "User Deleted successfully";
                    int       res   = clsESPSql.DeleteSYData(" where email=" + lnkremove.CommandArgument.ToString(), "tblmstOrgUsers");
                    string    strpg = Request.Url.ToString();
                    DataTable dt    = clsESPSql.ExecQuery("SP_GetUserByRole 'DataEntry' , " + Session["orgid"].ToString());

                    rptuserlist.DataSource = dt;

                    rptuserlist.DataBind();
                    ViewState["dt"] = dt;
                }
                else
                {
                    lblErrorMessage.Text      = "Failed to delete ";
                    lblErrorMessage.ForeColor = System.Drawing.Color.Green;
                }
            }
            catch (Exception ex)
            {
            }
        }