Ejemplo n.º 1
0
        //para consultar todos
        public List<clsCliente> Consultar()
        {
            try
            {
                List<clsCliente> listaCliente = new List<clsCliente>();
                TallerEntities ent = new TallerEntities();
                var con = from w in ent.Persona select w;
                foreach (var item in con)
                {
                    clsCliente e = new clsCliente();
                    e.IdPersona = item.IdPersona;
                    e.Identificacion = item.Identificacion;
                    e.IdTipoPersona = item.IdTipoPersona;
                    e.Nombre = item.NombreRazonSocial;
                    e.Apellido = item.Apellido;
                    e.FechaNacimiento = item.FechaNacimiento;
                    e.Genero = item.Genero;
                    e.TipoIdentificacion = item.TipoIdentificacion;
                    e.Direccion = item.Direccion;
                    e.Telefono = item.Telefono;
                    e.Mail = item.Mail;
                    e.idEstado = item.IdEstado;
                    e.idEmpresa = item.IdEmpresa;
                    listaCliente.Add(e);
                }
                return listaCliente;

            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                Console.WriteLine("Error datTipoTrabajo: " + ex);
                return null;
            }
        }
Ejemplo n.º 2
0
        public bool Eliminar(clsCliente e)
        {
            try
            {
                using (TallerEntities ent = new TallerEntities())
                {
                    //busca por PK el primero que encuentre lo coge
                    var x = (from a in ent.Persona where a.Identificacion == e.Identificacion select a).First();
                    ent.DeleteObject(x);//elimina el registro
                    ent.SaveChanges();
                }
                return true;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Eliminar Error: " + ex);
                return false;

            }
        }
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            frmConsultarCliente f = new frmConsultarCliente();
            f.ShowDialog();
            oCliente = f.e;
            txtIdentificacion.Text = Convert.ToString(oCliente.Identificacion);
            cbxTipoPersona.SelectedItem = oDatCliente.getDescripcionSegunIdTipoPersona(oCliente.IdTipoPersona);
            txtNombre.Text = oCliente.Nombre;
            txtApellido.Text = oCliente.Apellido;
            cbxFechaNacimiento.Text = Convert.ToString(oCliente.FechaNacimiento);
            cbxGenero.SelectedItem = oCliente.Genero;
            cbxTipoIdentificacion.SelectedItem = oDatCliente.getDescripcionSegunIdTipoIdentificacion(oCliente.TipoIdentificacion);
            txtDireccion.Text = oCliente.Direccion;
            txtTelefono.Text = Convert.ToString(oCliente.Telefono);
            txtMail.Text = Convert.ToString(oCliente.Mail);

            if (oCliente.idEstado == 1)
            {
                cbxEstado.SelectedItem = "Activa";
            }
            else
            {
                cbxEstado.SelectedItem = "Inactiva";
            }

            oCliente.idEmpresa = 1;
        }
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            frmConsultarCliente f = new frmConsultarCliente();
            f.ShowDialog();
            oCliente = f.e;

            if (oCliente.IdPersona == 0)
            {
                borrar();
            }
            else
            {
                txtCodigo.Text = Convert.ToString(oCliente.IdPersona);
                txtIdentificacion.Text = oCliente.Identificacion;
                cbxTipoPersona.EditValue = oDatCliente.getDescripcionSegunIdTipoPersona(oCliente.IdTipoPersona);
                txtNombre.Text = oCliente.Nombre;
                txtApellido.Text = oCliente.Apellido;
                cbxFechaNacimiento.Text = Convert.ToString(oCliente.FechaNacimiento.ToShortDateString());
                cbxGenero.SelectedItem = oCliente.Genero;
                cbxTipoIdentificacion.EditValue = oDatCliente.getDescripcionSegunIdTipoIdentificacion(oCliente.TipoIdentificacion);
                txtDireccion.Text = oCliente.Direccion;
                txtTelefono.Text = oCliente.Telefono;
                txtMail.Text = Convert.ToString(oCliente.Mail);

                if (oCliente.idEstado == 1)
                {
                    cbxEstado.SelectedItem = "Activo";
                }
                else if (oCliente.idEstado == 2)
                {
                    cbxEstado.SelectedItem = "Inactivo";
                }

                oCliente.idEmpresa = 1;

                btnGuardar.Enabled = false;
                btnModificar.Enabled = true;
                btnEliminar.Enabled = true;
            }
        }
Ejemplo n.º 5
0
 public bool Modificar(clsCliente e)
 {
     try
     {
         using (TallerEntities ent = new TallerEntities())
         {
             //busca por PK el primero que encuentre lo coge
             var x = (from a in ent.Persona where a.IdPersona == e.IdPersona select a).First();
                 x.Identificacion = e.Identificacion;
                 x.IdTipoPersona = e.IdTipoPersona;
                 x.NombreRazonSocial = e.Nombre;
                 x.Apellido = e.Apellido;
                 x.FechaNacimiento = e.FechaNacimiento;
                 x.Genero = e.Genero;
                 x.TipoIdentificacion = e.TipoIdentificacion;
                 x.Direccion = e.Direccion;
                 x.Telefono = e.Telefono;
                 x.Mail = e.Mail;
                 x.IdEstado = e.idEstado;
                 x.IdEmpresa = e.idEmpresa;
             ent.SaveChanges();
         }
         return true;
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error: " + ex);
         return false;
     }
 }
Ejemplo n.º 6
0
 public bool Guardar(clsCliente e)
 {
     try
     {
         int id = getIdSiguiente();
         e.IdPersona = id;
         using (TallerEntities ent = new TallerEntities())
         { //se instancia el entity para poder usar los nombres de las tablas
             Persona persona = new Persona()
             {
                 IdPersona = e.IdPersona,
                 Identificacion = e.Identificacion,
                 IdTipoPersona = e.IdTipoPersona,
                 NombreRazonSocial = e.Nombre,
                 Apellido = e.Apellido,
                 FechaNacimiento = e.FechaNacimiento,
                 Genero = e.Genero,
                 TipoIdentificacion = e.TipoIdentificacion,
                 Direccion = e.Direccion,
                 Telefono = e.Telefono,
                 Mail = e.Mail,
                 IdEstado = e.idEstado,
                 IdEmpresa = e.idEmpresa
             };
             ent.AddToPersona(persona);
             ent.SaveChanges();
         }
         return true;
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error al guardar: " + ex);
         Console.Read();
         return false;
     }
 }
 private void btnBuscarCliente_Click(object sender, EventArgs e)
 {
     frmConsultarCliente f = new frmConsultarCliente();
     f.ShowDialog();
     oCliente = f.e;
     txtPropietario.Text = oCliente.Nombre+" "+oCliente.Apellido;
 }