Help with filling gridview c # MVC

0

It turns out that I have an unsolved problem, I have a test project which shows me a field after assigning a value, so I assign a value to the field that shows in a gridview, this is in windows forms, when I pass it to seen why it should be web, I can not find the way to make it work, so I want it to be, to see if someone can guide me, thanks

Now I would like if you could assign this to the view and neecsito help, thanks

<body>
</body>
<div class="jumbotron">
    <form action="~/Home/First" />
    <form method="post">
        <div>Nombre archivo</div>
        <div><input type="text" name="txtNombreArchivo" /></div>
        <div>Cantidad tarjetas</div>
        <div><input type="text" name="txtCantidadTarjetas" /></div>
        <div>nombre Afiliado</div>
        <div><input type="text" name="txtNombreAfiliado" /></div>
        <div>BIN</div>
        <div><input type="text" name="txtBIN" /></div>
        <div>fecha vigencia</div>
        <div><input type="text" name="dtpFechaVigencia" /></div>
        <div>monto</div>
        <div><input type="text" name="txtMonto" /></div>
        <input type="submit" value="agregar" />
    </form>
</div>
        public void First(string txtNombreArchivo, string txtCantidadTarjetas, string txtNombreAfiliado, string txtBIN, DateTime dtpFechaVigencia, string txtTextoMonto, string txtMonto)
    {
        using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Insertar"].ToString()))
        {
            try
            {
                BC.Funciones funciones = new Funciones();

                if (!Directory.Exists(@"Respaldo"))
                {
                    Directory.CreateDirectory(@"Respaldo");
                }

                funciones.EscribirCSV("Numero Afiliado;Cuenta;Clave;Vigencia;Nombre afiliado;Texto;Track1 Banda;Track2 Banda;EAN13;BIN", int.Parse(txtCantidadTarjetas.ToString()), txtNombreArchivo.ToString());
                Random rnd = new Random();

                int consecutivo = 1;
                int random9 = rnd.Next(100000000, 999999999);

                int rowcount = int.Parse(txtCantidadTarjetas.ToString());



                TarjetaTicket[] tarjetaTickets = new TarjetaTicket[int.Parse(txtCantidadTarjetas.ToString())];
                for (int i = 0; i <= rowcount - 1; i++)
                {
                    BC.TarjetaTicket tarjetaTicket = new TarjetaTicket();
                    int nro1 = rnd.Next(10000000, 99999999);
                    int nro2 = rnd.Next(10000000, 99999999);
                    int clave = rnd.Next(1000, 9999);
                    int quince1 = rnd.Next(10000000, 99999999);
                    int quince2 = rnd.Next(1000000, 9999999);

                    string Track1 = "B" + nro1 + nro2 + "^    /                     ^" + random9.ToString();
                    string Track2 = nro1.ToString() + nro2.ToString() + "=" + quince1 + quince2;
                    funciones.EscribirCSV(consecutivo.ToString("0000") + ";" + nro1.ToString() + nro2.ToString() + ";" + clave + ";" + dtpFechaVigencia.ToString("yyyy-MM-dd").Substring(0, 10) +
                        ";" + txtNombreAfiliado.ToString() + ";" + txtTextoMonto.ToString() + ";" + Track1 + ";" + Track2 + ";" + nro1 + nro2.ToString().Substring(0, 4) + ";" + txtBIN.ToString(), int.Parse(txtCantidadTarjetas.ToString()), txtNombreArchivo.ToString());
                    consecutivo++;

                    tarjetaTicket.NumeroTarjeta = nro1.ToString() + nro2.ToString();
                    tarjetaTicket.FechaCreacionTarjeta = DateTime.Now;
                    tarjetaTicket.FechaVigenciaTarjeta = dtpFechaVigencia.Date;
                    tarjetaTicket.MontoTarjeta = txtMonto.ToString();
                    tarjetaTicket.HashOriginal = rnd.Next(100000, 999999).ToString();

                    tarjetaTickets[i] = tarjetaTicket;
                }


            string query = "INSERT INTO [mae_ticket] ([mti_nombre_ticket], [mti_total_tarjetas], [mti_fecha_creacion], [mti_nombre_afiliado], [mti_BIN])" +
                    " VALUES (@txtNombreArchivo, @txtCantidadTarjetas ,@txtNombreAfiliado, @txtBIN, @dtpFechaVigencia)";

                BC.Ticket ticket = new Ticket();
                ticket.NombreTicket = txtNombreArchivo.ToString();
                ticket.Bin = txtBIN.ToString();
                ticket.TotalTarjetas = int.Parse(txtCantidadTarjetas.ToString());
                ticket.FechaCreacionTicket = DateTime.Now;
                ticket.NombreAfiliado = txtNombreAfiliado.ToString();
                funciones.PoblarProceso(ticket, tarjetaTickets);

            /*    SqlCommand cmd = new SqlCommand(query, con);
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Parameters.AddWithValue("@txtNombreArchivo", txtNombreArchivo.ToString());
                cmd.Parameters.AddWithValue("@txtCantidadTarjetas", txtCantidadTarjetas.ToString());
                cmd.Parameters.AddWithValue("@txtNombreAfiliado", txtNombreAfiliado.ToString());
                cmd.Parameters.AddWithValue("@txtBIN", txtBIN.ToString());
                cmd.Parameters.AddWithValue("@dtpFechaVigencia", dtpFechaVigencia.ToString("yyyy-MM-dd"));
              //  cmd.Parameters.AddWithValue("@txtMonto", txtMonto.ToString());

                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();*/
            }
            catch (Exception ron)
            {
                Exception ex;
                //MessageBox.Show(ron.Message);
            }

        }
    }
    
asked by KonnAN 03.12.2018 в 16:34
source

0 answers