UNIDAD 3 - Implementacion de metodos

Implementacion de metodos 


DISEÑO 



ConsultaMenu(cliente)

  • CONSULTA
public void GenerarConsultaCliente(View view)
{
AdminBD admin = new AdminBD(this, "BaseDatos", null, 1);
SQLiteDatabase BDCLIENTE = admin.getWritableDatabase();
String CodigoCliente= cod_cli.getText().toString();

if (!CodigoCliente.isEmpty()) {
Cursor FilaCliente = BDCLIENTE.rawQuery("Select nombre,direccion,telefono FROM CLIENTE where cedula=" + CodigoCliente, null);

if (FilaCliente.moveToFirst()) {
nom_cli.setText(FilaCliente.getString(0));
dir_cli.setText(FilaCliente.getString(1));
tel_cli.setText(FilaCliente.getString(2));
BDCLIENTE.close();

}
else
{
Toast.makeText(this, "NO EXISTE LOS DATOS", Toast.LENGTH_LONG).show();
BDCLIENTE.close();
}
}
else
{
Toast.makeText(this, "DEBES INTRODUCIR LA CEDULA", Toast.LENGTH_LONG).show();
}
}
  • ELIMINAR 
public void EliminarDatosCliente(View view)
{
AdminBD admin = new AdminBD(this, "BaseDatos", null, 1);
SQLiteDatabase BDELIMINARCLI = admin.getWritableDatabase();
String CodigoEliminarCli = cod_cli.getText().toString();
if((!CodigoEliminarCli.isEmpty()))
{
int ELIMINARCLIENTE = BDELIMINARCLI.delete("CLIENTE", "cedula=" + CodigoEliminarCli,null);
BDELIMINARCLI.close();
nom_cli.setText("");
dir_cli.setText("");
tel_cli.setText("");

if(ELIMINARCLIENTE == 1)
{
Toast.makeText(this, "DATOS ELIMINADOS CORRECTAMENTE", Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(this, "LOS DATOS NO EXISTE", Toast.LENGTH_LONG).show();
}
}
else
{
Toast.makeText(this, "DEBES INTRODUCIR LA CEDULA", Toast.LENGTH_SHORT).show();
}
}
  • ACTUALIZAR
public void ActualizarDatosCliente(View view)
{
AdminBD admin = new AdminBD(this, "BaseDatos", null, 1);
SQLiteDatabase BDACTUALIZARCLI = admin.getWritableDatabase();
String CedulaCA = cod_cli.getText().toString();
String NombreCA = nom_cli.getText().toString();
String DireccionCA = dir_cli.getText().toString();
String TelefonoCA = tel_cli.getText().toString();

if (!CedulaCA.isEmpty() && !NombreCA.isEmpty() && DireccionCA.isEmpty() && TelefonoCA.isEmpty())
{
ContentValues actualizar = new ContentValues();
actualizar.put("cedula", CedulaCA);
actualizar.put("nombre", NombreCA);
actualizar.put("direccion", DireccionCA);
actualizar.put("telefono", TelefonoCA);

int ACTUALIZARCLIENTE = BDACTUALIZARCLI.update("CLIENTE", actualizar,"cedula="+ CedulaCA,null);
BDACTUALIZARCLI.close();

if(ACTUALIZARCLIENTE == 1)
{
Toast.makeText(this, "DATOS DEL CLIENTE ACTUALIZADOS", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(this, "DATOS DEL CLIENTE NO ACTUALIZADOS", Toast.LENGTH_SHORT).show();
}
}
else
{
Toast.makeText(this, "DEBES LLENAR TODOS LOS CAMPOS DEL CLIENTE", Toast.LENGTH_SHORT).show();
}
}

ConsultaPedido

  • CONSULTA
public void GenerarConsultaPedido(View view)
{
AdminBD admin = new AdminBD(this, "BaseDatos", null, 1);
SQLiteDatabase BDPEDIDO = admin.getWritableDatabase();
String CodigoPedido= cod_ped.getText().toString();

if (!CodigoPedido.isEmpty())
{
Cursor FilaPedido = BDPEDIDO .rawQuery("Select descripcionP,fechaP,cantidadP FROM PEDIDO where codigoP=" + CodigoPedido, null);

if (FilaPedido.moveToFirst()) {
des_ped.setText(FilaPedido.getString(0));
fec_ped.setText(FilaPedido.getString(1));
can_ped.setText(FilaPedido.getString(2));
BDPEDIDO.close();
}
else
{
Toast.makeText(this, "NO EXISTE LOS DATOS", Toast.LENGTH_LONG).show();
BDPEDIDO.close();
}
}
else
{
Toast.makeText(this, "DEBES INTRODUCIR EL CODIGO DEL PEDIDO", Toast.LENGTH_LONG).show();

}

}
  • ELIMINAR 
public void EliminarDatosPedido(View view)
{
AdminBD admin = new AdminBD(this, "BaseDatos", null, 1);
SQLiteDatabase BDELIMINARPED = admin.getWritableDatabase();
String CodigoEliminarPed = cod_ped.getText().toString();
if((!CodigoEliminarPed.isEmpty()))
{
int ELIMINARPEDIDO = BDELIMINARPED.delete("PEDIDO", "codigoP=" + CodigoEliminarPed,null);
BDELIMINARPED.close();
des_ped.setText("");
fec_ped.setText("");
can_ped.setText("");

if(ELIMINARPEDIDO == 1)
{
Toast.makeText(this, "DATOS ELIMINADOS CORRECTAMENTE", Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(this, "LOS DATOS NO EXISTE", Toast.LENGTH_LONG).show();
}
}
else
{
Toast.makeText(this, "DEBES INTRODUCIR LA CODIGO DEL PEDIDO", Toast.LENGTH_SHORT).show();
}

}
  • ACTUALIZAR
public void ActualizarDatosPedido(View view)
{
AdminBD admin = new AdminBD(this, "BaseDatos", null, 1);
SQLiteDatabase BDACTUALIZARPED = admin.getWritableDatabase();
String CodigoPA = cod_ped .getText().toString();
String DescripcionPA = des_ped.getText().toString();
String FechaPA = fec_ped.getText().toString();
String CantidadPA = can_ped.getText().toString();
if (!CodigoPA.isEmpty() && !DescripcionPA.isEmpty() && FechaPA.isEmpty() && CantidadPA.isEmpty())
{
ContentValues ActualizarPedido= new ContentValues();
ActualizarPedido.put("codigoP", CodigoPA);
ActualizarPedido.put("descripcionP", DescripcionPA);
ActualizarPedido.put("fechaP", FechaPA);
ActualizarPedido.put("cantidadP", CantidadPA);

int ACTUALIZARPEDIDO = BDACTUALIZARPED.update("PEDIDO",ActualizarPedido,"codigoP="+ CodigoPA,null);
BDACTUALIZARPED.close();

if(ACTUALIZARPEDIDO == 1)
{
Toast.makeText(this, "DATOS DEL PEDIDO ACTUALIZADOS", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(this, "DATOS DEL PEDIDO NO ACTUALIZADOS", Toast.LENGTH_SHORT).show();
}

}
else
{
Toast.makeText(this, "DEBES LLENAR TODOS LOS CAMPOS DEL PEDIDO", Toast.LENGTH_SHORT).show();
}
}
ConsultaProducto

  • CONSULTA
public void GenerarConsultaProducto(View view)
{
AdminBD admin = new AdminBD(this, "BaseDatos", null, 1);
SQLiteDatabase BDPRODUCTO = admin.getWritableDatabase();
String CodigoProducto= cod_pro.getText().toString();
if (!CodigoProducto.isEmpty())
{
Cursor FilaProducto = BDPRODUCTO .rawQuery("Select descripcionPr,valorPr FROM PRODUCTO where codigoPr=" + CodigoProducto, null);

if (FilaProducto.moveToFirst()) {
des_pro.setText(FilaProducto.getString(0));
val_pro.setText(FilaProducto.getString(1));
BDPRODUCTO.close();
}
else
{
Toast.makeText(this, "NO EXISTE LOS DATOS", Toast.LENGTH_LONG).show();
BDPRODUCTO.close();
}
}
else
{
Toast.makeText(this, "DEBES INTRODUCIR EL CODIGO DEL PRODUCTO", Toast.LENGTH_LONG).show();

}
}
  • ELIMINAR 
public void EliminarDatosProducto(View view)
{
AdminBD admin = new AdminBD(this, "BaseDatos", null, 1);
SQLiteDatabase BDELIMINARPRO = admin.getWritableDatabase();
String CodigoEliminarPro = cod_pro.getText().toString();
if((!CodigoEliminarPro.isEmpty()))
{
int ELIMINARPRODUCTO = BDELIMINARPRO.delete("PRODUCTO", "codigoPr=" + CodigoEliminarPro,null);
BDELIMINARPRO.close();
des_pro.setText("");
val_pro.setText("");
if(ELIMINARPRODUCTO == 1)
{
Toast.makeText(this, "DATOS ELIMINADOS CORRECTAMENTE", Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(this, "LOS DATOS NO EXISTE", Toast.LENGTH_LONG).show();
}
}
else
{
Toast.makeText(this, "DEBES INTRODUCIR LA CODIGO PRODUCTO", Toast.LENGTH_SHORT).show();
}

}
  • ACTUALIZAR
public void ActualizarDatosProducto(View view)
{
AdminBD admin = new AdminBD(this, "BaseDatos", null, 1);
SQLiteDatabase BDACTUALIZARPRO = admin.getWritableDatabase();
String CodigoProA = cod_pro .getText().toString();
String DescripcionProA = des_pro .getText().toString();
String ValorProA = val_pro.getText().toString();

if (!CodigoProA.isEmpty() && !DescripcionProA.isEmpty() && ValorProA.isEmpty())
{
ContentValues ActualizarProducto = new ContentValues();
ActualizarProducto.put("codigoPr", CodigoProA );
ActualizarProducto.put("descripcionPr", DescripcionProA);
ActualizarProducto.put("valorPr",ValorProA);

int ACTUALIZARPRODUCTO = BDACTUALIZARPRO .update("PRODUCTO",ActualizarProducto,"codigoPr="+ CodigoProA,null);
BDACTUALIZARPRO.close();

if(ACTUALIZARPRODUCTO == 1)
{
Toast.makeText(this, "DATOS DEL PRODUCTO ACTUALIZADOS", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(this, "DATOS DEL PRODUCTO NO ACTUALIZADOS", Toast.LENGTH_SHORT).show();
}
}
else
{
Toast.makeText(this, "DEBES LLENAR TODOS LOS CAMPOS DEL PRODUCTO", Toast.LENGTH_SHORT).show();
}
}

ConsultaFactura

  • CONSULTA
public void GenerarConsultaFactura(View view)
{
AdminBD admin = new AdminBD(this, "BaseDatos", null, 1);
SQLiteDatabase BDFACTURA = admin.getWritableDatabase();
String CodigoFactura= num_fac.getText().toString();
if (!CodigoFactura.isEmpty())
{
Cursor FilaFactura = BDFACTURA .rawQuery("Select fechaF,totalF FROM FACTURA where numeroF=" + CodigoFactura, null);

if (FilaFactura.moveToFirst()) {
fec_fac.setText(FilaFactura.getString(0));
tot_fac.setText(FilaFactura.getString(1));
BDFACTURA.close();
}
else
{
Toast.makeText(this, "NO EXISTE LOS DATOS", Toast.LENGTH_LONG).show();
BDFACTURA.close();
}
}
else
{
Toast.makeText(this, "DEBES INTRODUCIR EL CODIGO DE LA FACTURA", Toast.LENGTH_LONG).show();

}
}
  • ELIMINAR 
public void EliminarDatosFactura(View view)
{
AdminBD admin = new AdminBD(this, "BaseDatos", null, 1);
SQLiteDatabase BDELIMINARFAC = admin.getWritableDatabase();
String CodigoEliminarFac = num_fac.getText().toString();
if((!CodigoEliminarFac.isEmpty()))
{
int ELIMINARFACTURA = BDELIMINARFAC.delete("FACTURA", "numeroF=" + CodigoEliminarFac,null);
BDELIMINARFAC.close();
fec_fac.setText("");
tot_fac.setText("");
if(ELIMINARFACTURA == 1)
{
Toast.makeText(this, "DATOS ELIMINADOS CORRECTAMENTE", Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(this, "LOS DATOS NO EXISTE", Toast.LENGTH_LONG).show();
}
}
else
{
Toast.makeText(this, "DEBES INTRODUCIR LA CODIGO FACTURA", Toast.LENGTH_SHORT).show();
}

}
  • ACTUALIZAR
public void ActualizarDatosFactura(View view)
{
AdminBD admin = new AdminBD(this, "BaseDatos", null, 1);
SQLiteDatabase BDACTUALIZARFAC = admin.getWritableDatabase();
String NumerofA = num_fac .getText().toString();
String FechafA = fec_fac .getText().toString();
String TotalfA = tot_fac.getText().toString();

if (!NumerofA.isEmpty() && !FechafA.isEmpty() && TotalfA.isEmpty())
{
ContentValues ActualizarFactura = new ContentValues();
ActualizarFactura.put("numeroF", NumerofA);
ActualizarFactura.put("fechaF", FechafA);
ActualizarFactura.put("totalF ",TotalfA);

int ACTUALIZARFACTURA = BDACTUALIZARFAC .update("FACTURA",ActualizarFactura,"numeroF="+ NumerofA ,null);
BDACTUALIZARFAC.close();

if(ACTUALIZARFACTURA == 1)
{
Toast.makeText(this, "DATOS DE LA FACTURA ACTUALIZADOS", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(this, "DATOS DE LA FACTURA NO ACTUALIZADOS", Toast.LENGTH_SHORT).show();
}
}
else
{
Toast.makeText(this, "DEBES LLENAR TODOS LOS CAMPOS DE LA FACTURA", Toast.LENGTH_SHORT).show();
}
}

Comentarios

Entradas populares de este blog

Metodologias para Analisis de Riesgo

UNIDAD 1 - Preguntas sobre la idea de investigación

UNIDAD 2 - La hipótesis de investigación