manual de shine system

14
INSTITUTO TECNOLOGICO SUPERIOR DE LERDO MANUAL DE USO DEL SISTEMA SHINE SYSTEM EN C# ALUMNO: RAFAEL ALFREDO QUINTANA HERRADA MATERIA: TALLER DE BASE DE DATOS PROFESOR: RICARDO BUSTAMANTE GONZÁLEZ Lunes 24 de mayo de 2010

Upload: rafa

Post on 28-May-2015

664 views

Category:

Documents


2 download

DESCRIPTION

huhuh

TRANSCRIPT

Page 1: Manual de shine system

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

MANUAL DE USO DEL SISTEMA SHINE SYSTEM EN C#

ALUMNO:

RAFAEL ALFREDO QUINTANA HERRADA

MATERIA:

TALLER DE BASE DE DATOS

PROFESOR:

RICARDO BUSTAMANTE GONZÁLEZ

Lunes 24 de mayo de 2010

Page 2: Manual de shine system

1.- Como primera interfaz tenemos el form principal

El cual contiene un pictureboox, 2 labels y 1 progressbar, esta forma también tendremos

un timer el cual tendrá el siguiente código;

private void timer1_Tick(object sender, EventArgs e)

{

progressBar1.Maximum = 100;

progressBar1.Value++;

if (progressBar1.Value == 100)

{

timer1.Stop();

MessageBox.Show("BASE DE DATOS CONECTADA");

Form2 ventana = new Form2();

this.Hide();

ventana.Show();

}

}

y en la load form contendra el siguiente codigo;

private void Form1_Load(object sender, EventArgs e)

{

timer1.Start();

con = new System.Data.SqlClient.SqlConnection();

con.ConnectionString = " Data

Source=RAFA1\\SQLEXPRESS;AttachDbFilename=I:\\Programas\\Shine System\\Shine

System\\Negocio.mdf;Integrated Security=True";

try

{

con.Open();

con = new System.Data.SqlClient.SqlConnection();

con.ConnectionString = " Data

Source=RAFA1\\SQLEXPRESS;AttachDbFilename=I:\\Programas\\Shine System\\Shine

System\\Negocio.mdf;Integrated Security=True";

con.Close();

}

catch

{

MessageBox.Show("BASE DE DATOS NO CONECTADA");

}

}

Page 3: Manual de shine system

2.- el segundo form tiene la siguiente interfaz

La siguiente forma está compuesta por 4 pictureboox y 1 label oculto, cada pictureboox

representa cada una de las opciones de nuestro sistema, en orden de izquierda a

derecha tenemos la opción “entrar al login”,”registrar usuario”, “Modificar Usuario” y

“cerrar”

3.- para la animación de los pictureboox es necesario activar los eventos mousmovie y

mouseleave ejemplo;

private void pictureBox3_MouseMove(object sender, MouseEventArgs e)

{

pictureBox7.Visible = false;

}

private void pictureBox3_MouseLeave(object sender, EventArgs e)

{

pictureBox7.Visible = true;

pictureBox3.Visible = false;

}

4.- en el evento mouse clic de cada uno de los pictureboox

En el evento click de “entrar al login” contendrá el siguiente código;

private void pictureBox3_Click_1(object sender, EventArgs e)

{

if (label1.Text == "0")

{

Form7 vent = new Form7();

this.Close();

vent.ShowDialog();

}

else

{

Form23 vent = new Form23();

this.Close();

vent.ShowDialog();

}

}

Page 4: Manual de shine system

En el evento click de “Agregar usuario” contendrá el siguiente código;

private void pictureBox1_Click(object sender, EventArgs e)

{

if (label1.Text == "0")

{

MessageBox.Show("NO PUEDES AGREGAR... LA BASE DE DATOS ESTA VACIA");

}

else

{

Form20 vent = new Form20();

this.Close();

vent.ShowDialog();

}

}

En el evento click de “modificar usuario” contendrá el siguiente código;

private void pictureBox2_Click(object sender, EventArgs e)

{

if (label1.Text == "0")

{

MessageBox.Show("No Existe Ningun Usuario En La Base De Datos ");

}

else

{

Form20 vent = new Form20();

this.Close();

vent.ShowDialog();

}

}

En el evento click de “Cerrar” contendrá el siguiente código;

private void pictureBox4_Click(object sender, EventArgs e)

{

this.Close();

Application.Exit();

}

EN LA FORMA 3 TENDREMOS LA SIGUIENTE INTERFAZ;

La forma 3 está compuesta por 4 labels, 3 textbox y un botón “Aceptar”.

Page 5: Manual de shine system

El botón aceptar contiene el siguiente código;

if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")

{

MessageBox.Show("Faltan datos por llenar");

}

else

{

// abriendo la conexion o enlace

con = new System.Data.SqlClient.SqlConnection();

con.ConnectionString = " Data

Source=RAFA1\\SQLEXPRESS;AttachDbFilename=I:\\Programas\\Shine System\\Shine

System\\Negocio.mdf;Integrated Security=True";

if (condicion == 1)

{

string buscar = "SELECT * from usuarios where usuario= '" + textBox1.Text +

"'";

ORDEN = new SqlCommand(buscar, con);

ORDEN.Connection.Open();

ORDEN.ExecuteNonQuery();

reader = ORDEN.ExecuteReader();

reader.Read();

if (reader.HasRows)

{

MessageBox.Show("El Usuario " + textBox1.Text + " ya existe Ingresa Otro

Nombre");

textBox1.Text = "";

}

else

{

if (textBox2.Text == textBox3.Text)

{

// abriendo la conexion o enlace

con = new System.Data.SqlClient.SqlConnection();

con.ConnectionString = " Data

Source=RAFA1\\SQLEXPRESS;AttachDbFilename=I:\\Programas\\Shine System\\Shine

System\\Negocio.mdf;Integrated Security=True";

string q = "insert into usuarios(usuario,clave)

values(@usuario,@clave)";

SqlCommand ORDEN1 = new SqlCommand(q, con);

ORDEN1 = new SqlCommand(q, con);

ORDEN1.Parameters.Add(new SqlParameter("@usuario", textBox1.Text));

ORDEN1.Parameters.Add(new SqlParameter("@clave", textBox2.Text));

ORDEN1.Connection.Open();

ORDEN1.ExecuteNonQuery();

ORDEN1.Connection.Close();

MessageBox.Show("El Usuario " + textBox1.Text + " se registro con

exito");

textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = "";

Form4 ven = new Form4();

this.Close();

ven.ShowDialog();

}

else

{

MessageBox.Show("La contraseña no Coincide");

textBox2.Text = ""; textBox3.Text = "";

}

}

Page 6: Manual de shine system

En la forma 4 (PRINCIPAL) tenemos la siguiente interfaz;

La cual contiene 6 pictureboox los cuales de izquierda a derecha son “clientes”,

“Proveedores”, “Productos”, “Ventas”, “cerrar Sesión”, “Salir”

El pictureboox “cliente” contiene el siguiente código;

private void pictureBox1_Click(object sender, EventArgs e)

{

Form5 ven = new Form5();

this.Close();

ven.ShowDialog();

}

El pictureboox “Proveedor” contiene el siguiente código;

private void pictureBox3_Click(object sender, EventArgs e)

{

Form11 vent = new Form11();

this.Close();

vent.ShowDialog();

}

El pictureboox “Productos” contiene el siguiente código;

private void pictureBox5_Click(object sender, EventArgs e)

{

Form15 vent = new Form15();

this.Close();

vent.ShowDialog();

}

El pictureboox “Ventas” contiene el siguiente código;

private void pictureBox10_Click(object sender, EventArgs e)

{

Form19 vent = new Form19();

this.Close();

vent.ShowDialog();

}

Page 7: Manual de shine system

El pictureboox “Cerrar Sesión” contiene el siguiente código;

private void pictureBox12_Click(object sender, EventArgs e)

{

Form2 vent = new Form2();

this.Close();

vent.Show();

}

El pictureboox “Cerrar” contiene el siguiente código;

private void pictureBox7_Click(object sender, EventArgs e)

{

this.Close();

Application.Exit();

}

El form 5 contiene la siguiente interfaz

El cual contiene 4 pictureboox, el cual de izquierda a derecha son “Altas”, “Bajas” y

“Cambios”;

Altas de los clientes;

El cual tendrá los siguientes componentes 11 labels y 11 textbox con 2 pictureboox en la parte

inferior

Page 8: Manual de shine system

El pictureboox 1 contiene el siguiente código

// Altas de los clientes

private void pictureBox1_Click(object sender, EventArgs e)

{

if (textBox6.Text == "" || textBox1.Text == "" || textBox2.Text == "" ||

textBox5.Text == "" || textBox7.Text == "" || textBox8.Text == "" || textBox9.Text == "" ||

textBox3.Text == "" || textBox23.Text == "")

{

MessageBox.Show("Faltan datos por llenar");

}

else

{

// abriendo la conexion o enlace

con = new System.Data.SqlClient.SqlConnection();

con.ConnectionString = " Data

Source=RAFA1\\SQLEXPRESS;AttachDbFilename=I:\\Programas\\Shine System\\Shine

System\\Negocio.mdf;Integrated Security=True";

string q = "insert into

Clientes(Id_cte,Nombre,Apellido_Paterno,Apellido_Materno,Direccion,Calle,Edo,E_mail,Telefono

,Edad,C_P)

values(@Id_cte,@Nombre,@Apellido_Paterno,@Apellido_Materno,@Direccion,@Calle,@Edo,@E_mail,@T

elefono,@Edad,@C_P)";

SqlCommand ORDEN = new SqlCommand(q, con);

ORDEN = new SqlCommand(q, con);

ORDEN.Parameters.Add(new SqlParameter("@Id_cte", textBox6.Text));

ORDEN.Parameters.Add(new SqlParameter("@nombre", textBox1.Text));

ORDEN.Parameters.Add(new SqlParameter("@Apellido_Paterno", textBox2.Text));

ORDEN.Parameters.Add(new SqlParameter("@Apellido_Materno", textBox3.Text));

ORDEN.Parameters.Add(new SqlParameter("@Direccion", textBox7.Text));

ORDEN.Parameters.Add(new SqlParameter("@Calle", textBox8.Text));

ORDEN.Parameters.Add(new SqlParameter("@Edo", textBox9.Text));

ORDEN.Parameters.Add(new SqlParameter("@E_mail", textBox10.Text));

ORDEN.Parameters.Add(new SqlParameter("@Telefono", textBox11.Text));

ORDEN.Parameters.Add(new SqlParameter("@Edad", textBox23.Text));

ORDEN.Parameters.Add(new SqlParameter("@C_P", textBox5.Text));

ORDEN.Connection.Open();

ORDEN.ExecuteNonQuery();

ORDEN.Connection.Close();

MessageBox.Show("El Usuario " + textBox1.Text + " " + textBox2.Text + " se

registro con exito");

textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox23.Text =

""; textBox5.Text = "";

textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = ""; textBox10.Text =

""; textBox11.Text = ""; Form4 ven = new Form4();

Form4 vent = new Form4();

this.Close();

ven.Show();

}

}

El form load contiene el siguiente código;

Page 9: Manual de shine system

private void Form6_Load(object sender, EventArgs e)

{

con = new System.Data.SqlClient.SqlConnection();

con.ConnectionString = " Data

Source=RAFA1\\SQLEXPRESS;AttachDbFilename=I:\\Programas\\Shine System\\Shine

System\\Negocio.mdf;Integrated Security=True";

try

{

con.Open();

string Sql = "SELECT Count(Id_cte) FROM Clientes";

SqlCommand aux = new SqlCommand(Sql, con);

int numRegistros = ((int)aux.ExecuteScalar()) + 1;

con.Close();

label1.Text = "Registros: " + (numRegistros - 1).ToString();

//llenar el textbox con el ID

textBox6.Text = numRegistros.ToString();

}

catch (Exception)

{

MessageBox.Show("Conexión fallida");

this.Close();

}

}

Despues tenemos la interfaz de bajas de Clientes

El cual contiene 1 label, 1 textbox, 1 botón y 1 datagridview

El botón “eliminar contiene el siguiente código”;

private void button1_Click_1(object sender, EventArgs e)

{

con = new System.Data.SqlClient.SqlConnection();

con.ConnectionString = " Data

Source=RAFA1\\SQLEXPRESS;AttachDbFilename=I:\\Programas\\Shine System\\Shine

System\\Negocio.mdf;Integrated Security=True";

try

{

string buscar = "SELECT * from Clientes where Id_cte= '" + textBox1.Text +

"'";

SqlCommand ORDEN = new SqlCommand(buscar, con);

ORDEN.Connection.Open();

ORDEN.ExecuteNonQuery();

SqlDataReader reader = ORDEN.ExecuteReader();

reader.Read();

if (reader.HasRows)

{

con2 = new System.Data.SqlClient.SqlConnection();

Page 10: Manual de shine system

con2.ConnectionString = " Data

Source=RAFA1\\SQLEXPRESS;AttachDbFilename=I:\\Programas\\Shine System\\Shine

System\\Negocio.mdf;Integrated Security=True";

if (MessageBox.Show("¿Eliminar el cliente " + textBox1.Text + "?",

"Confirmar", MessageBoxButtons.YesNo) == DialogResult.Yes)

{

string eliminar = "DELETE FROM Clientes WHERE Id_cte='" +

textBox1.Text + "'";

SqlCommand ORDEN2 = new SqlCommand(eliminar, con2);

ORDEN2.Connection.Open();

ORDEN2.ExecuteNonQuery();

MessageBox.Show("cliente eliminado");

textBox1.Text = "";

Form4 vent = new Form4();

this.Close();

vent.Show();

}

else

{

MessageBox.Show("No se puede eliminar el cliente");

}

}

else

{

MessageBox.Show("el cliente proporcionado no existe");

textBox1.Text = "";

}

}

catch

{

MessageBox.Show("Conexion fallida");

}

}

Ahora tenemos la interfaz de los cambios de los clientes

El cual cuenta con 11 textbox y 11 labels y 1 botón, 4 pictureboox y 1 datagridview

El botón de actualizar contiene el siguiente código;

private void button1_Click(object sender, EventArgs e)

{

con = new System.Data.SqlClient.SqlConnection();

con.ConnectionString = " Data

Source=RAFA1\\SQLEXPRESS;AttachDbFilename=I:\\Programas\\Shine System\\Shine

System\\Negocio.mdf;Integrated Security=True";

// 1 Clave ya

SqlCommand ORDEN = new SqlCommand("SELECT Id_cte from Clientes where Id_cte=

'" + textBox14.Text + "'", con);

Page 11: Manual de shine system

ORDEN.Connection.Open(); ORDEN.ExecuteNonQuery(); SqlDataReader reader =

ORDEN.ExecuteReader(); reader.Read();

try { if (reader.HasRows) { textBox6.Text = reader.GetString(0); } }

catch (Exception) { textBox6.Text = ""; }

reader.Close(); ORDEN.Connection.Close();

// telefono ya

SqlCommand ORDEN1 = new SqlCommand("SELECT Telefono from Clientes where

Id_cte= '" + textBox14.Text + "'", con);

ORDEN.Connection.Open(); ORDEN.ExecuteNonQuery(); SqlDataReader reader2 =

ORDEN.ExecuteReader(); reader2.Read();

try { if (reader.HasRows) { textBox11.Text = reader.GetString(0); } }

catch (Exception) { textBox11.Text = ""; }

reader.Close(); ORDEN.Connection.Close();

// 2 Nombre ya

SqlCommand ORDEN2 = new SqlCommand("SELECT nombre from Clientes where

Id_cte= '" + textBox14.Text + "'", con);

ORDEN2.Connection.Open(); ORDEN2.ExecuteNonQuery();

SqlDataReader reader15 = ORDEN2.ExecuteReader(); reader15.Read();

try { if (reader15.HasRows) { textBox1.Text = reader15.GetString(0); } }

catch (Exception) { textBox1.Text = ""; }

reader15.Close(); ORDEN2.Connection.Close();

// 3 Apellido paterno ya

SqlCommand ORDEN3 = new SqlCommand("SELECT Apellido_Paterno from Clientes

where Id_cte= '" + textBox14.Text + "'", con);

ORDEN3.Connection.Open(); ORDEN3.ExecuteNonQuery();

SqlDataReader reader3 = ORDEN3.ExecuteReader(); reader3.Read();

try { if (reader3.HasRows) { textBox2.Text = reader3.GetString(0); } }

catch (Exception) { textBox2.Text = ""; }

reader3.Close(); ORDEN3.Connection.Close();

// 4 Apellido materno ya

SqlCommand ORDEN4 = new SqlCommand("SELECT Apellido_Materno from Clientes

where Id_cte= '" + textBox14.Text + "'", con);

ORDEN4.Connection.Open(); ORDEN4.ExecuteNonQuery();

SqlDataReader reader4 = ORDEN4.ExecuteReader(); reader4.Read();

try { if (reader4.HasRows) { textBox3.Text = reader4.GetString(0); } }

catch (Exception) { textBox3.Text = ""; } reader4.Close();

ORDEN4.Connection.Close();

// 5 Telefono ya

SqlCommand ORDEN5 = new SqlCommand("SELECT Telefono from Clientes where

Id_cte= '" + textBox14.Text + "'", con);

ORDEN5.Connection.Open(); ORDEN5.ExecuteNonQuery();

SqlDataReader reader5 = ORDEN5.ExecuteReader(); reader5.Read();

try { if (reader5.HasRows) { textBox11.Text = reader5.GetString(0); } }

catch (Exception) { textBox11.Text = ""; } reader5.Close();

ORDEN5.Connection.Close();

// 6 Calle ya

SqlCommand ORDEN6 = new SqlCommand("SELECT Calle from Clientes where Id_cte=

'" + textBox14.Text + "'", con);

ORDEN6.Connection.Open(); ORDEN6.ExecuteNonQuery();

SqlDataReader reader6 = ORDEN6.ExecuteReader(); reader6.Read();

try { if (reader6.HasRows) { textBox8.Text = reader6.GetString(0); } }

catch (Exception) { textBox8.Text = ""; } reader6.Close();

ORDEN6.Connection.Close();

// 7 direccion ya

SqlCommand ORDEN7 = new SqlCommand("SELECT Direccion from Clientes where

Id_cte= '" + textBox14.Text + "'", con);

ORDEN7.Connection.Open(); ORDEN7.ExecuteNonQuery();

SqlDataReader reader7 = ORDEN7.ExecuteReader(); reader7.Read();

try { if (reader7.HasRows) { textBox7.Text = reader7.GetString(0); } }

catch (Exception) { textBox7.Text = ""; } reader7.Close();

ORDEN7.Connection.Close();

// 8 e.mail ya

SqlCommand ORDEN8 = new SqlCommand("SELECT E_mail from Clientes where

Id_cte= '" + textBox14.Text + "'", con);

ORDEN8.Connection.Open(); ORDEN8.ExecuteNonQuery();

SqlDataReader reader8 = ORDEN8.ExecuteReader(); reader8.Read();

try { if (reader8.HasRows) { textBox10.Text = reader8.GetString(0); } }

catch (Exception) { textBox10.Text = ""; }

reader8.Close(); ORDEN8.Connection.Close();

// 10 Estado

Page 12: Manual de shine system

SqlCommand ORDEN11 = new SqlCommand("SELECT Edo from Clientes where Id_cte=

'" + textBox14.Text + "'", con);

ORDEN11.Connection.Open(); ORDEN11.ExecuteNonQuery();

SqlDataReader reader11 = ORDEN11.ExecuteReader(); reader11.Read();

try { if (reader11.HasRows) { textBox9.Text = reader11.GetString(0); } }

catch (Exception) { textBox9.Text = ""; } reader11.Close();

ORDEN11.Connection.Close();

//Edad

SqlCommand ORDEN12 = new SqlCommand("SELECT Edad from Clientes where Id_cte=

'" + textBox14.Text + "'", con);

ORDEN12.Connection.Open(); ORDEN12.ExecuteNonQuery();

SqlDataReader reader12 = ORDEN12.ExecuteReader(); reader12.Read();

try { if (reader12.HasRows) { textBox23.Text = reader12.GetString(0); } }

catch (Exception) { textBox23.Text = ""; } reader12.Close();

ORDEN12.Connection.Close();

}

El pictureboox1 “aceptar” contiene el siguiente codigo;

private void pictureBox1_Click(object sender, EventArgs e)

{

if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" ||

textBox23.Text == "" || textBox7.Text == "" || textBox8.Text == "" || textBox11.Text == ""

|| textBox9.Text == "" || textBox10.Text == "")

{

MessageBox.Show("Faltan datos por llenar");

}

else

{

if (MessageBox.Show("Se modificara el registro", "Añadir al cliente",

MessageBoxButtons.YesNo) == DialogResult.Yes)

{

textBox6.Text = textBox14.Text;

con = new System.Data.SqlClient.SqlConnection();

con.ConnectionString = " Data

Source=RAFA1\\SQLEXPRESS;AttachDbFilename=I:\\Programas\\Shine System\\Shine

System\\Negocio.mdf;Integrated Security=True";

string q = "update Clientes set

Nombre=@Nombre,Telefono=@Telefono,Apellido_Paterno=@Apellido_Paterno,Apellido_Materno=@Apell

ido_Materno,calle=@calle,Direccion=@Direccion,Edo=@Edo,E_mail=@E_mail,Edad=@Edad where

Id_cte=@Id_cte";

SqlCommand ORDEN = new SqlCommand(q, con);

ORDEN.Parameters.Add(new SqlParameter("@Id_cte", textBox14.Text));

ORDEN.Parameters.Add(new SqlParameter("@Nombre", textBox1.Text));

ORDEN.Parameters.Add(new SqlParameter("@Apellido_Paterno",

textBox2.Text));

ORDEN.Parameters.Add(new SqlParameter("@Apellido_Materno",

textBox3.Text));

ORDEN.Parameters.Add(new SqlParameter("@Direccion", textBox7.Text));

ORDEN.Parameters.Add(new SqlParameter("@Calle", textBox8.Text));

ORDEN.Parameters.Add(new SqlParameter("@Edo", textBox9.Text));

ORDEN.Parameters.Add(new SqlParameter("@E_mail", textBox10.Text));

ORDEN.Parameters.Add(new SqlParameter("@Telefono", textBox11.Text));

ORDEN.Parameters.Add(new SqlParameter("@Edad", textBox23.Text));

ORDEN.Connection.Open();

ORDEN.ExecuteNonQuery();

ORDEN.Connection.Close();

MessageBox.Show("Registros modificados");

this.Close();

Page 13: Manual de shine system

}

}

}

Y el la forma se carga el siguiente codigo;

DataSet TABLA;

SqlDataAdapter ORDEN;

CANAL = new SqlConnection("Data

Source=RAFA1\\SQLEXPRESS;AttachDbFilename=I:\\Programas\\Shine System\\Shine

System\\Negocio.mdf;Integrated Security=True");

string q = "select * from Clientes";

ORDEN = new SqlDataAdapter(q, CANAL);

// Creando el dataset y cargandolo

TABLA = new DataSet();

ORDEN.Fill(TABLA, "Clientes");

// Cargando el datagridview

dataGridView1.DataSource = TABLA;

dataGridView1.DataMember = "Clientes";

con = new System.Data.SqlClient.SqlConnection();

con.ConnectionString = " Data

Source=RAFA1\\SQLEXPRESS;AttachDbFilename=I:\\Programas\\Shine System\\Shine

System\\Negocio.mdf;Integrated Security=True";

con.Open();

//Cuento registros

string strSql = "SELECT Count(Id_cte) FROM Clientes";

SqlCommand cmd = new SqlCommand(strSql, con);

int numRegistros = ((int)cmd.ExecuteScalar()) + 1;

con.Close();

label1.Text = "Registros: " + (numRegistros - 1).ToString();

}

Page 14: Manual de shine system

En esta forma tenemos la opción ventas

La cual contiene 5 textboc y 2 combobox 4 picturebox y 8 labels

El picturebox1 de aceptar contiene el siguiente codigo;

private void pictureBox1_Click(object sender, EventArgs e)

{

if (textBox1.Text == "" || textBox2.Text == "" || textBox5.Text == "" ||

textBox3.Text == "")

{

MessageBox.Show("Faltan datos por llenar o No Calculaste EL TOTAL");

}

else

{

// abriendo la conexion o enlace

con = new System.Data.SqlClient.SqlConnection();

con.ConnectionString = " Data

Source=RAFA1\\SQLEXPRESS;AttachDbFilename=I:\\Programas\\Shine System\\Shine

System\\Negocio.mdf;Integrated Security=True";

string q = "insert into

Ventas(id_vta,fecha,cantidad,total,id_prod,id_cte,presio)

values(@id_vta,@fecha,@cantidad,@total,@id_prod,@id_cte,@presio)";

SqlCommand ORDEN = new SqlCommand(q, con);

ORDEN = new SqlCommand(q, con);

ORDEN.Parameters.Add(new SqlParameter("@id_vta", textBox4.Text));

ORDEN.Parameters.Add(new SqlParameter("@fecha", textBox1.Text));

ORDEN.Parameters.Add(new SqlParameter("@cantidad", textBox2.Text));

ORDEN.Parameters.Add(new SqlParameter("@total", textBox3.Text));

ORDEN.Parameters.Add(new SqlParameter("@id_prod", comboBox2.Text));

ORDEN.Parameters.Add(new SqlParameter("@id_cte", comboBox3.Text));

ORDEN.Parameters.Add(new SqlParameter("@presio", textBox5.Text));

ORDEN.Connection.Open();

ORDEN.ExecuteNonQuery();

ORDEN.Connection.Close();

MessageBox.Show("La Venta " + textBox4.Text + " se registro con exito");

textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text =

""; textBox5.Text = "";

Form4 ven = new Form4();

this.Close();

ven.Show();

}

}