Пример #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (TheClubBDEntities myEnt = new TheClubBDEntities())
     {
         var allSponsors = from sp in myEnt.Sponsors
                           orderby sp.FechaAlta
                           select sp;
         GridView1.DataSource = allSponsors;
         GridView1.DataBind();
     }
 }
Пример #2
0
    protected void imgBtnDelete_Click(object sender, ImageClickEventArgs e)
    {
        using (TheClubBDEntities myEntities = new TheClubBDEntities())
        {
            var aRaceType = (from r in myEntities.RaceTypes
                             where r.Id == _Id
                             select r).Single();

            myEntities.RaceTypes.DeleteObject(aRaceType);
            myEntities.SaveChanges();
        }
        GridView1.DataBind();
        setNormalMode();
    }
Пример #3
0
    protected void imgBtnCancel_Click(object sender, ImageClickEventArgs e)
    {
        using (TheClubBDEntities myEnt = new TheClubBDEntities())
        {
            var aRaceType = (from rt in myEnt.RaceTypes
                             orderby rt.Name ascending
                             where rt.Id == LastPos
                             select rt).SingleOrDefault();

            if (aRaceType == null)
            {
                _Id = -1;
                LastPos = -1;
            }
            else
            {
                _Id = aRaceType.Id;
                txbxNombre.Text = aRaceType.Name;
                txbxPuntos.Text = aRaceType.PuntosPart.ToString();
                txbxMemo.Text = aRaceType.Memo;
            }
            setNormalMode();
        }
    }
Пример #4
0
    protected void imgBtnFirst_Click(object sender, ImageClickEventArgs e)
    {
        using (TheClubBDEntities myEnt = new TheClubBDEntities())
        {

            var aRaceType = (from rt in myEnt.RaceTypes
                             orderby rt.Name ascending
                             select rt).FirstOrDefault();

            if (aRaceType == null)
                _Id = -1;
            else
            {
                _Id = aRaceType.Id;
                LastPos = _Id;
                txbxNombre.Text = aRaceType.Name;
                txbxPuntos.Text = aRaceType.PuntosPart.ToString();
                txbxMemo.Text = aRaceType.Memo;
            }
        }
    }
Пример #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        using (TheClubBDEntities myEnt = new TheClubBDEntities())
        {
            if (!Page.IsPostBack)
            {
                var aRaceType = (from rt in myEnt.RaceTypes
                                 select rt).FirstOrDefault();

                if (aRaceType == null)
                {
                    _Id = -1;
                    LastPos = -1;
                }
                else
                {
                    _Id = aRaceType.Id;
                    LastPos = _Id;
                    txbxNombre.Text = aRaceType.Name;
                    txbxPuntos.Text = aRaceType.PuntosPart.ToString();
                    txbxMemo.Text = aRaceType.Memo;
                }
            }
        }
    }
Пример #6
0
    protected void imgBtnSave_Click(object sender, ImageClickEventArgs e)
    {
        using (TheClubBDEntities myEntities = new TheClubBDEntities())
        {
            RaceType aRaceType;
            if (_Id == -1) //Save new
            {
                aRaceType = new RaceType();
                myEntities.RaceTypes.AddObject(aRaceType);
            }
            else
            {
                aRaceType = (from r in myEntities.RaceTypes
                             where r.Id == _Id
                             select r).Single();
            }
            aRaceType.Name = txbxNombre.Text;
            aRaceType.PuntosPart = Int32.Parse(txbxPuntos.Text);
            aRaceType.Memo = txbxMemo.Text;
            LastPos = _Id;
            myEntities.SaveChanges();

            GridView1.DataBind();

            setNormalMode();
        }
    }