Пример #1
0
        protected void grdPoints_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Edit")
            {
                int index = Convert.ToInt32(e.CommandArgument);
                string value = this.grdPoints.DataKeys[index].Values["id"].ToString();

                Response.Redirect("edit.aspx?id=" + value.ToString());
            }

            if (e.CommandName == "DeletePoints")
            {

                int index = Convert.ToInt32(e.CommandArgument);
                string value = this.grdPoints.DataKeys[index].Values["id"].ToString();

                player_points _points = new player_points();
                _points = _dal.GetPointsById(new Guid(value));
                _points.isDeleted = true;
                _points.deletedDate = DateTime.Now;

                _dal.SoccerEntities.SaveChanges();

            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            player _player = new player();
            player_points _playerpoints = new player_points();
            IQueryable<prize> _prizes;
            string id = Request.QueryString["playerId"];

            Guid _guid = string.IsNullOrEmpty(id) ? new Guid() : new Guid(id);

            _player = _dal.GetPlayerBYID(new Guid(_dal.UserID.ToString()));

            playerName.InnerText = _player.Name.Substring(0, 9);
            lblshirtNumber.Text = _player.shirtNumber.ToString();

            int playerPointsToadd = _dal.GetTotalPointsToAdd();

            lblpoints.Text = playerPointsToadd.ToString();

            _playerpoints = _dal.GetPlayerPointsBYID(new Guid(_dal.UserID.ToString()));

            _prizes = _dal.getAllprizesByPoints(Convert.ToInt32(_playerpoints.points));

            rptPrize.DataSource = _prizes.ToList();
            rptPrize.DataBind();

            points.InnerText = _playerpoints.points.ToString();
        }
        public player_points GetPointsTORedeemByPlayerId(Guid _playerId)
        {
            try
            {
                if (_playerId == Guid.Empty)
                {
                    player_points _playerpoints = new player_points();
                    return _playerpoints;
                }
                else
                {
                    var q = SoccerEntities.player_points.Where(p => p.playerId == _playerId && p.isProcessed==true);

                    if (q == null)
                        throw new EntityContextException(string.Format("No Points could be found for player to be processed {0}!", _playerId));
                    else
                        return q.ToList()[0];
                }
            }
            catch (Exception ex)
            {
                throw new EntityContextException("GetPlayerBYID failed.", ex);
            }
        }
Пример #4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {

                string id = Request.QueryString["id"];
                if (id != "00000000-0000-0000-0000-000000000000")
                {
                    _playerId = string.IsNullOrEmpty(id) ? new Guid() : new Guid(id);

                }

                string teamIds = Request.QueryString["teamId"];
                if (teamIds != "00000000-0000-0000-0000-000000000000")
                {
                    _teamId = string.IsNullOrEmpty(id) ? new Guid() : new Guid(id);

                }

                  player _player = new player();

                  RadWindow1.VisibleOnPageLoad = false;

                _player = _dal.GetPlayerBYID(_playerId);

                _player.Name = txtFullName.Text;
                _player.email = txtEmail.Text;
                  _player.address = txtAddress.Text;

                  _player.description = txtDescription.InnerText;
                   _player.gender = dlGenders.SelectedValue.ToString();
                  _player.modifiedDate = DateTime.Now;
                _player.teamId = new Guid(ddlTeam.SelectedValue.ToString());

                if (Convert.ToDateTime(dateOfBirth.Text) == new DateTime(1900, 1, 1))

                _player.dob =Convert.ToDateTime(dateOfBirth.Text);

                if (_player.player_id == null)
                    _player.player_id = _dal.genPlayerID(new Guid("B9B2A89A-2295-4E48-BBA4-9DC28A1855FB"), new Guid("6E424913-A9A4-4A46-9785-C8AFA09C82DB"));

                if (_teamId != Guid.Empty)
                {
                    _player.teamId = _teamId;

                }

                 if (id == "00000000-0000-0000-0000-000000000000")
                {

                   player_points _points = new player_points();

                   _points.points = 200;
                   _points.pointsToRedeem = 20;
                   _points.authCreatedDate = DateTime.Now;
                   _points.authUserName = User.Identity.Name;

                   _player.player_points.Add(_points);

                    _dal.SoccerEntities.AddToplayers(_player);
                }

                 _dal.SoccerEntities.SaveChanges();
            }

            catch (Exception ex)
            {

                throw new EntityContextException("btnSave_Click failed.", ex);

            }

            Response.Redirect("default.aspx?teamId=00000000-0000-0000-0000-000000000000&id=00000000-0000-0000-0000-000000000000");
        }
        public player_points GetPointsById(Guid _ppoints)
        {
            try
            {
                if (_ppoints == Guid.Empty)
                {
                    player_points _points = new player_points();
                    return _points;
                }
                else
                {
                    var q = SoccerEntities.player_points.Where(p => p.id == _ppoints && p.isDeleted == false);

                    if (q == null)
                        throw new EntityContextException(string.Format("A Point could not be found {0}!", _ppoints));
                    else
                        return q.ToList()[0];
                }
            }
            catch (Exception ex)
            {
                throw new EntityContextException("GetPointsById failed.", ex);
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the player_points EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToplayer_points(player_points player_points)
 {
     base.AddObject("player_points", player_points);
 }
 /// <summary>
 /// Create a new player_points object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="playerId">Initial value of the playerId property.</param>
 public static player_points Createplayer_points(global::System.Guid id, global::System.Guid playerId)
 {
     player_points player_points = new player_points();
     player_points.id = id;
     player_points.playerId = playerId;
     return player_points;
 }