private void BuscarClientes()
 {
     try
     {
         int    result  = 0;
         string caturar = Interaction.InputBox("Ingresa el codigo del Cliente", EntidadNegocio.Entidades.Mensajes.Titulo_Guardar, "1");
         if (String.IsNullOrEmpty(caturar))
         {
             MessageBox.Show("Introduzca un valor numerico", EntidadNegocio.Entidades.Mensajes.Titulo_Advertencia, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             this.Cancelar();
         }
         else if (Int32.TryParse(caturar, out result))
         {
             _cliente = new EntidadNegocio.Entidades.Cliente();
             _cliente = _ctrlCliente.Details(result);
             LimpiarCampos(); LlenarComboEstatus(); MostrarDatos();
             this.ControlBotonesMenu(EntidadNegocio.Enumerados.EnumTipos.AccionMenu.Buscar);
         }
         else
         {
             MessageBox.Show("El valor no es numerico, introduzca un valor numerico", EntidadNegocio.Entidades.Mensajes.Titulo_Advertencia, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             this.Cancelar();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 2
0
 public List <EntidadNegocio.Entidades.Cliente> ObtenerItems()
 {
     try
     {
         List <Dato.Modelo.Cliente> _ListC = null;
         List <EntidadNegocio.Entidades.Cliente> _ListCE = new List <EntidadNegocio.Entidades.Cliente>();
         EntidadNegocio.Entidades.Cliente        _cE     = null;
         _ListC = (List <Dato.Modelo.Cliente>)db.ClienteSet.ToList();
         foreach (Dato.Modelo.Cliente element in _ListC)
         {
             _cE               = new EntidadNegocio.Entidades.Cliente();
             _cE.ID            = element.ID;
             _cE.Nombre        = element.Nombre;
             _cE.Telefono      = element.Telefono;
             _cE.Correo        = element.Correo;
             _cE.Direccion     = element.Direccion;
             _cE.NumAlquileres = 0;
             if (element.Estatus == 1)
             {
                 _cE.Status = EntidadNegocio.Enumerados.EnumEstatus.Registro.Activo;
             }
             else
             {
                 _cE.Status = EntidadNegocio.Enumerados.EnumEstatus.Registro.Inactivo;
             }
             _cE.Edicion = EntidadNegocio.Enumerados.EnumEstatus.Edicion.Normal;
             _ListCE.Add(_cE);
         }
         return(_ListCE);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 3
0
 public EntidadNegocio.Entidades.Cliente Details(int id)
 {
     Dato.Modelo.Cliente _cliente = new Dato.Modelo.Cliente();
     if (id == 0)
     {
         _cliente = new Dato.Modelo.Cliente();
     }
     else
     {
         _cliente = db.ClienteSet.First(c => c.ID == id);
     }
     EntidadNegocio.Entidades.Cliente clienteDetail = new EntidadNegocio.Entidades.Cliente();
     clienteDetail.ID            = _cliente.ID;
     clienteDetail.Nombre        = _cliente.Nombre;
     clienteDetail.Telefono      = _cliente.Telefono;
     clienteDetail.Correo        = _cliente.Correo;
     clienteDetail.Direccion     = _cliente.Direccion;
     clienteDetail.NumAlquileres = 0;
     if (_cliente.Estatus == 1)
     {
         clienteDetail.Status = EntidadNegocio.Enumerados.EnumEstatus.Registro.Activo;
     }
     else
     {
         clienteDetail.Status = EntidadNegocio.Enumerados.EnumEstatus.Registro.Inactivo;
     }
     return(clienteDetail);
 }
Ejemplo n.º 4
0
 public EntidadNegocio.Entidades.Cliente DetailsClinetePorPagar(int id)
 {
     Dato.Modelo.Cantidad_Alquileres_Por_Pagar_VW _cliente = new Dato.Modelo.Cantidad_Alquileres_Por_Pagar_VW();
     if (id == 0)
     {
         _cliente = new Dato.Modelo.Cantidad_Alquileres_Por_Pagar_VW();
     }
     else
     {
         _cliente = dbVW.Cantidad_Alquileres_Por_Pagar_VW_Set.First(c => c.IDCliente == id);
     }
     EntidadNegocio.Entidades.Cliente clienteDetail = new EntidadNegocio.Entidades.Cliente();
     clienteDetail.ID            = _cliente.IDCliente;
     clienteDetail.Nombre        = _cliente.Nombre;
     clienteDetail.Telefono      = _cliente.Telefono;
     clienteDetail.Correo        = _cliente.Correo;
     clienteDetail.Direccion     = _cliente.Direccion;
     clienteDetail.NumAlquileres = _cliente.NumAlquiler ?? 0;
     if (_cliente.Estatus == 1)
     {
         clienteDetail.Status = EntidadNegocio.Enumerados.EnumEstatus.Registro.Activo;
     }
     else
     {
         clienteDetail.Status = EntidadNegocio.Enumerados.EnumEstatus.Registro.Inactivo;
     }
     return(clienteDetail);
 }
Ejemplo n.º 5
0
 private void MostrarDatos()
 {
     try
     {
         this.txtID.Text = Convert.ToString(_idPagoCab.ToString());
         _cliente        = _ctrlCliente.DetailsClinetePorPagar(_idCliente);
         if (_pago.Edicion == EntidadNegocio.Enumerados.EnumEstatus.Edicion.Nuevo)
         {
             _pago         = _ctrlPago.Details(_idCliente);
             _pago.Edicion = EntidadNegocio.Enumerados.EnumEstatus.Edicion.Nuevo;
         }
         else
         {
             _pago = _ctrlPago.Details(_idCliente);
         }
         this.cmbCliente.Text     = _cliente.Nombre;
         this.dtpFecha.Value      = _pago.Fecha;
         this.lblRows.Text        = "DataGrid - Rows: " + _cliente.NumAlquileres.ToString();
         this.txtDescuento.Text   = _pago.Descuento.ToString();
         this.txtTotal.Text       = _pago.MontoTotal.ToString();
         this.lblMontoExento.Text = _pago.MontoExento.ToString();
         this.cmbEstatus.Text     = _pago.Status.ToString();
         CargarProducto(); CargarAlquilerPorPagar(); MostrarAlquilerPorPagar();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, EntidadNegocio.Entidades.Mensajes.Titulo_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 6
0
        public Boolean Create(EntidadNegocio.Entidades.Cliente _cliente)
        {
            Dato.Modelo.Cliente clienteToAdd = new Dato.Modelo.Cliente();
            Boolean             resul        = false;

            clienteToAdd.ID        = _cliente.ID;
            clienteToAdd.Nombre    = _cliente.Nombre;
            clienteToAdd.Telefono  = _cliente.Telefono;
            clienteToAdd.Correo    = _cliente.Correo;
            clienteToAdd.Direccion = _cliente.Direccion;
            if (_cliente.Status == EntidadNegocio.Enumerados.EnumEstatus.Registro.Activo)
            {
                clienteToAdd.Estatus = 1;
            }
            else
            {
                clienteToAdd.Estatus = 0;
            }

            //valido claves primaria
            if (db.ClienteSet.FirstOrDefault(c => c.ID == clienteToAdd.ID) != null)
            {
                MessageBox.Show(EntidadNegocio.Entidades.Mensajes.Info_ErrorAlGuardarViolacionPK, EntidadNegocio.Entidades.Mensajes.Titulo_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (db.Connection.State != System.Data.ConnectionState.Open)
                {
                    db.Connection.Open();
                }

                DbTransaction dbTransaction = db.Connection.BeginTransaction();

                try
                {
                    // Guardar y confirmar el cliente.
                    db.AddToClienteSet(clienteToAdd);
                    db.SaveChanges();
                    dbTransaction.Commit();
                    /// Si la transaccion es exitosa enviamos true
                    Dato.Modelo.Cliente _entidadToIDAdd = db.ClienteSet.ToList().LastOrDefault();
                    Int32 _id = _entidadToIDAdd.ID;
                    _entidadToIDAdd.ID = _id;
                    resul = true;
                }
                catch (Exception ex)
                {
                    dbTransaction.Rollback();
                    HandleException excepcion = new HandleException();
                    String          msjLog    = "Error en " + ObtenerMetodoEnEjecucion(false).ToString() + ".\n" + excepcion.RegistrarExcepcion(ex, ObtenerMetodoEnEjecucion(false).ToString());
                    excepcion.EscribirLogExcepcion(msjLog); String clientMessage = excepcion.HandleExceptionEx(ex); excepcion = null;
                    resul = false;
                }
            }

            return(resul);
        }
Ejemplo n.º 7
0
        public Boolean Delete(EntidadNegocio.Entidades.Cliente _cliente)
        {
            Int32 id = _cliente.ID; Boolean resul = false;

            Dato.Modelo.Cliente clienteToDelete = db.ClienteSet.First(c => c.ID == id);

            clienteToDelete.ID        = _cliente.ID;
            clienteToDelete.Nombre    = _cliente.Nombre;
            clienteToDelete.Telefono  = _cliente.Telefono;
            clienteToDelete.Correo    = _cliente.Correo;
            clienteToDelete.Direccion = _cliente.Direccion;
            if (_cliente.Status == EntidadNegocio.Enumerados.EnumEstatus.Registro.Activo)
            {
                clienteToDelete.Estatus = 1;
            }
            else
            {
                clienteToDelete.Estatus = 0;
            }

            //valido cliente tiene alquiler
            if (db.AlquilerSet.FirstOrDefault(b => b.IDCliente == id) != null)
            {
                MessageBox.Show(String.Format("Esta intentando Borrar un cliente que tiene un Alquiler"), EntidadNegocio.Entidades.Mensajes.Titulo_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (db.Connection.State != System.Data.ConnectionState.Open)
                {
                    db.Connection.Open();
                }

                DbTransaction dbTransaction = db.Connection.BeginTransaction();

                try
                {
                    // Delete
                    db.DeleteObject(clienteToDelete);
                    db.SaveChanges();
                    dbTransaction.Commit();
                    /// Si la transaccion es exitosa enviamos true
                    resul = true;
                }
                catch (Exception ex)
                {
                    dbTransaction.Rollback();
                    HandleException excepcion = new HandleException();
                    String          msjLog    = "Error en " + ObtenerMetodoEnEjecucion(false).ToString() + ".\n" + excepcion.RegistrarExcepcion(ex, ObtenerMetodoEnEjecucion(false).ToString());
                    excepcion.EscribirLogExcepcion(msjLog); String clientMessage = excepcion.HandleExceptionEx(ex); excepcion = null;
                    resul = false;
                }
            }

            return(resul);
        }
 public frmCliente(int idcliente)
 {
     InitializeComponent();
     _ctrlCliente = new LogicaNegocio.ClienteController();
     _cliente     = new EntidadNegocio.Entidades.Cliente();
     _idcliente   = idcliente;
     this.mstpItemCancelar.Visible  = false;
     this.mstpItemEliminar.Visible  = false;
     this.mstpItemModificar.Visible = false;
     this.mstpItemNuevo.Visible     = false;
     txtCodigo.TabIndex             = 0;
 }
Ejemplo n.º 9
0
        public Boolean Edit(EntidadNegocio.Entidades.Cliente _cliente)
        {
            Int32 id = _cliente.ID; Boolean resul = false;

            Dato.Modelo.Cliente clienteToUpdate = db.ClienteSet.First(c => c.ID == id);

            clienteToUpdate.ID        = _cliente.ID;
            clienteToUpdate.Nombre    = _cliente.Nombre;
            clienteToUpdate.Telefono  = _cliente.Telefono;
            clienteToUpdate.Correo    = _cliente.Correo;
            clienteToUpdate.Direccion = _cliente.Direccion;
            if (_cliente.Status == EntidadNegocio.Enumerados.EnumEstatus.Registro.Activo)
            {
                clienteToUpdate.Estatus = 1;
            }
            else
            {
                clienteToUpdate.Estatus = 0;
            }

            if (db.Connection.State != System.Data.ConnectionState.Open)
            {
                db.Connection.Open();
            }

            DbTransaction dbTransaction = db.Connection.BeginTransaction();

            try
            {
                // Guardar y confirmar el cliente.
                db.SaveChanges();
                dbTransaction.Commit();
                /// Si la transaccion es exitosa enviamos true
                resul = true;
            }
            catch (Exception ex)
            {
                dbTransaction.Rollback();
                HandleException excepcion = new HandleException();
                String          msjLog    = "Error en " + ObtenerMetodoEnEjecucion(false).ToString() + ".\n" + excepcion.RegistrarExcepcion(ex, ObtenerMetodoEnEjecucion(false).ToString());
                excepcion.EscribirLogExcepcion(msjLog); String clientMessage = excepcion.HandleExceptionEx(ex); excepcion = null;
                resul = false;
            }

            return(resul);
        }
 public frmCliente()
 {
     InitializeComponent();
     _ctrlCliente = new LogicaNegocio.ClienteController();
     _cliente     = new EntidadNegocio.Entidades.Cliente();
 }