Пример #1
0
        /// <summary>
        /// EVento que nos permite agregar un contacto a la BD
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void addContac(object sender, EventArgs e)
        {
            if (this.IsPostBack)
            {
                this.Validate();

                if (this.IsValid)
                {

                    ServicioGestionClient proxy = new ServicioGestionClient();

                    /** Objeto Contacto **/

                    ContactoData objetoContacto = new ContactoData();

                    objetoContacto.nombre = this.nomb.Text;
                    objetoContacto.nif = this.nf.Text;
                    objetoContacto.idEmpresa = Convert.ToInt32(Request.QueryString["id"]);

                    /** Fin objeto Contacto **/

                    ContactoData contacto = proxy.getContactoNif(objetoContacto.nif);
                    if (contacto == null)
                    {
                        int res=proxy.AddContacto(objetoContacto);

                        if (res != -1)
                        {
                            int idEmpresa = Convert.ToInt32(Request.QueryString["id"]);
                            Response.Redirect("gestionContacto.aspx?id=" + idEmpresa);
                        }
                        else
                        {
                            this.lblError.Visible = true;
                            this.lblError.Text = "No se guardaron los datos, error de acceso al servicio";
                        }
                    }
                    else
                    {
                        this.lblError.Visible = true;
                        this.lblError.Text = "No se puede insertar este contacto. El N.I.F. ya existe en la base de datos.";
                    }

                } // Fin del if (this.IsValid)
            }// Fin del if (this.IsPostBack)
        }