ASESORIAS EN LINEA
ASESORIAS EN LINEA
TRUCOS Y CODIGOS FUENTES
  
Ejemplo de envio de datos
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Cliente
{
public partial class AltasProductos : Form
{
public AltasProductos()
{
InitializeComponent();
}
string Id;
ClassLibrary1.Productos ope = new ClassLibrary1.Productos();

public void buscar(string dato) {
DataTable dtx= ope.buscar(dato);
try
{
textBox1.Text = dtx.Rows[0][0].ToString() ;
textBox2.Text = dtx.Rows[0][1].ToString ();
textBox3.Text = dtx.Rows[0][2].ToString ();
textBox4.Text = dtx.Rows[0][3].ToString ();
textBox5.Text = dtx.Rows[0][4].ToString ();
textBox6.Text = dtx.Rows[0][5].ToString ();
textBox7.Text = dtx.Rows[0][6].ToString ();
mostrar();

}
catch { MessageBox.Show("No existe el registro Buscado"); }

}

public void actualizar() {
Boolean x = ope.Actualiza(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text, textBox6.Text, textBox7.Text);
if (x== true)
{
MessageBox.Show("Operación Exitosa");

}
else
MessageBox.Show("Operación no exitosa");


}
public void mostrar() {
DataTable resultado;

resultado = ope.MostrarGeneral ();
dataGridView1.DataSource = resultado;


}



public void guardar()
{
Boolean a = ope.inserta(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text, textBox6.Text, textBox7.Text);

if (a == true)
{
MessageBox.Show("Operación Exitosa");
mostrar();
}
else
MessageBox.Show("Operación no exitosa");
mostrar();
}
public void eliminar()
{
DialogResult reply = MessageBox.Show("¿ Estas seguro que deseas eliminar \n el registro actual?", "Eliminar Registro",
MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (reply == DialogResult.Yes)
{
Boolean V;

V = ope.Eliminar(textBox1.Text);
if (V == true)
{
MessageBox.Show("Registro eliminado", "Sistema",
MessageBoxButtons.OK, MessageBoxIcon.Information);
mostrar();

}
else
{
MessageBox.Show("Registro no se pudo eliminar \n o no se encontró en la base de datos", "Sistema",
MessageBoxButtons.OK, MessageBoxIcon.Information);

mostrar();
}

}
}
private void guardarToolStripMenuItem_Click(object sender, EventArgs e)
{
guardar();

}

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
textBox1.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString();
textBox2.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString();
textBox3.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString();
textBox4.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString();
textBox5.Text = dataGridView1.CurrentRow.Cells[4].Value.ToString();
textBox6.Text = dataGridView1.CurrentRow.Cells[5].Value.ToString();
textBox7.Text = dataGridView1.CurrentRow.Cells[6].Value.ToString();
}

private void AltasProductos_Load(object sender, EventArgs e)
{
textBox7.Text = Form1.NOMBRE_USUARIO;
textBox7.Enabled = false;
mostrar();

}

private void eliminarToolStripMenuItem_Click(object sender, EventArgs e)
{
actualizar();
}

private void buscarToolStripMenuItem_Click(object sender, EventArgs e)
{
buscar(textBox1.Text );
}

private void eliminarToolStripMenuItem1_Click(object sender, EventArgs e)
{
eliminar();
}

private void refrescarToolStripMenuItem_Click(object sender, EventArgs e)
{
mostrar();
}

private void salirToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}

private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
eliminar();

}
}
}
}
Conéctate o Regístrate
Email:
Contraseña:
Mantener conexión
Registrarse
Usuarios más activos
ADRIANA LANDERO SUAREZ
ADRIANA
 
7 Comentarios
Mapa de visitas
Estadísticas
Nº Páginas Vistas
2024 Topforo.com | Aviso legal | Uso de cookies | Hacer foro | Foros Informática e internet