Пример #1
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            Cheff cheff = new Cheff();

            cheff.Nombre       = this.txtNombre.Text;
            cheff.Apellido     = this.txtApellido.Text;
            cheff.Telefono     = this.txtTelefono.Text;
            cheff.Especialidad = this.txtEspecialidad.Text;
            cheff.DNI          = this.txtDNI.Text;

            AdmCheff PATOVACHEFF = new AdmCheff();
            int      resultado   = PATOVACHEFF.ingresarCheff(cheff);

            if (resultado == 1)
            {
                //lo agrego bien
                LitResultado.Text = "Cheff agregado con exito";
                //limpio los textbox
                this.txtNombre.Text = "";
            }
            else
            {
                //El cheff ya existe
                LitResultado.Text = "Ya existe Cheff con ese DNI";
            }
        }
Пример #2
0
        public int ingresarCheff(Cheff cheff)
        {
            //Validaciones
            //Validar si ya existe el cheff
            Cheff cheffAuxiliar = cheffDB.buscarPorDNI(cheff.DNI);

            if (cheffAuxiliar == null)//Si no existe el cheff con ese DNI me lo agrega
            {
                cheffDB.agregarCheff(cheff);
                return(1);
            }
            else
            {
                return(-1);
            }
        }
Пример #3
0
        public Cheff buscarPorDNI(string dni)
        {
            Cheff cheff = DB.Cheffs.Where(c => c.DNI == dni).FirstOrDefault();

            return(cheff);
        }
Пример #4
0
 public void agregarCheff(Cheff cheff)
 {
     DB.Cheffs.Add(cheff);
     DB.SaveChanges();
 }