SlideShare una empresa de Scribd logo
1 de 14
Descargar para leer sin conexión
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
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=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine
SystemNegocio.mdf;Integrated Security=True";
            try
            {
                con.Open();

                con = new System.Data.SqlClient.SqlConnection();
                con.ConnectionString = " Data
Source=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine
SystemNegocio.mdf;Integrated Security=True";



               con.Close();
                  }
           catch
           {

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

           }
       }
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();
                }

        }
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”.
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=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine
SystemNegocio.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=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine
SystemNegocio.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 = "";
                    }


                }
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();
        }
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
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=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine
SystemNegocio.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;
private void Form6_Load(object sender, EventArgs e)
        {
            con = new System.Data.SqlClient.SqlConnection();
             con.ConnectionString = " Data
Source=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine
SystemNegocio.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=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine
SystemNegocio.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();
con2.ConnectionString = " Data
Source=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine
SystemNegocio.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=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine
SystemNegocio.mdf;Integrated Security=True";

                // 1 Clave ya
                SqlCommand ORDEN = new SqlCommand("SELECT Id_cte from Clientes where Id_cte=
'" + textBox14.Text + "'", con);
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
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=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine
SystemNegocio.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();
}
             }
       }

Y el la forma se carga el siguiente codigo;

DataSet TABLA;
            SqlDataAdapter ORDEN;
            CANAL = new SqlConnection("Data
Source=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine
SystemNegocio.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=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine
SystemNegocio.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();


        }
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=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine
SystemNegocio.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();


             }
        }

Más contenido relacionado

La actualidad más candente

Ejemplos Borland C++ Builder
Ejemplos Borland C++ BuilderEjemplos Borland C++ Builder
Ejemplos Borland C++ BuilderDarwin Durand
 
Visual basic 2010 data por codigo
Visual basic 2010 data por codigoVisual basic 2010 data por codigo
Visual basic 2010 data por codigojuan fernandez
 
Conexion sql server 2005 java netbeans
Conexion sql server 2005 java netbeansConexion sql server 2005 java netbeans
Conexion sql server 2005 java netbeansjbersosa
 
CREACION DE DLL Y USO (Ejemplo desarrollado)
CREACION DE DLL Y USO (Ejemplo desarrollado)CREACION DE DLL Y USO (Ejemplo desarrollado)
CREACION DE DLL Y USO (Ejemplo desarrollado)Darwin Durand
 
5. Interacción con el usuario: eventos y formularios
5. Interacción con el usuario: eventos y formularios5. Interacción con el usuario: eventos y formularios
5. Interacción con el usuario: eventos y formulariosLaura Folgado Galache
 
Manual Visual Basic .NET SQL Server paso a paso
Manual Visual Basic .NET SQL Server paso a pasoManual Visual Basic .NET SQL Server paso a paso
Manual Visual Basic .NET SQL Server paso a pasoatak
 
Fundamentos de Programación Visual Basic 2010
Fundamentos de Programación Visual Basic 2010Fundamentos de Programación Visual Basic 2010
Fundamentos de Programación Visual Basic 2010Luis Ruiz Ch
 
Aprenda a conectar sql y c# en 19 sencillos pasos!
Aprenda a conectar sql y c# en 19 sencillos pasos!Aprenda a conectar sql y c# en 19 sencillos pasos!
Aprenda a conectar sql y c# en 19 sencillos pasos!Ziscko
 
Practica 02-taller-de-programacion-121226180145-phpapp02
Practica 02-taller-de-programacion-121226180145-phpapp02Practica 02-taller-de-programacion-121226180145-phpapp02
Practica 02-taller-de-programacion-121226180145-phpapp02Flor Santana Mota
 
Formularios y contenedores
Formularios y contenedoresFormularios y contenedores
Formularios y contenedoreszeta2015
 
Parte II. Notas Rapidas (sticky notes) App W8: MVVM y SQLite.
Parte II. Notas Rapidas (sticky notes) App W8: MVVM y SQLite.Parte II. Notas Rapidas (sticky notes) App W8: MVVM y SQLite.
Parte II. Notas Rapidas (sticky notes) App W8: MVVM y SQLite.Juan Manuel
 

La actualidad más candente (19)

Ejemplos Borland C++ Builder
Ejemplos Borland C++ BuilderEjemplos Borland C++ Builder
Ejemplos Borland C++ Builder
 
Guia no2 ado.net
Guia no2 ado.netGuia no2 ado.net
Guia no2 ado.net
 
manual visual basic 02
manual visual basic 02 manual visual basic 02
manual visual basic 02
 
Visual basic 2010 data por codigo
Visual basic 2010 data por codigoVisual basic 2010 data por codigo
Visual basic 2010 data por codigo
 
Conexion sql server 2005 java netbeans
Conexion sql server 2005 java netbeansConexion sql server 2005 java netbeans
Conexion sql server 2005 java netbeans
 
CREACION DE DLL Y USO (Ejemplo desarrollado)
CREACION DE DLL Y USO (Ejemplo desarrollado)CREACION DE DLL Y USO (Ejemplo desarrollado)
CREACION DE DLL Y USO (Ejemplo desarrollado)
 
5. Interacción con el usuario: eventos y formularios
5. Interacción con el usuario: eventos y formularios5. Interacción con el usuario: eventos y formularios
5. Interacción con el usuario: eventos y formularios
 
Conexion Visual
Conexion Visual Conexion Visual
Conexion Visual
 
Manual Visual Basic .NET SQL Server paso a paso
Manual Visual Basic .NET SQL Server paso a pasoManual Visual Basic .NET SQL Server paso a paso
Manual Visual Basic .NET SQL Server paso a paso
 
284
284284
284
 
Fundamentos de Programación Visual Basic 2010
Fundamentos de Programación Visual Basic 2010Fundamentos de Programación Visual Basic 2010
Fundamentos de Programación Visual Basic 2010
 
Documento de eloy
Documento de eloyDocumento de eloy
Documento de eloy
 
Aprenda a conectar sql y c# en 19 sencillos pasos!
Aprenda a conectar sql y c# en 19 sencillos pasos!Aprenda a conectar sql y c# en 19 sencillos pasos!
Aprenda a conectar sql y c# en 19 sencillos pasos!
 
Jquery para principianes
Jquery para principianesJquery para principianes
Jquery para principianes
 
Sql
SqlSql
Sql
 
Practica 02-taller-de-programacion-121226180145-phpapp02
Practica 02-taller-de-programacion-121226180145-phpapp02Practica 02-taller-de-programacion-121226180145-phpapp02
Practica 02-taller-de-programacion-121226180145-phpapp02
 
Formularios y contenedores
Formularios y contenedoresFormularios y contenedores
Formularios y contenedores
 
Guia programacion acceso al asistema
Guia programacion  acceso al asistemaGuia programacion  acceso al asistema
Guia programacion acceso al asistema
 
Parte II. Notas Rapidas (sticky notes) App W8: MVVM y SQLite.
Parte II. Notas Rapidas (sticky notes) App W8: MVVM y SQLite.Parte II. Notas Rapidas (sticky notes) App W8: MVVM y SQLite.
Parte II. Notas Rapidas (sticky notes) App W8: MVVM y SQLite.
 

Destacado (8)

Fujitsu map new
Fujitsu map newFujitsu map new
Fujitsu map new
 
Test
TestTest
Test
 
NECTEC E-magazine Vol.4
NECTEC E-magazine Vol.4NECTEC E-magazine Vol.4
NECTEC E-magazine Vol.4
 
Basic m3-1-chapter2
Basic m3-1-chapter2Basic m3-1-chapter2
Basic m3-1-chapter2
 
ข้อสอบ O-net ปี 2553 สังคม อังกฤษ คณิต 92D
ข้อสอบ O-net ปี 2553 สังคม อังกฤษ คณิต 92Dข้อสอบ O-net ปี 2553 สังคม อังกฤษ คณิต 92D
ข้อสอบ O-net ปี 2553 สังคม อังกฤษ คณิต 92D
 
Cvd prevention
Cvd preventionCvd prevention
Cvd prevention
 
Dce2 ejercicios asp.net
Dce2 ejercicios asp.netDce2 ejercicios asp.net
Dce2 ejercicios asp.net
 
แนวข้อสอบ ด้านการเงินหรือการคลังของท้องถิ่น (เจ้าหน้าที่ เจ้าพนักงาน-นักวิชาก...
แนวข้อสอบ ด้านการเงินหรือการคลังของท้องถิ่น (เจ้าหน้าที่ เจ้าพนักงาน-นักวิชาก...แนวข้อสอบ ด้านการเงินหรือการคลังของท้องถิ่น (เจ้าหน้าที่ เจ้าพนักงาน-นักวิชาก...
แนวข้อสอบ ด้านการเงินหรือการคลังของท้องถิ่น (เจ้าหน้าที่ เจ้าพนักงาน-นักวิชาก...
 

Similar a Manual de shine system

Crear El Proyecto Y El Primer Formulario Con Su CodificacióN
Crear El Proyecto Y El Primer  Formulario Con Su CodificacióNCrear El Proyecto Y El Primer  Formulario Con Su CodificacióN
Crear El Proyecto Y El Primer Formulario Con Su CodificacióNjameszx
 
Crear El Proyecto Y El Primer Formulario Con Su CodificacióN
Crear El Proyecto Y El Primer  Formulario Con Su CodificacióNCrear El Proyecto Y El Primer  Formulario Con Su CodificacióN
Crear El Proyecto Y El Primer Formulario Con Su CodificacióNjameszx
 
Creación de correo electrónico mediante C#
Creación de correo electrónico mediante C#Creación de correo electrónico mediante C#
Creación de correo electrónico mediante C#José Mora Torres
 
Ejemplo de base de datos y reports con jasper report
Ejemplo de base de datos y reports con jasper reportEjemplo de base de datos y reports con jasper report
Ejemplo de base de datos y reports con jasper reportjbersosa
 
Documentoaltas
DocumentoaltasDocumentoaltas
DocumentoaltaslupithaRSz
 
Actualizacion de base de datos desde Visual Basic
Actualizacion de base de datos desde Visual Basic Actualizacion de base de datos desde Visual Basic
Actualizacion de base de datos desde Visual Basic EduardoMontiel18
 
Pantallas de programa armando maquinas
Pantallas de programa armando maquinasPantallas de programa armando maquinas
Pantallas de programa armando maquinasjuanarmando2010
 
Pantallas de programa armando maquinas
Pantallas de programa armando maquinasPantallas de programa armando maquinas
Pantallas de programa armando maquinasjuanarmando2010
 

Similar a Manual de shine system (20)

Acceder
AccederAcceder
Acceder
 
Acceder
AccederAcceder
Acceder
 
Crear El Proyecto Y El Primer Formulario Con Su CodificacióN
Crear El Proyecto Y El Primer  Formulario Con Su CodificacióNCrear El Proyecto Y El Primer  Formulario Con Su CodificacióN
Crear El Proyecto Y El Primer Formulario Con Su CodificacióN
 
Crear El Proyecto Y El Primer Formulario Con Su CodificacióN
Crear El Proyecto Y El Primer  Formulario Con Su CodificacióNCrear El Proyecto Y El Primer  Formulario Con Su CodificacióN
Crear El Proyecto Y El Primer Formulario Con Su CodificacióN
 
GEOMETRIC COMPUTER PROGRAMA DE BD
GEOMETRIC COMPUTER PROGRAMA DE BDGEOMETRIC COMPUTER PROGRAMA DE BD
GEOMETRIC COMPUTER PROGRAMA DE BD
 
Aplicación Cliente - Servidor / GUI - Consola
Aplicación Cliente - Servidor / GUI - ConsolaAplicación Cliente - Servidor / GUI - Consola
Aplicación Cliente - Servidor / GUI - Consola
 
Creación de correo electrónico mediante C#
Creación de correo electrónico mediante C#Creación de correo electrónico mediante C#
Creación de correo electrónico mediante C#
 
Ejemplo de base de datos y reports con jasper report
Ejemplo de base de datos y reports con jasper reportEjemplo de base de datos y reports con jasper report
Ejemplo de base de datos y reports con jasper report
 
C# calculadora
C# calculadoraC# calculadora
C# calculadora
 
Documentoaltas
DocumentoaltasDocumentoaltas
Documentoaltas
 
Actualizacion de base de datos desde Visual Basic
Actualizacion de base de datos desde Visual Basic Actualizacion de base de datos desde Visual Basic
Actualizacion de base de datos desde Visual Basic
 
Creacion de proyecto_en_netbeans
Creacion de proyecto_en_netbeansCreacion de proyecto_en_netbeans
Creacion de proyecto_en_netbeans
 
Pantallas de programa armando maquinas
Pantallas de programa armando maquinasPantallas de programa armando maquinas
Pantallas de programa armando maquinas
 
Pantallas de programa armando maquinas
Pantallas de programa armando maquinasPantallas de programa armando maquinas
Pantallas de programa armando maquinas
 
24
2424
24
 
Desarrollo De Programas Ejemplos 01
Desarrollo De Programas Ejemplos 01Desarrollo De Programas Ejemplos 01
Desarrollo De Programas Ejemplos 01
 
Desarrollo de programas_ejemplos_01
Desarrollo de programas_ejemplos_01Desarrollo de programas_ejemplos_01
Desarrollo de programas_ejemplos_01
 
Cuaderno digital
Cuaderno digitalCuaderno digital
Cuaderno digital
 
Practica 1 html_basico
Practica 1 html_basicoPractica 1 html_basico
Practica 1 html_basico
 
22
2222
22
 

Más de Rafa

Edi
EdiEdi
EdiRafa
 
Diseño de flujo de datos
Diseño de flujo de datosDiseño de flujo de datos
Diseño de flujo de datosRafa
 
Procedimientos Almacenados
Procedimientos AlmacenadosProcedimientos Almacenados
Procedimientos AlmacenadosRafa
 
My Sql
My SqlMy Sql
My SqlRafa
 
Procesamientos Almacenados
Procesamientos AlmacenadosProcesamientos Almacenados
Procesamientos AlmacenadosRafa
 
Herramientas De Control De B D
Herramientas De Control De B DHerramientas De Control De B D
Herramientas De Control De B DRafa
 
Manual Access
Manual AccessManual Access
Manual AccessRafa
 
Manual Sql
Manual SqlManual Sql
Manual SqlRafa
 
Ejemplos De Normalizaxion
Ejemplos De NormalizaxionEjemplos De Normalizaxion
Ejemplos De NormalizaxionRafa
 

Más de Rafa (9)

Edi
EdiEdi
Edi
 
Diseño de flujo de datos
Diseño de flujo de datosDiseño de flujo de datos
Diseño de flujo de datos
 
Procedimientos Almacenados
Procedimientos AlmacenadosProcedimientos Almacenados
Procedimientos Almacenados
 
My Sql
My SqlMy Sql
My Sql
 
Procesamientos Almacenados
Procesamientos AlmacenadosProcesamientos Almacenados
Procesamientos Almacenados
 
Herramientas De Control De B D
Herramientas De Control De B DHerramientas De Control De B D
Herramientas De Control De B D
 
Manual Access
Manual AccessManual Access
Manual Access
 
Manual Sql
Manual SqlManual Sql
Manual Sql
 
Ejemplos De Normalizaxion
Ejemplos De NormalizaxionEjemplos De Normalizaxion
Ejemplos De Normalizaxion
 

Manual de shine system

  • 1. 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
  • 2. 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=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine SystemNegocio.mdf;Integrated Security=True"; try { con.Open(); con = new System.Data.SqlClient.SqlConnection(); con.ConnectionString = " Data Source=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine SystemNegocio.mdf;Integrated Security=True"; con.Close(); } catch { MessageBox.Show("BASE DE DATOS NO CONECTADA"); } }
  • 3. 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(); } }
  • 4. 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”.
  • 5. 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=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine SystemNegocio.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=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine SystemNegocio.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 = ""; } }
  • 6. 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(); }
  • 7. 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
  • 8. 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=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine SystemNegocio.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;
  • 9. private void Form6_Load(object sender, EventArgs e) { con = new System.Data.SqlClient.SqlConnection(); con.ConnectionString = " Data Source=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine SystemNegocio.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=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine SystemNegocio.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();
  • 10. con2.ConnectionString = " Data Source=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine SystemNegocio.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=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine SystemNegocio.mdf;Integrated Security=True"; // 1 Clave ya SqlCommand ORDEN = new SqlCommand("SELECT Id_cte from Clientes where Id_cte= '" + textBox14.Text + "'", con);
  • 11. 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
  • 12. 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=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine SystemNegocio.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();
  • 13. } } } Y el la forma se carga el siguiente codigo; DataSet TABLA; SqlDataAdapter ORDEN; CANAL = new SqlConnection("Data Source=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine SystemNegocio.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=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine SystemNegocio.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(); }
  • 14. 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=RAFA1SQLEXPRESS;AttachDbFilename=I:ProgramasShine SystemShine SystemNegocio.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(); } }