コード例 #1
0
        public int Insertar(Movimiento mov)
        {
            string f = String.Format("{0}-{1}-{2}", mov.Fecha.Substring(6), mov.Fecha.Substring(3, 2), mov.Fecha.Substring(0, 2));

            string vl = mov.Valor.ToString();

            decimal v1 = Convert.ToDecimal(vl, CultureInfo.CreateSpecificCulture("es-ES"));

            vl = vl.Replace(',', '.');
            MySqlConnection conection = Conexion.ObtenerConexion();
            MySqlCommand    comando   = new MySqlCommand(string.Format("Insert into movimientos (descMov, fecha, valor, idEvento, idCuenta) values ('{0}','{1}','{2}','{3}','{4}')",
                                                                       mov.DescMov, f, vl, mov.IdEvento, mov.IdCuenta), conection);

            int retorno = comando.ExecuteNonQuery();

            comando.Dispose();
            conection.Close();

            return(retorno);
        }
コード例 #2
0
        public Movimiento ObtenerMovimiento(int id)
        {
            Movimiento      mov       = new Movimiento();
            MySqlConnection conection = Conexion.ObtenerConexion();
            MySqlCommand    comando   = new MySqlCommand(String.Format("select idMov, descMov, valor, fecha, idCuenta, idEvento from movimientos where idMov='" + id + "'"), conection);
            MySqlDataReader codigos   = comando.ExecuteReader();

            while (codigos.Read())
            {
                mov.IdMov    = codigos.GetInt32(0);
                mov.DescMov  = codigos.GetString(1);
                mov.Valor    = Convert.ToDecimal(codigos.GetDouble(2));
                mov.Fecha    = codigos.GetString(3);
                mov.IdCuenta = codigos.GetInt32(4);
                mov.IdEvento = codigos.GetInt32(5);
            }

            comando.Dispose();
            conection.Close();

            return(mov);
        }