public static bool Guardar(Fotografos fotografo)
 {
     if (!Existe(fotografo.FotografoId))
     {
         return(Insertar(fotografo));
     }
     else
     {
         return(Modificar(fotografo));
     }
 }
Beispiel #2
0
        public void GuardarTest()
        {
            Fotografos fotografos = new Fotografos();

            fotografos.FotografoId = 0;
            fotografos.UsuarioId   = 1;
            fotografos.Nombres     = "Frandy";
            fotografos.Apellidos   = "Mota";
            fotografos.Cedula      = "41223355889";
            fotografos.Direccion   = "Cotui";
            fotografos.Telefono    = "8093527799";
            fotografos.Celular     = "8092458037";
            fotografos.Sexo        = "Hombre";
            fotografos.Sueldo      = 100;

            Assert.IsTrue(FotografosBLL.Guardar(fotografos));
        }
        public void GuardarTest()
        {
            Fotografos fotografo = new Fotografos();

            fotografo.FotografoId     = 1;
            fotografo.UsuarioId       = 1;
            fotografo.Nombres         = "Fotografo Nombre Fotografo Apellido";
            fotografo.Cedula          = "111-1111111-1";
            fotografo.Direccion       = "Calle Fotografo, casa Fotografo";
            fotografo.Celular         = "+11231231234";
            fotografo.Telefono        = "+11231231225";
            fotografo.Email           = "*****@*****.**";
            fotografo.Sexo            = "Masculino";
            fotografo.FechaNacimiento = DateTime.Now;

            Assert.IsTrue(FotografosBLL.Guardar(fotografo));
        }
Beispiel #4
0
        public static Fotografos Buscar(int id)
        {
            Contexto   db         = new Contexto();
            Fotografos fotografos = new Fotografos();

            try
            {
                fotografos = db.Fotografos.Find(id);
            }
            catch
            {
                throw;
            }
            finally
            {
                db.Dispose();
            }
            return(fotografos);
        }
        private static bool Modificar(Fotografos fotografo)
        {
            Contexto contexto = new Contexto();
            bool     ok       = false;

            try
            {
                contexto.Entry(fotografo).State = EntityState.Modified;
                ok = contexto.SaveChanges() > 0;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                contexto.Dispose();
            }
            return(ok);
        }
        private static bool Insertar(Fotografos fotografo)
        {
            Contexto contexto = new Contexto();
            bool     ok       = false;

            try
            {
                contexto.Fotografos.Add(fotografo);
                ok = contexto.SaveChanges() > 0;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                contexto.Dispose();
            }
            return(ok);
        }
Beispiel #7
0
        private static bool Modificar(Fotografos fotografos)
        {
            Contexto db   = new Contexto();
            bool     paso = false;

            try
            {
                db.Entry(fotografos).State = EntityState.Modified;
                paso = (db.SaveChanges() > 0);
            }
            catch
            {
                throw;
            }
            finally
            {
                db.Dispose();
            }
            return(paso);
        }
Beispiel #8
0
        private static bool Insertar(Fotografos fotografos)
        {
            Contexto db   = new Contexto();
            bool     paso = false;

            try
            {
                if (db.Fotografos.Add(fotografos) != null)
                {
                    paso = (db.SaveChanges() > 0);
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                db.Dispose();
            }
            return(paso);
        }
Beispiel #9
0
        //Este evento busca un registro en la base de datos.
        private void BuscarButton_Click(object sender, RoutedEventArgs e)
        {
            //válida que haya un Id válido en el campo ClienteId.
            if (!Regex.IsMatch(FotografoIdTextBox.Text, "^[1-9]+$"))
            {
                MessageBox.Show("El Cliente Id solo puede ser de carácter numérico.", "Campo Cliente Id.",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            var encontrado = FotografosBLL.Buscar(int.Parse(FotografoIdTextBox.Text));

            if (encontrado != null)
            {
                Fotografo        = encontrado;
                this.DataContext = Fotografo;
            }
            else
            {
                MessageBox.Show("Puede ser que el Fotógrafo no este registrado en la base de datos.", "No se encontro el Fotógrafo.", MessageBoxButton.OK,
                                MessageBoxImage.Information);
            }
        }
Beispiel #10
0
 //Metodo limpiar.
 private void Limpiar()
 {
     Fotografo        = new Fotografos();
     this.DataContext = Fotografo;
 }