예제 #1
0
 public void CopySponsor(Sponsor aSponsor1)
 {
     this.SponsorId     = aSponsor1.SponsorId;
     this.Nombre        = aSponsor1.Nombre;
     this.Address       = aSponsor1.Address;
     this.ContactPerson = aSponsor1.ContactPerson;
     this.Mobile        = aSponsor1.Mobile;
     this.Tlf           = aSponsor1.Tlf;
     this.RegDate       = aSponsor1.RegDate;
     this.CondOfertadas = aSponsor1.CondOfertadas;
     this.AportInicial  = aSponsor1.AportInicial;
     this.AportRecibida = aSponsor1.AportRecibida;
     this.WebURL        = aSponsor1.WebURL;
     this.EMail         = aSponsor1.EMail;
     this.LogoURL       = aSponsor1.LogoURL;
     this.ImageURL      = aSponsor1.ImageURL;
     this.Activo        = aSponsor1.Activo;
     this.Longitud      = aSponsor1.Longitud;
     this.Latitud       = aSponsor1.Latitud;
     this.Memo          = aSponsor1.Memo;
 }
예제 #2
0
 private void LoadSponsorInForm(Sponsor aSponsor)
 {
     sponsorUsedId = aSponsor.SponsorId;
     imgLogo.ImageUrl = aSponsor.LogoURL;
     imgLogo.AlternateText = "(Sin Logo)";
     FileULogo.Text = "";
     imgImage.ImageUrl = aSponsor.ImageURL;
     imgImage.AlternateText = "(Sin imagen)";
     FileUImg.Text = "";
     txbxId.Text = sponsorUsedId.ToString();
     txbxNombre.Text = aSponsor.Nombre;
     txbxContacto.Text = aSponsor.ContactPerson;
     txbxRegDate.Text = aSponsor.RegDate.ToShortDateString();
     chbcActivo.Checked = aSponsor.Activo;
     try
     {
         txbxAportInicial.Text = aSponsor.AportInicial.ToString();
     }
     catch (Exception)
     {
         txbxAportInicial.Text = "";
     }
     try
     {
         txbxAportRecibida.Text = aSponsor.AportRecibida.ToString();
     }
     catch (Exception)
     {
         txbxAportRecibida.Text = "";
     }
     txbxCondOfertadas.Text = aSponsor.CondOfertadas;
     txbxBlogURL.Text = aSponsor.WebURL;
     txbxEMail.Text = aSponsor.EMail;
     txbxMobile.Text = aSponsor.Mobile;
     txbxTlf.Text = aSponsor.Tlf;
     txbxMemo.Text = aSponsor.Memo;
     if (aSponsor.Address == null)
     {
         txbxStreet.Text = null;
         txbxCity.Text = null;
         txbxNumber.Text = null;
         txbxCountry.Text = null;
         txbxPostalCode.Text = null;
     }
     else
     {
         txbxStreet.Text = aSponsor.Address.Street;
         txbxCity.Text = aSponsor.Address.City;
         txbxNumber.Text = aSponsor.Address.Number;
         txbxCountry.Text = aSponsor.Address.Country;
         txbxPostalCode.Text = aSponsor.Address.PostalCode;
     }
     ////To avoid problems with the , and . in decimal numbers
     System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en-US");
     txbxLatitud.Text = Convert.ToString(aSponsor.Latitud, culture );
     txbxLongitud.Text = Convert.ToString(aSponsor.Longitud, culture);
 }
예제 #3
0
        private Sponsor LoadSponsorFromForm()
        {
            Sponsor aSponsor = new Sponsor();
            aSponsor.SponsorId = Convert.ToInt16(txbxId.Text);
            aSponsor.LogoURL = sponsorUsed.LogoURL;
            aSponsor.ImageURL = sponsorUsed.ImageURL;
            aSponsor.Nombre = txbxNombre.Text;
            aSponsor.ContactPerson = txbxContacto.Text;
            aSponsor.RegDate = Convert.ToDateTime(txbxRegDate.Text);
            aSponsor.Activo = chbcActivo.Checked;
            try
            {
                aSponsor.AportInicial = Convert.ToDecimal(txbxAportInicial.Text);
            }
            catch (Exception)
            {
                aSponsor.AportInicial = 0;
            }
            try
            {
                aSponsor.AportRecibida = Convert.ToDecimal(txbxAportRecibida.Text);
            }
            catch (Exception)
            {
                aSponsor.AportRecibida = 0;
            }
            aSponsor.CondOfertadas = txbxCondOfertadas.Text;
            aSponsor.WebURL = txbxBlogURL.Text;
            aSponsor.EMail = txbxEMail.Text;
            aSponsor.Mobile = txbxMobile.Text;
            aSponsor.Tlf = txbxTlf.Text;
            aSponsor.Memo = txbxMemo.Text;
            aSponsor.Address.Street = txbxStreet.Text;
            aSponsor.Address.City = txbxCity.Text;
            aSponsor.Address.Number = txbxNumber.Text;
            aSponsor.Address.Country = txbxCountry.Text;
            aSponsor.Address.PostalCode = txbxPostalCode.Text;
            string aux = ReformatNumber(txbxLatitud.Text);
            if (aux == null)
                aSponsor.Latitud = 0;
            else
            {
                aSponsor.Latitud = Convert.ToDouble(aux);
            }

            aux = ReformatNumber(txbxLongitud.Text);
            if (aux == null)
                aSponsor.Longitud = 0;
            else
            {
                aSponsor.Longitud = Convert.ToDouble(aux);
            }
            return aSponsor;
        }
예제 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                sponsorUsed = new Sponsor();
                oldSponsorUsed = new Sponsor();
                using (var db = new ClubSiteContext())
                {
                    sponsorUsed = (from sponsors in db.Sponsors
                                   orderby sponsors.Nombre
                                   select sponsors).FirstOrDefault();

                    if (sponsorUsed == null)
                    {
                        sponsorUsed = new Sponsor();
                        Response.Write("<script>alert('No hay ningún Sponsor registrado en la Base de datos.')</script>");
                    }
                    oldSponsorUsed.CopySponsor(sponsorUsed);
                    LoadSponsorInForm(sponsorUsed);
                }
            }
        }
예제 #5
0
        protected void GPSponsors_CellClick(object sender, EventArgs e)
        {
            //Click a Sponsor in grid and show data in edit boxes
            try
            {
                CellSelectionModel sm = this.GPSponsors.GetSelectionModel() as CellSelectionModel;
                Int32 actualSId = Convert.ToInt32(sm.SelectedCell.RecordID);

                //Search the Sponsor and load into model object.
                using (var db = new ClubSiteContext())
                {
                    sponsorUsed = (from sponsors in db.Sponsors
                                   orderby sponsors.Nombre
                                   where sponsors.SponsorId == actualSId
                                   select sponsors).FirstOrDefault();

                    if (sponsorUsed == null)
                        X.Msg.Alert("Atención", "No hay ningún sponsor registrado en la Base de datos.").Show();
                    oldSponsorUsed.CopySponsor(sponsorUsed);

                    //Loads model object data into form
                    LoadSponsorInForm(sponsorUsed);
                }
            }
            catch (Exception) { }
            btnBorrar.Enabled = true;
        }
예제 #6
0
        public void DoDel()
        {
            if (sponsorUsed.SponsorId == 0)
            { //No Race Type selected
                X.Msg.Alert("Atención", "No hay nada que borrar ya que no hay sponsors registrados.").Show();
            }
            else
            {
                using (var db = new ClubSiteContext())
                {
                    Sponsor item = (from sponsors in db.Sponsors
                                    where sponsors.SponsorId == sponsorUsed.SponsorId
                                    select sponsors).FirstOrDefault();
                    if (item == null)
                    {
                        // The item wasn't found
                        ModelState.AddModelError("", String.Format("Sponsor con id : {0} no encontrado", sponsorUsed.SponsorId));
                        X.Msg.Alert("Atención", "Sponsor no encontrado").Show();
                        return;
                    }
                    db.Sponsors.Remove(item);
                    db.SaveChanges();
                    this.StoreGPSponsors.DataBind();
                    X.Msg.Alert("Atención", "Sponsor borrado.").Show();

                    //Load data for first race type
                    sponsorUsed = (from sponsors in db.Sponsors
                                   orderby sponsors.Nombre
                                   select sponsors).FirstOrDefault();

                    if (sponsorUsed == null)
                    {
                        //Last item was erased. No items in BD.
                        sponsorUsed = new Sponsor();
                        X.Msg.Alert("Atención", "No queda ningún sponsor registrado en la Base de datos.").Show();
                    }

                    oldSponsorUsed.CopySponsor(sponsorUsed);
                    //Loads model object data into form
                    LoadSponsorInForm(sponsorUsed);
                }
            }
        }
예제 #7
0
 public void CopySponsor(Sponsor aSponsor1)
 {
     this.SponsorId = aSponsor1.SponsorId;
     this.Nombre = aSponsor1.Nombre;
     this.Address = aSponsor1.Address;
     this.ContactPerson = aSponsor1.ContactPerson;
     this.Mobile = aSponsor1.Mobile;
     this.Tlf = aSponsor1.Tlf;
     this.RegDate = aSponsor1.RegDate;
     this.CondOfertadas = aSponsor1.CondOfertadas;
     this.AportInicial = aSponsor1.AportInicial;
     this.AportRecibida = aSponsor1.AportRecibida;
     this.WebURL = aSponsor1.WebURL;
     this.EMail = aSponsor1.EMail;
     this.LogoURL = aSponsor1.LogoURL;
     this.ImageURL = aSponsor1.ImageURL;
     this.Activo = aSponsor1.Activo;
     this.Longitud = aSponsor1.Longitud;
     this.Latitud = aSponsor1.Latitud;
     this.Memo = aSponsor1.Memo;
 }
예제 #8
0
        public void TestCopySponsor()
        {
            int aSponsorId = 10;
            string aNombre = "Name";
            string aContactPerson = "Contact person";
            string aMobile = "999 929292";
            string aTlf = "555 676767";
            DateTime aRegDate = DateTime.Now;
            string aCondOfertadas = "Condiciones ofertadas";
            decimal anAportInicial = 400;
            decimal anAportRecibida = 200;
            string aWebURL = "www.weburl.com";
            string anEMail = "*****@*****.**";
            string aLogoURL = "a logo URL";
            string anImageURL = " An image URL";
            bool activo = false;
            double aLatitud = 40.381090863719436;
            double aLongitud = -3.6222052574157715;
            string aMemo = "Observaciones varias";

            string aStreet = "Street";
            string aNumber = "1a";
            string aCity = "City";
            string aCountry = "Country";
            string aPostalCode = "18007";

            Address anAddress = new Address(aStreet, aNumber, aCity, aCountry, aPostalCode);
            Sponsor aSponsor1 = new Sponsor();
            aSponsor1.SetSponsor(aSponsorId, aNombre, anAddress, aContactPerson, aMobile, aTlf, aRegDate, aCondOfertadas, anAportInicial,
                anAportRecibida, aWebURL, anEMail, aLogoURL, anImageURL, aLongitud, aLatitud, activo, aMemo);

            Assert.AreEqual(aSponsorId, aSponsor1.SponsorId);
            Assert.AreEqual(aNombre, aSponsor1.Nombre);
            Assert.AreEqual(aContactPerson, aSponsor1.ContactPerson);
            Assert.AreEqual(aMobile, aSponsor1.Mobile);
            Assert.AreEqual(aTlf, aSponsor1.Tlf);
            Assert.AreEqual(aRegDate.ToShortDateString(), aSponsor1.RegDate.ToShortDateString());
            Assert.AreEqual(aCondOfertadas, aSponsor1.CondOfertadas);
            Assert.AreEqual(anAportInicial, aSponsor1.AportInicial);
            Assert.AreEqual(anAportRecibida, aSponsor1.AportRecibida);
            Assert.AreEqual(aWebURL, aSponsor1.WebURL);
            Assert.AreEqual(anEMail, aSponsor1.EMail);
            Assert.AreEqual(aLogoURL, aSponsor1.LogoURL);
            Assert.AreEqual(anImageURL, aSponsor1.ImageURL);
            Assert.AreEqual(activo, aSponsor1.Activo);
            Assert.AreEqual(aLatitud, aSponsor1.Latitud);
            Assert.AreEqual(aLongitud, aSponsor1.Longitud);
            Assert.AreEqual(aMemo, aSponsor1.Memo);

            Assert.AreEqual(aStreet, aSponsor1.Address.Street);
            Assert.AreEqual(aNumber, aSponsor1.Address.Number);
            Assert.AreEqual(aCity, aSponsor1.Address.City);
            Assert.AreEqual(aCountry, aSponsor1.Address.Country);
            Assert.AreEqual(aPostalCode, aSponsor1.Address.PostalCode);

            Sponsor aSponsor2 = new Sponsor();
            aSponsor2.CopySponsor(aSponsor1);

            Assert.AreEqual(aSponsorId, aSponsor2.SponsorId);
            Assert.AreEqual(aNombre, aSponsor2.Nombre);
            Assert.AreEqual(aContactPerson, aSponsor2.ContactPerson);
            Assert.AreEqual(aMobile, aSponsor2.Mobile);
            Assert.AreEqual(aTlf, aSponsor2.Tlf);
            Assert.AreEqual(aMobile, aSponsor2.Mobile);
            Assert.AreEqual(aTlf, aSponsor2.Tlf);
            Assert.AreEqual(aRegDate.ToShortDateString(), aSponsor2.RegDate.ToShortDateString());
            Assert.AreEqual(aCondOfertadas, aSponsor2.CondOfertadas);
            Assert.AreEqual(anAportInicial, aSponsor2.AportInicial);
            Assert.AreEqual(anAportRecibida, aSponsor2.AportRecibida);
            Assert.AreEqual(aWebURL, aSponsor2.WebURL);
            Assert.AreEqual(anEMail, aSponsor2.EMail);
            Assert.AreEqual(aLogoURL, aSponsor2.LogoURL);
            Assert.AreEqual(anImageURL, aSponsor2.ImageURL);
            Assert.AreEqual(activo, aSponsor2.Activo);
            Assert.AreEqual(aLatitud, aSponsor2.Latitud);
            Assert.AreEqual(aLongitud, aSponsor2.Longitud);
            Assert.AreEqual(aMemo, aSponsor2.Memo);

            Assert.AreEqual(aStreet, aSponsor2.Address.Street);
            Assert.AreEqual(aNumber, aSponsor2.Address.Number);
            Assert.AreEqual(aCity, aSponsor2.Address.City);
            Assert.AreEqual(aCountry, aSponsor2.Address.Country);
            Assert.AreEqual(aPostalCode, aSponsor2.Address.PostalCode);
        }
예제 #9
0
        public void TestSponsorConstructorWithoutData()
        {
            int aSponsorId=0;
            string aNombre=null;
            string aContactPerson = null;
            string aMobile = null;
            string aTlf = null;
            DateTime aRegDate=DateTime.Now;
            string aCondOfertadas = null;
            decimal anAportInicial = 0;
            decimal anAportRecibida = 0;
            string aWebURL = null;
            string anEMail = null;
            string aLogoURL = null;
            string anImageURL = null;
            bool activo=false;
            double aLatitud = 0;
            double aLongitud = 0;
            string aMemo = null;
            string aStreet = null;
            string aNumber = null;
            string aCity = null;
            string aCountry = null;
            string aPostalCode = null;

            Sponsor aSponsor = new Sponsor();

            Assert.AreEqual(aSponsorId, aSponsor.SponsorId);
            Assert.AreEqual(aNombre, aSponsor.Nombre);
            //Assert.AreEqual(null, aSponsor.Address);
            Assert.AreEqual(aStreet, aSponsor.Address.Street);
            Assert.AreEqual(aNumber, aSponsor.Address.Number);
            Assert.AreEqual(aCity, aSponsor.Address.City);
            Assert.AreEqual(aCountry, aSponsor.Address.Country);
            Assert.AreEqual(aPostalCode, aSponsor.Address.PostalCode);

            Assert.AreEqual(aContactPerson, aSponsor.ContactPerson);
            Assert.AreEqual(aMobile, aSponsor.Mobile);
            Assert.AreEqual(aTlf, aSponsor.Tlf);
            Assert.AreEqual(aRegDate.ToShortDateString(), aSponsor.RegDate.ToShortDateString());
            Assert.AreEqual(aCondOfertadas, aSponsor.CondOfertadas);
            Assert.AreEqual(anAportInicial, aSponsor.AportInicial);
            Assert.AreEqual(anAportRecibida, aSponsor.AportRecibida);
            Assert.AreEqual(aWebURL, aSponsor.WebURL);
            Assert.AreEqual(anEMail, aSponsor.EMail);
            Assert.AreEqual(aLogoURL, aSponsor.LogoURL);
            Assert.AreEqual(anImageURL, aSponsor.ImageURL);
            Assert.AreEqual(activo, aSponsor.Activo);
            Assert.AreEqual(aLatitud, aSponsor.Latitud);
            Assert.AreEqual(aLongitud, aSponsor.Longitud);
            Assert.AreEqual(aMemo, aSponsor.Memo);
        }