Codigo Boton Baja: Using Using Using Using Using Using Using Using Using Using Using
Codigo Boton Baja: Using Using Using Using Using Using Using Using Using Using Using
Codigo Boton Baja: Using Using Using Using Using Using Using Using Using Using Using
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;
using System.Data.SqlClient;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
namespace MDIPRINCIPAL
{
public partial class BajaVendedores : Form
{
private MySqlConnection dbConection;
public BajaVendedores()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e) //BOTON CANCELAR
{
this.Close();
}
private void button3_Click(object sender, EventArgs e) //BOTON BUSCAR
{
dbConection = new MySqlConnection("DataBase=OXXO;Data
Source=localhost;User Id=root;Password=;");
string leercod = " select
vendedores.cod_vendedor,vendedores.Nombre,vendedores.direccion,vendedores.CP,municip
ios.Nombre,vendedores.cod_jefe from vendedores,municipios where
vendedores.cod_vendedor = municipios.cod_muni and cod_vendedor='" + textBox4.Text +
"' ";
MySqlCommand comando = new MySqlCommand(leercod, dbConection);
dbConection.Open();
try
{
MySqlDataAdapter sda = new MySqlDataAdapter();
sda.SelectCommand = comando;
DataTable dbdataset = new DataTable();
sda.Fill(dbdataset);
BindingSource bSource = new BindingSource();
bSource.DataSource = dbdataset;
dataGridView1.DataSource = bSource;
sda.Update(dbdataset);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
CODIGO BOTON BAJA
}
}
private void button1_Click(object sender, EventArgs e)
{
try
{
dbConection = new MySqlConnection("Database=OXX,Data
Source=localhost;User Id= root;Password=;");
dbConection.Open();
MySqlCommand command1 = dbConection.CreateCommand();
MySqlTransaction t1 = dbConection.BeginTransaction();
try
{
command1.CommandText = "call eliminar_vendedor('" +
textBox4.Text + "')";
command1.ExecuteNonQuery();
t1.Commit();
MessageBox.Show(" Se ELIMINO correctamente", "ok");
dbConection.Close();
}
catch (Exception e1)
{
t1.Rollback();
MessageBox.Show("NO se pudo ELIMINAR debido a " + e1);
}
}
catch
{
System.Console.WriteLine("ERROR de Conexion");
}
}
private void Buscar_Click(object sender, EventArgs e)
{
}
private void button1_Click_1(object sender, EventArgs e) //BOTON ELIMINAR
{
try
{
dbConection = new MySqlConnection("Database=OXXO;Data
Source=localhost;User Id= root;Password=;");
dbConection.Open();
MySqlCommand command1 = dbConection.CreateCommand();
MySqlTransaction t1 = dbConection.BeginTransaction();
try
{
CODIGO BOTON BAJA
command1.CommandText = "call eliminar_vendedor('" +
textBox4.Text + "')";
command1.ExecuteNonQuery();
t1.Commit();
MessageBox.Show(" Se ELIMINO correctamente", "ok");
dbConection.Close();
}
catch (Exception e1)
{
t1.Rollback();
MessageBox.Show("NO se pudo ELIMINAR debido a " + e1);
}
}
catch
{
System.Console.WriteLine("ERROR de Conexion");
}
}
}
}