protected void DeleteAdmin(object sender, GridViewDeleteEventArgs e)
        {
            int       x     = e.RowIndex;
            DataTable data  = Admins.Select();
            int       check = Admins.Delete(int.Parse(data.Rows[x]["User_Id"].ToString()));

            if (check == 1)
            {
                GridView3.DataSource = Admins.Select();
                GridView3.DataBind();
            }

            Response.Redirect("ShowUserNew.aspx");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataTable data = Users.SelectByAccipt(true);
                GridView1.DataSource = data;
                GridView1.DataBind();

                GridView2.DataSource = Users.SelectByAccipt(false);
                GridView2.DataBind();

                GridView3.DataSource = Admins.Select();
                GridView3.DataBind();

                GvwMakeAdmin.DataSource = Users.SelectByAccipt(true);
                GvwMakeAdmin.DataBind();

                HttpCookie cookie = Request.Cookies["MyCookie"];
                if (cookie != null)
                {
                    int       x = int.Parse(cookie["userId"].ToString());
                    DataTable d = LoginAdmin.SelectById(x);
                    if (d.Rows.Count > 0)
                    {
                        ShowAdmin.Visible = true;
                    }


                    else
                    {
                        ShowAdmin.Visible = false;
                    }
                }

                else
                {
                    Response.Redirect("LogIn.aspx");
                }
            }
        }
        protected void BlockUser(object sender, GridViewDeleteEventArgs e)
        {
            int       x     = e.RowIndex;
            DataTable table = Users.SelectByAccipt(true);

            if (table.Rows.Count != 0)
            {
                string s = table.Rows[x]["User_Id"].ToString();
                Users.UpdateState(false, int.Parse(s));
                Admins.Delete(int.Parse(table.Rows[x]["User_Id"].ToString()));
            }
            GridView1.DataSource = Users.SelectByAccipt(true);
            GridView1.DataBind();

            GridView2.DataSource = Users.SelectByAccipt(false);
            GridView2.DataBind();

            GridView3.DataSource = Admins.Select();
            GridView3.DataBind();

            Response.Redirect("ShowUserNew.aspx");
        }
示例#4
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            HttpCookie cookie = new HttpCookie("MyCookie");

            DataTable dataTable  = Users.SelectByEmail(txtLoginEmail.Text, txtLoginPassword.Text);
            DataTable dataTable1 = Admins.SelectAllAdmin();

            if (dataTable.Rows.Count > 0)
            {
                for (int i = 0; i < dataTable1.Rows.Count; i++)
                {
                    if (dataTable.Rows[0]["User_Id"].ToString() == dataTable1.Rows[i]["User_Id"].ToString())
                    {
                        cookie["userId"] = dataTable.Rows[0]["User_Id"].ToString();
                        cookie.Expires.AddDays(30);
                        Response.Cookies.Add(cookie);
                        Response.Redirect($"AdminHome.aspx?userId={dataTable.Rows[0]["User_Id"].ToString()}");//QueryString
                    }
                }

                if (dataTable.Rows[0]["State"].ToString() == "True")
                {
                    cookie["userId"] = dataTable.Rows[0]["User_Id"].ToString();
                    cookie.Expires.AddDays(30);
                    Response.Cookies.Add(cookie);
                    Response.Redirect($"Home.aspx?userId={dataTable.Rows[0]["User_Id"].ToString()}");//QueryString
                }
                else
                {
                    Label1.Text = "Wait List";
                }
            }

            else
            {
                Label1.Text = "Invalid Email Or Password";
            }
        }
        protected void FunMakeAdmin(object sender, GridViewDeleteEventArgs e)
        {
            int       x          = e.RowIndex;
            bool      check      = false;
            DataTable table      = Users.SelectByAccipt(true);
            DataTable tableAdmin = Admins.SelectAllAdmin();

            for (int i = 0; i < tableAdmin.Rows.Count; i++)
            {
                if (table.Rows[x]["User_Id"].ToString() == tableAdmin.Rows[i]["User_Id"].ToString())
                {
                    check = true;
                }
            }

            if (check == false)
            {
                Admins.Insert(int.Parse(table.Rows[x]["User_Id"].ToString()));
                GvwMakeAdmin.DataSource = Users.SelectByAccipt(true);
                GvwMakeAdmin.DataBind();
                GridView3.DataSource = Admins.Select();
                GridView3.DataBind();
            }
        }