Académique Documents
Professionnel Documents
Culture Documents
{
private string texto;
public SqlConnection conn;
}
catch (Exception e)
{
Texto = "se presento el siguiente error" + e.Message;
return false;
}
finally
{
conn.Close();
}
}
SqlDataReader NBT;
SqlCommand comando = new SqlCommand("Sp_Login", conn);
comando.CommandType = CommandType.StoredProcedure;
comando.Parameters.Add("@USER", SqlDbType.VarChar, 20).Value =
usuario;
comando.Parameters.Add("@PASS", SqlDbType.VarChar, 20).Value =
contrase�a;
conn.Open();
NBT = comando.ExecuteReader();
if (NBT.Read() == true)
Cargo = NBT["Cargo"].ToString();
return Cargo;
}
catch (Exception EX)
{
return Texto;
}
finally
{
conn.Close();
}
}
conn.Open();
da.Fill(dt);
return dt;
}
catch (Exception EX)
{
return null;
}
finally
{
conn.Close();
}
}
conn.Open();
cmd.ExecuteNonQuery();
return true;
}
catch (Exception e)
{
conn.Open();
crd.ExecuteNonQuery();
return true;
}
catch (Exception e)
{
texto = "Se presenta un error" + e.Message;
return false;
}
finally
{
conn.Close();
}
}
conn.Open();
comando.ExecuteNonQuery();
return true;
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
return false;
}
finally
{
conn.Close();
}
}
conn.Open();
cld.ExecuteNonQuery();
return true;
}
catch (Exception e)
{
conn.Open();
ckd.ExecuteNonQuery();
return true;
}
catch (Exception e)
{
texto = "Se presenta un error" + e.Message;
return false;
}
finally
{
conn.Close();
}
}
public bool EliminarCliente(int id_cliente)
{
try
{
SqlCommand comando = new SqlCommand("ELIMINAR_CLIENTE", conn);
comando.CommandType = CommandType.StoredProcedure;
conn.Open();
comando.ExecuteNonQuery();
return true;
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
return false;
}
finally
{
conn.Close();
}
}
public bool InsertarProducto(int codigo_productos, string tipo_producto,
string nombre_producto, int valor, int id_proveedores, string cantidad)
{
try
{
SqlCommand cjd = new SqlCommand("INSERTAR_PRODUCTO", conn);
cjd.CommandType = CommandType.StoredProcedure;
cjd.Parameters.Add("@CODIGO_PRODUCTOS", SqlDbType.Int, 10).Value =
codigo_productos;
cjd.Parameters.Add("@TIPO_PRODUCTO", SqlDbType.VarChar, 15).Value =
tipo_producto;
cjd.Parameters.Add("@NOMBRE_PRODUCTO", SqlDbType.VarChar, 15).Value
= nombre_producto;
cjd.Parameters.Add("@VALOR", SqlDbType.Int, 10).Value = valor;
cjd.Parameters.Add("@ID_PROVEEDORES", SqlDbType.Int, 15).Value =
id_proveedores;
cjd.Parameters.Add("@CANTIDAD", SqlDbType.VarChar, 8).Value =
cantidad;
conn.Open();
cjd.ExecuteNonQuery();
return true;
}
catch (Exception e)
{
conn.Open();
cpd.ExecuteNonQuery();
return true;
}
catch (Exception e)
{
texto = "Se presenta un error" + e.Message;
return false;
}
finally
{
conn.Close();
}
}
public bool EliminarProducto(int codigo_productos)
{
try
{
SqlCommand comando = new SqlCommand("ELIMINAR_PRODUCTOS", conn);
comando.CommandType = CommandType.StoredProcedure;
comando.Parameters.Add("@CODIGO_PRODUCTOS", SqlDbType.Int,
15).Value = codigo_productos;
conn.Open();
comando.ExecuteNonQuery();
return true;
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
return false;
}
finally
{
conn.Close();
}
}
public bool InsertarProveedor(int id_proveedores, string
telefono_proveedores, string nombre_empresa, string nombre_proveedor, string
direccion_proveedores, string correo_electronico_proveedor)
{
try
{
SqlCommand cud = new SqlCommand("INSERTAR_PROVEEDOR", conn);
cud.CommandType = CommandType.StoredProcedure;
cud.Parameters.Add("@ID_PROVEEDORES", SqlDbType.Int, 15).Value =
id_proveedores;
cud.Parameters.Add("@TELEFONO_PROVEEDORES", SqlDbType.VarChar,
20).Value = telefono_proveedores;
cud.Parameters.Add("@NOMBRE_EMPRESA", SqlDbType.VarChar, 20).Value
= nombre_empresa;
cud.Parameters.Add("@NOMBRE_PROVEEDOR", SqlDbType.VarChar,
15).Value = nombre_proveedor;
cud.Parameters.Add("@DIRECCION_PROVEEDORES", SqlDbType.VarChar,
20).Value = direccion_proveedores;
cud.Parameters.Add("@CORREO_ELECTRONICO_PROVEEDOR",
SqlDbType.VarChar, 25).Value = correo_electronico_proveedor;
conn.Open();
cud.ExecuteNonQuery();
return true;
}
catch (Exception e)
{
conn.Open();
jaja.ExecuteNonQuery();
return true;
}
catch (Exception e)
{
texto = "Se presenta un error" + e.Message;
return false;
}
finally
{
conn.Close();
}
}
public bool EliminarProveedor(int id_proveedores)
{
try
{
SqlCommand comando = new SqlCommand("ELIMINAR_PROVEEDOR", conn);
comando.CommandType = CommandType.StoredProcedure;
conn.Open();
comando.ExecuteNonQuery();
return true;
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
return false;
}
finally
{
conn.Close();
}
}
public bool InsertarFactura(int codigo_factura, int valor_venta, int
codigo_producto, int id_empleado, int id_cliente, DateTime fecha_de_la_factura)
{
try
{
SqlCommand cud = new SqlCommand("INSERTAR_FACTURA", conn);
cud.CommandType = CommandType.StoredProcedure;
cud.Parameters.Add("@CODIGO_FACTURA ", SqlDbType.Int, 10).Value =
codigo_factura;
cud.Parameters.Add("@VALOR", SqlDbType.Int, 10).Value =
valor_venta;
cud.Parameters.Add("@CODIGO_PRODUCTO", SqlDbType.Int, 15).Value =
codigo_producto;
cud.Parameters.Add("@ID_EMPLEADO", SqlDbType.Int, 15).Value =
id_empleado;
cud.Parameters.Add("@ID_CLIENTE", SqlDbType.Int, 15).Value =
id_cliente;
cud.Parameters.Add("@FECHA_DE_LA_FACTURA", SqlDbType.VarChar,
40).Value = fecha_de_la_factura;
conn.Open();
cud.ExecuteNonQuery();
return true;
}
catch (Exception e)
{