Пример #1
0
        private void LoadMemberInForm(Member aMember)
        {
            actualUserName = aMember.UserName;
            txbxUserName.Text = aMember.UserName;
            txbxRegDate.Text = aMember.RegDate.ToShortDateString();
            txbxClubberNumber.Text = aMember.Number;
            txbxDNI.Text = aMember.DNI;
            txbxFirstName.Text = aMember.FirstName;
            txbxSecondName.Text = aMember.SecondName;
            txbxBdate.Text = aMember.BirthDate.ToString();
            imgImage.ImageUrl = aMember.ImageURL;
            FileUploadImage.Text = "";
            imgNImage.ImageUrl = aMember.NImageURL;
            FileUploadNumber.Text = "";
            chbxFederated.Checked = aMember.Federated;
            chBxActiveUser.Checked = aMember.State;
            chbxVisible.Checked = aMember.Visible;
            txbxBlogURL.Text = aMember.BlogURL;
            txbxEMail.Text = aMember.EMail;
            txbxMobile.Text = aMember.Mobile;
            txbxTlf.Text = aMember.Tlf;
            if (aMember.Address == null)
            {
                txbxStreet.Text = "";
                txbxNumber.Text = "";
                txbxCity.Text = "";
                txbxCountry.Text = "";
                txbxPostalCode.Text = "";
            }
            else
            {
                txbxStreet.Text = aMember.Address.Street;
                txbxNumber.Text = aMember.Address.Number;
                txbxCity.Text = aMember.Address.City;
                txbxCountry.Text = aMember.Address.Country;
                txbxPostalCode.Text = aMember.Address.PostalCode;
            }
            txbxMemo.Text = aMember.Memo;

            //Load data for races for the clubber selected
            LoadDataInGridForRacesForClubber();

            FileUploadNumber.Reset();
            FileUploadImage.Reset();
        }
Пример #2
0
        protected void GVClubbers_Click(object sender, EventArgs e)
        {
            try
            {
                CellSelectionModel sm = this.GPClubbers.GetSelectionModel() as CellSelectionModel;
                string actualRId = sm.SelectedCell.RecordID;
                using (var db = new ClubSiteContext())
                {
                    memberUsed = (from m in db.Members
                                  where m.UserName == actualRId
                                  select m).FirstOrDefault();

                    if (memberUsed == null)
                        X.Msg.Alert("Atención", "No hay ningun clubber registrada en la Base de datos.").Show();
                    oldMemberUsed.CopyPerson(memberUsed);

                    //Loads model object data into form
                    LoadMemberInForm(memberUsed);
                }
            }
            catch (Exception) { }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                memberUsed = new Member();
                oldMemberUsed = new Member();
                newNumber = false;
                newImage = false;
                newNImage = false;
                using (var db = new ClubSiteContext())
                {
                    memberUsed = (from members in db.Members
                                  orderby members.UserName
                                  select members).FirstOrDefault();

                    if (memberUsed == null)
                    {
                        actualUserName = "";
                        Notification.Show(new NotificationConfig { Title = "Atención", Icon = Icon.Error, Html = "No hay ningún usuario registrado en la Base de datos. Vaya al formulario de registro para crear nuevos usuarios." });
                    }
                    else
                    {
                        actualUserName = memberUsed.UserName;

                        //Load Dates
                        DateTime fromDate = new DateTime(DateTime.Now.Year, 1, 1);
                        DateTime toDate = new DateTime(DateTime.Now.Year, 12, 31);
                        dtfFromDate.SelectedDate = fromDate;
                        dtfToDate.SelectedDate = toDate;

                        //Load data for Races combobox
                        LoadDataInRacesCombo();

                        //Load data for races for the clubber selected
                        LoadDataInGridForRacesForClubber();
                    }
                    LoadMemberInForm(memberUsed);
                    oldMemberUsed.CopyMember(memberUsed);
                }
            }
        }
Пример #4
0
        public void DoDelRace()
        {
            bool sigue = true;
            string messageError = "";

            //Verify race exists
            if (txbxUserName.Text == "")
            {
                sigue = false;
                messageError = "No hay competiciones que quitar.";
            }

            if (sigue)
            {
                if (actualRaceId == 0)
                {
                    messageError = "Seleccione una competición para quitar de la tabla.";
                    sigue = false;
                }
            }

            if (sigue)
            {
                //Load data for username
                using (var db = new ClubSiteContext())
                {
                    Member aMember = new Member();
                    Race aRace = new Race();
                    aMember = (from m in db.Members where m.UserName == memberUsed.UserName select m).FirstOrDefault();
                    aRace = (from r in db.Races where r.Id == actualRaceId select r).FirstOrDefault();
                    try
                    {
                        aRace.Members.Remove(aMember);
                        db.SaveChanges();
                        LoadDataInGridForRacesForClubber();
                        X.Msg.Alert("Atención", memberUsed.UserName + " quitad@ de la competición.").Show();
                    }
                    catch (Exception)
                    {
                        X.Msg.Alert("Atención", "Hubo un problema al quitar a " + memberUsed.UserName + " de la competición seleccionada.").Show();
                    }

                }
            }

            if (!sigue)
            {
                X.Msg.Alert("Atención", messageError).Show();
            }
        }
Пример #5
0
        public void DoSave()
        {
            bool sigue = true;
            bool nuevo = false;
            string messageError = null;

            //Save if conditions are ok.
            if (sigue)
            {
                //Update actual member
                actualUserName = txbxUserName.Text;
                using (var db = new ClubSiteContext())
                {
                    Member aMember = (from members in db.Members
                                      where members.UserName == actualUserName
                                      select members).FirstOrDefault();
                    if (aMember == null)
                    { //New User
                        aMember = new Member();
                        aMember.UserName = actualUserName;
                        nuevo = true;
                    }
                    try
                    {
                        aMember.FirstName = txbxFirstName.Text;
                        aMember.SecondName = txbxSecondName.Text;
                        aMember.BlogURL = txbxBlogURL.Text;
                        aMember.Memo = txbxMemo.Text;
                        aMember.DNI = txbxDNI.Text;
                        if (txbxBdate.Value.ToString() == "01/01/0001 0:00:00")
                        {
                            aMember.BirthDate = null;
                        }
                        else
                        {
                            try
                            {
                                aMember.BirthDate = Convert.ToDateTime(txbxBdate.Text);
                            }
                            catch
                            {
                                aMember.BirthDate = null;
                            }
                        }
                        aMember.Federated = chbxFederated.Checked;
                        aMember.State = chBxActiveUser.Checked;
                        aMember.Visible = chbxVisible.Checked;
                        if (FileUploadNumber.HasFile)
                        {
                            aMember.NImageURL = "../Images/Clubbers/" + FileUploadNumber.FileName; //imgNImage.ImageUrl;
                        }
                        else
                        {
                            aMember.NImageURL = memberUsed.NImageURL;
                        }
                        if (FileUploadImage.HasFile)
                        {
                            aMember.ImageURL = "../Images/Clubbers/" + FileUploadImage.FileName; //imgImage.ImageUrl;
                        }
                        else
                        {
                            aMember.ImageURL = memberUsed.ImageURL;
                        }
                        aMember.Tlf = txbxTlf.Text;
                        aMember.Mobile = txbxMobile.Text;
                        aMember.EMail = txbxEMail.Text;
                        if (nuevo)
                        {
                            aMember.Address = new Address();
                        }
                        aMember.Address.Street = txbxStreet.Text;
                        aMember.Address.Number = txbxNumber.Text;
                        aMember.Address.City = txbxCity.Text;
                        aMember.Address.Country = txbxCountry.Text;
                        aMember.Address.PostalCode = txbxPostalCode.Text;
                        aMember.Number = txbxClubberNumber.Text;
                        if (nuevo)
                        {
                            db.Members.Add(aMember);
                        }
                        db.SaveChanges();
                        memberUsed.CopyMember(aMember);
                        oldMemberUsed.CopyMember(aMember);
                        Notification.Show(new NotificationConfig { Title = "Aviso", Icon = Icon.Information, Html = "Datos del usuario "+ actualUserName +" grabados" });

                    }
                    catch (Exception)
                    {
                        sigue = false;
                        messageError = " No se grabaron los datos, se produjo un error al acceder a la base";
                    }
                    GPClubbers.DataBind();
                    newNumber = false;
                    newImage = false;
                }
            }
            if (!sigue)
            {
                X.Msg.Alert("Atención", messageError).Show();
            }
        }
Пример #6
0
        public void DoAddRace()
        {
            bool sigue = true;
            string messageError = "";

            //Load data for Race/Clubber
            using (var db = new ClubSiteContext())
            {
                Member aMember = new Member();
                Race aRace = new Race();
                aMember = (from m in db.Members where m.UserName == memberUsed.UserName select m).FirstOrDefault();
                aRace = (from r in db.Races where r.Id == actualRaceId select r).FirstOrDefault();

                //verify if member is in members list for race
                if (aRace.Members.Contains(aMember) == true)
                {
                    messageError = memberUsed.UserName + " ya esta inscrit@ en esa competición.";
                    sigue = false;
                }
                else
                {
                    try
                    {
                        aRace.Members.Add(aMember);
                        db.SaveChanges();
                        LoadDataInGridForRacesForClubber();
                        X.Msg.Alert("Atención", "Se ha inscrito a " + memberUsed.UserName + " en la competición.").Show();
                    }
                    catch (Exception)
                    {
                        X.Msg.Alert("Atención", "Hubo un problema al añadir a " + memberUsed.UserName + "a la lista de participantes en la competición.").Show();
                    }
                }
            }

            if (!sigue)
            {
                X.Msg.Alert("Atención", messageError).Show();
            }
        }
Пример #7
0
        public void DoDel()
        {
            //1-Delete user in Member table in ClubSite.mdf DB
            using (var db = new ClubSiteContext())
            {
                //Delete the user
                var aClubberToDelete = (from c in db.Members
                                        where c.UserName == actualUserName
                                        select c).Single();
                db.Members.Remove(aClubberToDelete);
                db.SaveChanges();
                //Delete de Image files for the user
                if (System.IO.File.Exists(Server.MapPath(imgNImage.ImageUrl)))
                    System.IO.File.Delete(Server.MapPath(imgNImage.ImageUrl));
                if (System.IO.File.Exists(Server.MapPath(imgImage.ImageUrl)))
                    System.IO.File.Delete(Server.MapPath(imgImage.ImageUrl));
                Notification.Show(new NotificationConfig { Title = "Aviso", Icon = Icon.Information, Html = "Usuario "+ actualUserName +" borrado correctamente." });
            }

            //2-Delete user in Membership and Users tables in ClubSiteBDDefault DB
            Membership.DeleteUser(actualUserName);

            //3-Load data for the first member into the form.
            using (var db = new ClubSiteContext())
            {
                var aMember = (from members in db.Members
                               orderby members.UserName
                               select members).FirstOrDefault();

                if (aMember == null)
                {
                    actualUserName = "";
                    memberUsed = new Member();
                    LoadMemberInForm(memberUsed);
                    Notification.Show(new NotificationConfig { Title = "Aviso", Icon = Icon.Information, Html = "Ya no hay ningún usuario registrado. Para crear nuevos usuarios vaya al formulario de registro." });
                }
                else
                {
                    LoadMemberInForm(aMember);
                    memberUsed.CopyMember(aMember);
                }
                oldMemberUsed.CopyMember(memberUsed);
            }
            //4-Refresh the GridView
            GPClubbers.DataBind();
        }
Пример #8
0
        protected void RegisterUser_CreatedUser(object sender, EventArgs e)
        {
            //save aditional DataBind of user
            using (var bd = new ClubSiteContext())
            {
                try
                {
                    string aUserName = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("UserName")).Text;
                    string aFirstName = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txbxName")).Text;
                    string aSecondName = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txbxSecondName")).Text;
                    string aBlogURL = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txbxBlog")).Text;
                    string aMemo = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txbxMemo")).Text;
                    string aDNI = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txbxDNI")).Text;
                    DateTime? aBirthDate = null;
                    try
                    {
                        aBirthDate = Convert.ToDateTime(((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txbxBdate")).Text);
                    }
                    catch
                    {
                        aBirthDate = null;
                    }
                    DateTime aRegDate = DateTime.Now;
                    bool aState = false;
                    bool visible = false;
                    bool federated = ((CheckBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("chbxFederated")).Checked;
                    string aNImageURL = ((Image)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("imgNImageURL")).ImageUrl;
                    string anImageURL = ((Image)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("imgImageURL")).ImageUrl;
                    string aTlf = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txbxTlf")).Text;
                    string aMobile = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txbxMobile")).Text;
                    string anEMail = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Email")).Text;
                    string aClubNumber = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txbxClubNumber")).Text;
                    string aStreet = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txbxStreet")).Text;
                    string aNumber = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txbxNumber")).Text;
                    string aCity = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txbxCity")).Text;
                    string aCountry = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txbxCountry")).Text;
                    string aPostalCode = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txbxPostalCode")).Text;
                    Address anAddress = new Address(aStreet, aNumber, aCity, aCountry, aPostalCode);
                    Member aMember = new Member(aUserName, aClubNumber, aFirstName, aSecondName, aDNI, anAddress, aTlf, aMobile, anEMail,
                        aState, federated, visible, aBirthDate, aMemo, anImageURL, aNImageURL, aBlogURL);
                    bd.Members.Add(aMember);
                    bd.SaveChanges();
                }
                catch (Exception)
                {
                    throw;
                }
            }

            FormsAuthentication.SetAuthCookie(RegisterUser.UserName, createPersistentCookie: false);

            string continueUrl = RegisterUser.ContinueDestinationPageUrl;
            if (!OpenAuth.IsLocalUrl(continueUrl))
            {
                continueUrl = "~/";
            }
            Response.Redirect(continueUrl);
        }
Пример #9
0
 public void CopyMember(Member aMember)
 {
     this.UserName = aMember.UserName;
     this.Number = aMember.Number;
     this.FirstName = aMember.FirstName;
     this.SecondName = aMember.SecondName;
     this.DNI = aMember.DNI;
     if (aMember.Address == null)
     {
         this.Address = null;
     }
     else
     {
         this.Address = new Address (aMember.Address.Street, aMember.Address.Number, aMember.Address.PostalCode,
                                     aMember.Address.Country, aMember.Address.City );
     }
     this.Tlf = aMember.Tlf;
     this.Mobile = aMember.Mobile;
     this.EMail = aMember.EMail;
     this.State = aMember.State;
     this.Federated = aMember.Federated;
     this.Visible = aMember.Visible;
     this.RegDate = aMember.RegDate;
     this.BirthDate = aMember.BirthDate;
     this.Memo = aMember.Memo;
     this.ImageURL = aMember.ImageURL;
     this.NImageURL = aMember.NImageURL;
     this.BlogURL = aMember.BlogURL;
 }
Пример #10
0
        public void TestMemberConstructorWithData()
        {
            string aUserName = "******";
            string aDNI = "DNI Number";
            bool aState = false;
            bool federated = false;
            bool visible = false;
            DateTime aRegDate = DateTime.Now;
            DateTime? aBirthdate = Convert.ToDateTime("12/12/2012");
            string aMemo = "A Memo";
            string anImageURL = "Image URL";
            string aNImageURL = "Image URL";
            string aBlogURL = "A Blog URL";
            string aFirstName = "First name";
            string aSecondName = "Second name";
            string aTlf = "tlf Numbre";
            string aMobile = "Mobile number";
            string anEMail = "Email";
            string aStreet = "Street";
            string aNumber = "1a";
            string aCity = "City";
            string aCountry = "Country";
            string aPostalCode = "18007";
            string aClubNumber = "14";

            Address anAddress = new Address(aStreet, aNumber, aCity, aCountry, aPostalCode);
            Member aMember = new Member(aUserName, aClubNumber, aFirstName, aSecondName, aDNI, anAddress, aTlf, aMobile, anEMail,
                aState, federated, visible, aBirthdate, aMemo, anImageURL, aNImageURL, aBlogURL);

            Assert.AreEqual(aUserName, aMember.UserName);
            Assert.AreEqual(aDNI, aMember.DNI);
            Assert.AreEqual(aState, aMember.State);
            Assert.AreEqual(federated, aMember.Federated);
            Assert.AreEqual(visible, aMember.Visible);
            Assert.AreEqual(aRegDate.ToShortDateString(), aMember.RegDate.ToShortDateString());
            Assert.AreEqual(aBirthdate, aMember.BirthDate);
            Assert.AreEqual(aMemo, aMember.Memo);
            Assert.AreEqual(anImageURL, aMember.ImageURL);
            Assert.AreEqual(aNImageURL, aMember.NImageURL);
            Assert.AreEqual(aBlogURL, aMember.BlogURL);
            Assert.AreEqual(aFirstName, aMember.FirstName);
            Assert.AreEqual(aSecondName, aMember.SecondName);
            Assert.AreEqual(aStreet, aMember.Address.Street);
            Assert.AreEqual(aNumber, aMember.Address.Number);
            Assert.AreEqual(aCity, aMember.Address.City);
            Assert.AreEqual(aCountry, aMember.Address.Country);
            Assert.AreEqual(aPostalCode, aMember.Address.PostalCode);
            Assert.AreEqual(aTlf, aMember.Tlf);
            Assert.AreEqual(aMobile, aMember.Mobile);
            Assert.AreEqual(anEMail, aMember.EMail);
            Assert.AreEqual(aClubNumber, aMember.Number);
        }
Пример #11
0
        public void TestMemberConstructorWithoutData()
        {
            string aUserName = null;
            string aDNI = null;
            bool aState = false;
            bool federated = false;
            bool visible = false;
            DateTime aRegDate = DateTime.Now;
            DateTime? aBirthdate = null;
            string aMemo = null;
            string anImageURL = null;
            string aNImageURL = null;
            string aBlogURL = null;
            string aFirstName = null;
            string aSecondName = null;
            string aTlf = null;
            string aMobile = null;
            string anEMail = null;

            Member aMember = new Member();

            Assert.AreEqual(aUserName, aMember.UserName);
            Assert.AreEqual(aDNI, aMember.DNI);
            Assert.AreEqual(aState, aMember.State);
            Assert.AreEqual(federated, aMember.Federated);
            Assert.AreEqual(visible, aMember.Visible);
            Assert.AreEqual(aRegDate.ToShortDateString(), aMember.RegDate.ToShortDateString());
            Assert.AreEqual(aBirthdate, aMember.BirthDate);
            Assert.AreEqual(aMemo, aMember.Memo);
            Assert.AreEqual(anImageURL, aMember.ImageURL);
            Assert.AreEqual(aNImageURL, aMember.NImageURL);
            Assert.AreEqual(aBlogURL, aMember.BlogURL);
            Assert.AreEqual(aFirstName, aMember.FirstName);
            Assert.AreEqual(aSecondName, aMember.SecondName);
            Assert.AreEqual(null, aMember.Address);
            Assert.AreEqual(aTlf, aMember.Tlf);
            Assert.AreEqual(aMobile, aMember.Mobile);
            Assert.AreEqual(anEMail, aMember.EMail);
        }
Пример #12
0
 public void AddMemberToRace(Member aMember)
 {
     this.Members.Add(aMember);
 }