parte visual envios

This commit is contained in:
carlos
2024-01-23 17:44:38 -06:00
parent da855a6c85
commit 2b2624fb41
11 changed files with 183 additions and 12 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ namespace compabetov2
TableLayoutPanel carta = new TableLayoutPanel(); TableLayoutPanel carta = new TableLayoutPanel();
carta.RowCount = 1; carta.RowCount = 1;
carta.ColumnCount = 2; carta.ColumnCount = 2;
carta.Height = 100; carta.Height = 80;
carta.Width = 820; carta.Width = 820;
carta.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 55F)); carta.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 55F));
carta.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 45F)); carta.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 45F));
+121 -5
View File
@@ -6,6 +6,7 @@ using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
@@ -26,17 +27,15 @@ namespace compabetov2
{ {
panelEnvio.Controls.Clear(); panelEnvio.Controls.Clear();
List<Envio> envios = service.conseguirEnvio(); List<Envio> envios = service.conseguirEnvio();
panelEnvio.BackColor = Color.Aqua;
foreach(Envio envio in envios) foreach(Envio envio in envios)
{ {
TableLayoutPanel carta = new TableLayoutPanel(); TableLayoutPanel carta = new TableLayoutPanel();
carta.ColumnCount = 1; carta.ColumnCount = 1;
carta.RowCount = 2; carta.RowCount = 2;
carta.RowStyles.Add(new RowStyle(SizeType.Percent, 80F)); carta.RowStyles.Add(new RowStyle(SizeType.Percent, 75F));
carta.RowStyles.Add(new RowStyle(SizeType.Percent, 20F)); carta.RowStyles.Add(new RowStyle(SizeType.Percent, 25F));
carta.Width = 700; carta.Width = 700;
carta.Height = 150; carta.Height = 170;
carta.BackColor = Color.Gray;
FlowLayoutPanel infoPanel = new FlowLayoutPanel(); FlowLayoutPanel infoPanel = new FlowLayoutPanel();
infoPanel.FlowDirection = FlowDirection.TopDown; infoPanel.FlowDirection = FlowDirection.TopDown;
@@ -44,12 +43,129 @@ namespace compabetov2
Label lbFecha = new Label(); Label lbFecha = new Label();
lbFecha.Text = $"Fecha: {envio.fecha}"; lbFecha.Text = $"Fecha: {envio.fecha}";
lbFecha.Font = new Font(lbFecha.Font.FontFamily, 12);
lbFecha.Width = 700;
Label lbDireaccion = new Label(); Label lbDireaccion = new Label();
lbDireaccion.Text = $"Direccion: {envio.direccion}"; lbDireaccion.Text = $"Direccion: {envio.direccion}";
lbDireaccion.Font = new Font(lbDireaccion.Font.FontFamily, 12);
lbDireaccion.Width = 700;
Label lbTelefono = new Label();
lbTelefono.Text = $"Telefono: {envio.telefono}";
lbTelefono.Font = new Font(lbTelefono.Font.FontFamily, 12);
lbTelefono.Width = 700;
Label lbCliente = new Label();
lbCliente.Text = $"Cliente: {envio.cliente}";
lbCliente.Font = new Font(lbCliente.Font.FontFamily, 12);
lbCliente.Width = 700;
Label lbResponzable = new Label();
lbResponzable.Text = $"Responzable: {envio.responsable}";
lbResponzable.Font = new Font(lbResponzable.Font.FontFamily, 12);
lbResponzable.Width = 700;
TableLayoutPanel botonesPanel = new TableLayoutPanel();
botonesPanel.RowCount = 1;
botonesPanel.ColumnCount = 4;
botonesPanel.Dock = DockStyle.Fill;
botonesPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
botonesPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
botonesPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
botonesPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
botonesPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
Button btnDetalles = new Button();
btnDetalles.Text = "Detalles";
btnDetalles.Dock = DockStyle.Fill;
btnDetalles.FlatStyle = FlatStyle.Flat;
btnDetalles.FlatAppearance.BorderSize = 0;
btnDetalles.BackColor = Color.FromArgb(33, 90, 255);
btnDetalles.Font = new Font(btnDetalles.Font.FontFamily, 16);
btnDetalles.ForeColor = Color.White;
btnDetalles.Click += new EventHandler(delegate (object sender, EventArgs e)
{
List<DetalleEnvioModel> detalles = service.conseguirDetalleEnvio(envio.id);
string mensaje = "";
foreach (DetalleEnvioModel detalle in detalles)
{
mensaje += $"{detalle.producto.nombre} - {detalle.cantidad}\n";
}
MessageBox.Show(mensaje);
});
Button btnConcluir = new Button();
btnConcluir.Text = "Concluir";
btnConcluir.Dock = DockStyle.Fill;
btnConcluir.FlatStyle = FlatStyle.Flat;
btnConcluir.FlatAppearance.BorderSize = 0;
btnConcluir.BackColor = Color.FromArgb(33, 90, 255);
btnConcluir.Font = new Font(btnDetalles.Font.FontFamily, 16);
btnConcluir.ForeColor = Color.White;
btnConcluir.Click += new EventHandler(delegate (object sender, EventArgs e)
{
List<DetalleEnvioModel> detalles = service.conseguirDetalleEnvio(envio.id);
string mensaje = "";
foreach (DetalleEnvioModel detalle in detalles)
{
mensaje += $"{detalle.producto.nombre} - {detalle.cantidad}\n";
}
MessageBox.Show(mensaje);
});
Button btnCancelar = new Button();
btnCancelar.Text = "Cancelar";
btnCancelar.Dock = DockStyle.Fill;
btnCancelar.FlatStyle = FlatStyle.Flat;
btnCancelar.FlatAppearance.BorderSize = 0;
btnCancelar.BackColor = Color.Red;
btnCancelar.Font = new Font(btnDetalles.Font.FontFamily, 16);
btnCancelar.Click += new EventHandler(delegate (object sender, EventArgs e)
{
List<DetalleEnvioModel> detalles = service.conseguirDetalleEnvio(envio.id);
string mensaje = "";
foreach (DetalleEnvioModel detalle in detalles)
{
mensaje += $"{detalle.producto.nombre} - {detalle.cantidad}\n";
}
MessageBox.Show(mensaje);
});
Button btnAgregar = new Button();
btnAgregar.Text = "Agregar";
btnAgregar.Dock = DockStyle.Fill;
btnAgregar.FlatStyle = FlatStyle.Flat;
btnAgregar.FlatAppearance.BorderSize = 0;
btnAgregar.BackColor = Color.FromArgb(33, 90, 255);
btnAgregar.Font = new Font(btnDetalles.Font.FontFamily, 16);
btnAgregar.ForeColor = Color.White;
btnAgregar.Click += new EventHandler(delegate (object sender, EventArgs e)
{
List<DetalleEnvioModel> detalles = service.conseguirDetalleEnvio(envio.id);
string mensaje = "";
foreach (DetalleEnvioModel detalle in detalles)
{
mensaje += $"{detalle.producto.nombre} - {detalle.cantidad}\n";
}
MessageBox.Show(mensaje);
});
infoPanel.Controls.Add(lbFecha);
infoPanel.Controls.Add(lbResponzable);
infoPanel.Controls.Add(lbCliente);
infoPanel.Controls.Add(lbDireaccion);
infoPanel.Controls.Add(lbTelefono);
botonesPanel.Controls.Add(btnDetalles, 0, 0);
botonesPanel.Controls.Add(btnConcluir, 1, 0);
botonesPanel.Controls.Add(btnAgregar, 2, 0);
botonesPanel.Controls.Add(btnCancelar, 3, 0);
carta.Controls.Add(infoPanel,0,0);
carta.Controls.Add(botonesPanel,0,1);
panelEnvio.Controls.Add(carta); panelEnvio.Controls.Add(carta);
} }
+1 -1
View File
@@ -708,7 +708,7 @@ namespace compabetov2
{ {
List<DetalleEnvioModel> detallesEnvio = listaProductosEnvio(); List<DetalleEnvioModel> detallesEnvio = listaProductosEnvio();
string responsable = responsablecb.Text.Equals("") ? loginPrincipal.usuario : responsablecb.Text; string responsable = responsablecb.Text.Equals("") ? loginPrincipal.usuario : responsablecb.Text;
Envio envio = new Envio(-1, DateTime.Now.ToString(), "", "", responsable); Envio envio = new Envio(-1, DateTime.Now.ToString(), "", "", responsable,"","",total);
if(detallesEnvio.Count > 0){ if(detallesEnvio.Count > 0){
if (service.crearEnvio(envio, detallesEnvio)) if (service.crearEnvio(envio, detallesEnvio))
{ {
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
+27 -1
View File
@@ -1212,7 +1212,7 @@ namespace compabetov2.database
{ {
try try
{ {
string sqlEnvio = "INSERT INTO envios (fecha, direccion, telefono) VALUES(@fecha,@direccion , @telefono);"; string sqlEnvio = "INSERT INTO envios (fecha, direccion, telefono,total) VALUES(@fecha,@direccion , @telefono,@total);";
string sqlDetalle = "INSERT INTO detalle_envios (fk_envios, fk_producto, cantidad) VALUES(@fk_envios, @fk_producto, @cantidad);"; string sqlDetalle = "INSERT INTO detalle_envios (fk_envios, fk_producto, cantidad) VALUES(@fk_envios, @fk_producto, @cantidad);";
string sqlIdCuenta = "SELECT idEnvios FROM envios ORDER BY idEnvios DESC LIMIT 1"; string sqlIdCuenta = "SELECT idEnvios FROM envios ORDER BY idEnvios DESC LIMIT 1";
@@ -1220,6 +1220,7 @@ namespace compabetov2.database
commandCuenta.Parameters.AddWithValue("@fecha", envio.fecha); commandCuenta.Parameters.AddWithValue("@fecha", envio.fecha);
commandCuenta.Parameters.AddWithValue("@direccion", ""); commandCuenta.Parameters.AddWithValue("@direccion", "");
commandCuenta.Parameters.AddWithValue("@telefono", ""); commandCuenta.Parameters.AddWithValue("@telefono", "");
commandCuenta.Parameters.AddWithValue("@total", envio.total);
commandCuenta.ExecuteNonQuery(); commandCuenta.ExecuteNonQuery();
SQLiteCommand commandConsulta = new SQLiteCommand(sqlIdCuenta, conexion); SQLiteCommand commandConsulta = new SQLiteCommand(sqlIdCuenta, conexion);
@@ -1283,6 +1284,31 @@ namespace compabetov2.database
} }
} }
public static SQLiteDataReader conseguirDetalleEnvioDAO(int idEnvio)
{
SQLiteDataReader reader = null;
var db_conexion = new Conexion();
try
{
SQLiteConnection conexion = db_conexion.get_connection();
conexion.Open();
string sql = "Select p.idproducto, p.nombre , de.cantidad from detalle_envios de, Producto p WHERE de.fk_producto = p.idproducto and de.fk_envios = @fk_envios;";
SQLiteCommand command = new SQLiteCommand(sql, conexion);
command.Parameters.AddWithValue("@fk_envios", idEnvio);
reader = command.ExecuteReader();
return reader;
}
catch (SQLiteException ex)
{
MessageBox.Show(ex.Message);
return reader;
}
}
private static void crearDB() private static void crearDB()
{ {
var db_conexion = new Conexion(); var db_conexion = new Conexion();
+7 -1
View File
@@ -13,13 +13,19 @@ namespace compabetov2.database.modelos
public string direccion; public string direccion;
public string telefono; public string telefono;
public string responsable; public string responsable;
public string estado;
public string cliente;
public decimal total;
public Envio(int id, string fecha, string direccion, string telefono, string responsable) { public Envio(int id, string fecha, string direccion, string telefono, string responsable,string estado,string cliente, decimal total) {
this.id = id; this.id = id;
this.fecha = fecha; this.fecha = fecha;
this.direccion = direccion; this.direccion = direccion;
this.telefono = telefono; this.telefono = telefono;
this.responsable = responsable; this.responsable = responsable;
this.estado = estado;
this.cliente = cliente;
this.total = total;
} }
} }
} }
+25 -2
View File
@@ -333,13 +333,36 @@ namespace compabetov2.database
reader.GetString(1), reader.GetString(1),
reader.GetString(2), reader.GetString(2),
reader.GetString(3), reader.GetString(3),
reader.GetString(4) reader.GetString(4),
); reader.GetString(5),
reader.GetString(7),
reader.GetDecimal(6)
) ;
envios.Add(envio); envios.Add(envio);
} }
return envios; return envios;
} }
public static List<DetalleEnvioModel> conseguirDetalleEnvio(int idEnvio)
{
List<DetalleEnvioModel> detallesEnvio = new List<DetalleEnvioModel>();
SQLiteDataReader reader = DAO.conseguirDetalleEnvioDAO(idEnvio);
while (reader.Read())
{
int idProducto = (int)reader.GetInt64(0);
DetalleEnvioModel detalleEnvio = new DetalleEnvioModel(
idEnvio,
new Producto(idProducto, reader["nombre"].ToString()),
(int)reader.GetInt64(2)
);
detallesEnvio.Add(detalleEnvio);
}
return detallesEnvio;
}
} }
} }
Binary file not shown.
Binary file not shown.