Пример #1
0
        private void BindData()
        {
            SqlConnection con = new SqlConnection(strConnString);
            SqlCommand    cmd = new SqlCommand("sp_get_cart_details_by_user_id", con);

            string userID = HttpContext.Current.User.Identity.Name;

            cmd.Parameters.Add("@user_id", SqlDbType.VarChar).Value = userID;

            cmd.CommandType = CommandType.StoredProcedure;

            cart = GetData(cmd);
            GridViewUsers.DataSource = cart;
            GridViewUsers.DataBind();
            calculateTotal();
        }
Пример #2
0
        public void GetAllUsers()
        {
            string getAllUsersList = "Select * FROM Employee ORDER BY EMP_ID DESC ";

            dt = new DataTable();
            dt = dbClass.ConnectDataBaseReturnDT(getAllUsersList);
            if (dt.Rows.Count > 0)
            {
                GridViewUsers.DataSource = dt;
                GridViewUsers.DataBind();
            }
            else
            {
                GridViewUsers.DataSource = null;
                GridViewUsers.DataBind();
            }
        }
Пример #3
0
    protected void ButtonAddUser_Click(object sender, EventArgs e)
    {
        try
        {
            strSQLAddNewuser  = "******";
            strSQLAddNewuser += "(salutationID, firstName, lastName, logonName, passwd)";
            strSQLAddNewuser += " VALUES ";
            strSQLAddNewuser += " (1, 'Angel', 'Alferez', 'aalferez', '12345')";

            connection.Open();
            transaction         = connection.BeginTransaction();
            command.Transaction = transaction;

            //Add user to table
            command = new SqlCommand(strSQLAddNewuser, connection, transaction);
            command.ExecuteNonQuery();

            //select user from table
            strSQLSelectUser = "******";
            command          = new SqlCommand(strSQLSelectUser, connection, transaction);
            sqlDataAdapter   = new SqlDataAdapter(command);
            sqlDataAdapter.Fill(dataSet);
            int PeopleID = (int)dataSet.Tables[0].Rows[0]["PeopleID"];

            //Insert role in table
            strSQLAddRole  = "INSERT INTO roles ";
            strSQLAddRole += "( PeopleID, roleTypeID, RoleActive )";
            strSQLAddRole += "VALUES";
            strSQLAddRole += "( " + PeopleID + ", 1, 1)";

            command = new SqlCommand(strSQLAddRole, connection, transaction);
            command.ExecuteNonQuery();

            command        = new SqlCommand("SELECT * FROM People", connection, transaction);
            sqlDataAdapter = new SqlDataAdapter(command);
            dataSet        = new DataSet();
            sqlDataAdapter.Fill(dataSet);

            GridViewUsers.DataSource = dataSet;
            GridViewUsers.DataBind();
            transaction.Commit();
        }
        catch { }
    }
Пример #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (Session["typeid"].ToString() != "1")
         {
             Response.Redirect("~/Login/Login.aspx");
         }
     }
     catch (Exception)
     {
         Response.Redirect("~/Login/Login.aspx");
     }
     if (!IsPostBack)
     {
         var data = imsdb.UserAccounts.OrderByDescending(u => u.Id).ToList();
         GridViewUsers.DataSource = data;
         GridViewUsers.DataBind();
     }
 }
Пример #5
0
    //Al apretar el botó de borrar, elimina aquesta de la BD.
    protected void GridViewUsers_OnRowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        GridViewRow row = (GridViewRow)GridViewUsers.Rows[e.RowIndex];

        string username = row.Cells[0].Text;

        string resultat = ORM.borrarUsuari(username);

        if (resultat != null)
        {
            ScriptManager.RegisterStartupScript(this, typeof(Page), "script", "alert('Error! user has not been deleted.');", true);
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, typeof(Page), "script", "alert('User has been deleted.');", true);
        }

        GridViewUsers.DataBind();
        CarregarGridUsuaris();
    }
Пример #6
0
        protected void GridViewUsers_Sorting(object sender, GridViewSortEventArgs e)
        {
            if (e.SortExpression == (string)ViewState["SortColumn"])
            {
                // We are resorting the same column, so flip the sort direction
                e.SortDirection =
                    ((SortDirection)ViewState["SortColumnDirection"] == SortDirection.Ascending) ?
                    SortDirection.Descending : SortDirection.Ascending;
            }
            // Apply the sort
            DataTable dataTable = GridViewUsers.DataSource as DataTable;

            dataTable.DefaultView.Sort = e.SortExpression +
                                         (string)((e.SortDirection == SortDirection.Ascending) ? " ASC" : " DESC");
            ViewState["SortColumn"]          = e.SortExpression;
            ViewState["SortColumnDirection"] = e.SortDirection;

            GridViewUsers.DataSource = dataTable;
            GridViewUsers.DataBind();
        }
Пример #7
0
    protected void ButtonAddUser_Click(object sender, EventArgs e)
    {
        var user = context.people.CreateObject();

        user.salutationID    = 1;
        user.firstName       = "Angel";
        user.lastName        = "Alferez";
        user.logonName       = "aalferez";
        user.passwd          = "12345";
        user.recCreationDate = System.DateTime.Now;

        context.people.AddObject(user);
        context.SaveChanges();
        var userID = (from r in context.people
                      where r.firstName == "Angel"
                      where r.lastName == "Alferez"
                      where r.logonName == "aalferez"
                      orderby r.peopleID descending
                      select r.peopleID).FirstOrDefault();

        var newrole = context.roles.CreateObject();

        newrole.PeopleID        = userID;
        newrole.RoleTypeID      = 1;
        newrole.roleActive      = true;
        newrole.recCreationDate = DateTime.Now;
        context.roles.AddObject(newrole);
        context.SaveChanges();

        var allpeople = from r in context.people
                        orderby r.peopleID ascending
                        select r;

        GridViewUsers.DataSource = allpeople;
        GridViewUsers.DataBind();
    }
        protected async void FillGrids()
        {
            HttpClient          client = CreateRestClient();
            HttpResponseMessage res    = await client.GetAsync("api/Users/");

            res.EnsureSuccessStatusCode();
            if (res.IsSuccessStatusCode)
            {
                users = await res.Content.ReadAsAsync <List <Users> >();

                GridViewUsers.DataSource = users;
                GridViewUsers.DataBind();
                GridViewUsers.HeaderRow.Cells[0].Text  = "ID";
                GridViewUsers.HeaderRow.Cells[0].Width = 25;
                GridViewUsers.HeaderRow.Cells[1].Text  = "First Name";
                GridViewUsers.HeaderRow.Cells[1].Width = 100;
                GridViewUsers.HeaderRow.Cells[2].Text  = "Last Name";
                GridViewUsers.HeaderRow.Cells[2].Width = 100;
                GridViewUsers.HeaderRow.Cells[3].Text  = "Email";
                GridViewUsers.HeaderRow.Cells[3].Width = 200;
                GridViewUsers.HeaderRow.Cells[4].Text  = "Password";
                GridViewUsers.HeaderRow.Cells[4].Width = 100;
            }

            videos = service1Client.GetVideos().ToList();

            GridViewVideos.DataSource = videos;
            GridViewVideos.DataBind();

            GridViewVideos.HeaderRow.Cells[0].Text = "Date";
            GridViewVideos.HeaderRow.Cells[1].Text = "Description";
            GridViewVideos.HeaderRow.Cells[2].Text = "Video ID";
            GridViewVideos.HeaderRow.Cells[3].Text = "Title";
            GridViewVideos.HeaderRow.Cells[4].Text = "URL";


            comments = service1Client.GetComments().ToList();

            GridViewComments.DataSource = comments;
            GridViewComments.DataBind();

            GridViewComments.HeaderRow.Cells[0].Text = "Comment";
            GridViewComments.HeaderRow.Cells[1].Text = "Date";
            GridViewComments.HeaderRow.Cells[2].Text = "Comment ID";
            GridViewComments.HeaderRow.Cells[3].Text = "Video ID";


            ratings = service1Client.GetRatings().ToList();

            GridViewRatings.DataSource = ratings;
            GridViewRatings.DataBind();

            GridViewRatings.HeaderRow.Cells[0].Text = "Rating ID";
            GridViewRatings.HeaderRow.Cells[1].Text = "Score";
            GridViewRatings.HeaderRow.Cells[2].Text = "Video ID";


            UsersText.InnerText    = "Admin Accounts: " + users.Count();
            VideosText.InnerText   = "Videos: " + videos.Count();
            CommentsText.InnerText = "Comments: " + comments.Count();
            RatingsText.InnerText  = "Ratings: " + ratings.Count();
        }
Пример #9
0
 private void BindGridView()
 {
     GridViewUsers.DataSource = Users;
     GridViewUsers.DataBind();
 }
Пример #10
0
 protected void GridViewUsers_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     BtnUserSearch_Click(sender, new EventArgs());
     GridViewUsers.PageIndex = e.NewPageIndex;
     GridViewUsers.DataBind();
 }
Пример #11
0
 protected void OnPaging(object sender, GridViewPageEventArgs e)
 {
     BindData();
     GridViewUsers.PageIndex = e.NewPageIndex;
     GridViewUsers.DataBind();
 }
Пример #12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     GridViewUsers.DataSource = Membership.GetAllUsers();
     GridViewUsers.DataBind();
 }
Пример #13
0
 protected void GridViewUsers_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     GridViewUsers.PageIndex = e.NewPageIndex;
     GridViewUsers.DataBind();
 }