TarjetaModel BuscarTarjeta()
        {
            try
            {
                TarjetaModel tarjeta = new TarjetaModel();
                frmLista      = new FrmListaDatos();
                listaTarjetas = BLTarjeta.tarjetasSelectAll();
                frmLista.CrearLista <TarjetaModel>(listaTarjetas);
                if (frmLista.ShowDialog() == DialogResult.OK)
                {
                    tarjeta                  = listaTarjetas[frmLista.ObtenerIndice()];
                    txtTarjeta.Text          = "";
                    txtTarjeta.Text          = tarjeta.Numero.ToString();
                    cuentaUsuario.Id_tarjeta = int.Parse(tarjeta.Numero.Replace(" ", ""));

                    btnProceder.Enabled = true;
                }
                ;
                return(tarjeta);
            }
            catch (Exception)
            {
                MetroFramework.MetroMessageBox.Show(this, "Hubo un error");
                return(null);
            }
        }
Exemplo n.º 2
0
        private void buscarTarjetas(List <TarjetaModel> objetos)
        {
            string[][] orden = new string[3][];

            orden[0] = new string[] { "Numero", "Codigo", "100" };
            orden[1] = new string[] { "Fechavencimiento", "Fecha Vencimiento", "150" };
            orden[2] = new string[] { "Id_cuenta", "Cuenta Vinculada", "150" };

            if (objetos != null)
            {
                using (Ayuda.FormHelp2 formHelp1 = new Ayuda.FormHelp2())
                {
                    formHelp1.setList(objetos, orden);
                    formHelp1.ShowDialog();

                    if (formHelp1.EstaAceptado())
                    {
                        var dato = formHelp1.getObject <TarjetaModel>();
                        if (dato != null)
                        {
                            this.clearForm();
                            this.gtarjeta = this.BLTarjeta.Gettarjeta(dato.Numero);
                            this.tarjeta2gui(this.gtarjeta);
                            this.modoNuevo();
                            this.modoEdicion();
                        }
                    }
                }
            }
        }
 private void btnTarjeta_Click(object sender, EventArgs e)
 {
     Tarjeta = BuscarTarjeta();
     if (Tarjeta == null)
     {
         return;
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Saves a record to the tarjeta table.
        /// returns True if value saved successfully else false
        /// Throw exception with message value EXISTS if the data is duplicate
        /// </summary>
        public bool Insert(TarjetaModel atarjeta)
        {
            atarjeta.Numero = CrearNumeroTarjeta(atarjeta.Id_cuenta);
            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlTransaction sqlTran = connection.BeginTransaction();

                    SqlCommand command = connection.CreateCommand();

                    command.Transaction = sqlTran;

                    command.Parameters.AddWithValue("@Numero", atarjeta.Numero);
                    command.Parameters.AddWithValue("@Password", atarjeta.Password == null ? (object)DBNull.Value : atarjeta.Password);
                    command.Parameters.AddWithValue("@CodControl", atarjeta.Codcontrol);
                    command.Parameters.AddWithValue("@FechaVencimiento", atarjeta.Fechavencimiento == null ? (object)DBNull.Value : atarjeta.Fechavencimiento);
                    command.Parameters.AddWithValue("@FechaVinculacion", atarjeta.Fechavinculacion == null ? (object)DBNull.Value : atarjeta.Fechavinculacion);
                    command.Parameters.AddWithValue("@Estado", atarjeta.Estado);
                    command.Parameters.AddWithValue("@id_cuenta", atarjeta.Id_cuenta);
                    command.Parameters.AddWithValue("@FECHA_MODIFICACION", atarjeta.Fecha_modificacion == null ? (object)DBNull.Value : atarjeta.Fecha_modificacion);
                    command.Parameters.AddWithValue("@USUARIO_CREADOR", atarjeta.Usuario_creador);
                    command.Parameters.AddWithValue("@USUARIO_MODIFICADOR", atarjeta.Usuario_modificador == null ? (object)DBNull.Value : atarjeta.Usuario_modificador);
                    command.Parameters.AddWithValue("@FECHA_CREACION", atarjeta.Fecha_creacion);


                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "tarjetasInsert";

                    int afectados = command.ExecuteNonQuery();

                    // Commit the transaction.
                    sqlTran.Commit();

                    connection.Close();
                    connection.Dispose();

                    if (afectados > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                //throw;
                return(false);
            }
        }
Exemplo n.º 5
0
        private void tarjeta2gui(TarjetaModel atarjeta)
        {
            this.gcuenta = this.BLCuenta.Getcuenta(atarjeta.Id_cuenta);

            this.txtCodigo.Text            = atarjeta.Numero.ToString();
            this.txtCodigoControl.Text     = atarjeta.Codcontrol.ToString();
            this.txtPassword.Text          = atarjeta.Password.ToString();
            this.dtpFechaVencimiento.Value = (DateTime)atarjeta.Fechavencimiento;
            this.chkEstado.Checked         = atarjeta.Estado;
            this.txtCuenta.Text            = this.gcuenta.Nrocuenta;

            this.SlblUsuario_creador.Text     = atarjeta.Usuario_creador;
            this.SlblFecha_creacion.Text      = atarjeta.Fecha_creacion.ToLongDateString();
            this.SlblUsuario_modificador.Text = atarjeta.Usuario_modificador;
            this.SlblFecha_modificacion.Text  = atarjeta.Fecha_modificacion.ToString();
        }
Exemplo n.º 6
0
 /// <summary>
 /// Updates a record to the tarjeta table.
 /// returns True if value saved successfully else false
 /// Throw exception with message value EXISTS if the data is duplicate
 /// </summary>
 public bool Update(TarjetaModel atarjeta)
 {
     return(this.managerTarjeta.Update(atarjeta));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Saves a record to the tarjeta table.
 /// returns True if value saved successfully else false
 /// Throw exception with message value EXISTS if the data is duplicate
 /// </summary>
 public bool Insert(TarjetaModel atarjeta)
 {
     return(this.managerTarjeta.Insert(atarjeta));
 }
Exemplo n.º 8
0
        /// <summary>
        /// Selects the Single object of tarjeta table.
        /// </summary>
        public TarjetaModel Gettarjeta(String aNumero)
        {
            TarjetaModel tarjeta = null;

            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlCommand command = connection.CreateCommand();

                    command.Parameters.AddWithValue("@Numero", aNumero);


                    command.CommandType = CommandType.StoredProcedure;

                    command.CommandText = "tarjetasSelect";

                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            String   Numero              = (string)(reader["Numero"]);
                            int?     Password            = reader["Password"] as int?;
                            int      CodControl          = (int)(reader["CodControl"]);
                            DateTime?FechaVencimiento    = reader["FechaVencimiento"] as DateTime?;
                            DateTime?FechaVinculacion    = reader["FechaVinculacion"] as DateTime?;
                            bool     Estado              = (bool)(reader["Estado"]);
                            string   id_cuenta           = (string)(reader["id_cuenta"]);
                            DateTime?FECHA_MODIFICACION  = reader["FECHA_MODIFICACION"] as DateTime?;
                            string   USUARIO_CREADOR     = (string)(reader["USUARIO_CREADOR"]);
                            string   USUARIO_MODIFICADOR = reader["USUARIO_MODIFICADOR"] as string;
                            DateTime FECHA_CREACION      = (DateTime)(reader["FECHA_CREACION"]);

                            tarjeta = new TarjetaModel
                            {
                                Numero              = Numero,
                                Password            = Password,
                                Codcontrol          = CodControl,
                                Fechavencimiento    = FechaVencimiento,
                                Fechavinculacion    = FechaVinculacion,
                                Estado              = Estado,
                                Id_cuenta           = id_cuenta,
                                Fecha_modificacion  = FECHA_MODIFICACION,
                                Usuario_creador     = USUARIO_CREADOR,
                                Usuario_modificador = USUARIO_MODIFICADOR,
                                Fecha_creacion      = FECHA_CREACION,
                            };
                        }
                    }
                }

                return(tarjeta);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                return(null);
            }
        }
Exemplo n.º 9
0
 public async Task <List <Log> > GetLogsAsync()
 {
     return(await TarjetaModel.GetLogsAsync());
 }
Exemplo n.º 10
0
 public async Task <string> GuardarIdTarjeta(string ip, string id_tarjeta, string resultado)
 {
     return(await TarjetaModel.GuardarLogRFID(ip, id_tarjeta, resultado));
 }