private void btnEliminarProducto_Click_1(object sender, EventArgs e) { Int32 selectedRowCount = dtComanda.Rows.GetRowCount(DataGridViewElementStates.Selected); if (selectedRowCount == 1) { for (int i = 0; i < selectedRowCount; i++) { if (!Detalle_comanda.eliminarDetalle(Convert.ToInt32(dtComanda.SelectedRows[i].Cells["col_Id_detalle"].Value))) { Funciones.mError(this, "ERROR AL ELIMIMAR EL PRODUCTO"); } else { dtComanda.DataSource = Comanda.getComanda(id_comanda1).Tables[0].DefaultView; if (Comanda.getSubtotal(id_comanda1) == -1) { Funciones.mError(this, "ERROR OBTENIENDO SUBTOTAL"); } else { lbSubtotal.Text = "$ " + Comanda.getSubtotal(id_comanda1).ToString(); } } } } else { Funciones.mError(this, "Por favor seleccione un producto"); } }
private void btnAgregar_Click(object sender, EventArgs e) { try { int id_producto = 0; id_producto = Convert.ToInt32(txtIdProducto.Text); //Receta.getRecetas(id_producto) if (cantidad.Value > 0) { DataTable data; if (id_producto > 0) { DataSet data1 = Producto.getReceta(id_producto); if (data1.Tables[0].Rows.Count == 0 || data1 == null) { //Funciones.mError(this, "Este producto NO posee receta"); } if (Detalle_comanda.detalleRepetido(id_producto, id_comanda1)) { int cantidad1 = Convert.ToInt32(cantidad.Value); Funciones.mError(this, "repetido"); Detalle_comanda.actualizarCantidad(id_producto, id_comanda1, cantidad1); this.DialogResult = DialogResult.OK; this.Close(); } else { data = Producto.getProducto(id_producto); DataRow fila = data.Rows[0]; string nombre = fila["nombre"].ToString(); float precio_costo; precio_costo = Convert.ToSingle(fila["precio_costo"]); float precio_venta = Convert.ToSingle(fila["precio_venta"]); int cantidad1 = Convert.ToInt32(cantidad.Value); float total = cantidad1 * precio_venta; Detalle_comanda dc = new Detalle_comanda(0, id_comanda1, id_producto, nombre, cantidad1, precio_venta, precio_costo, total, 0); if (!dc.guardarDetalle()) { Funciones.mError(this, "Error al cargar el producto"); this.Close(); } else { this.DialogResult = DialogResult.OK; this.Close(); } } } } else { Funciones.mError(this, "Por Favor seleccione una cantidad"); } } catch (Exception) { Funciones.mError(this, "Ingrese solo números en 'ID DEL PRODUCTO'"); } }
private void btnAceptar_Click(object sender, EventArgs e) { Comanda c = null; int id_mozo = 0; int num_mesa = 0; int total = 0; int baja = 1; int puesto = 1; int id_comanda = Comanda.ultimo_id_comanda(); if (txtnumMesa.Value > 0) { try { id_mozo = Convert.ToInt32(comb_Mozo.SelectedValue); num_mesa = Convert.ToInt32(txtnumMesa.Value); if (!Detalle_comanda.verificarComandaAbierta(num_mesa, 1, fecha.Value, fecha.Value)) { c = new Comanda(id_comanda, puesto, fecha.Value, id_mozo, num_mesa, total, baja); } else { Funciones.mError(this, "Esta mesa se encuentra abierta"); this.Close(); // aca deberia abrir la comanda } } catch (Exception ex) { Funciones.mError(this, ex.Message); } //VALIDAR SI LA COMANDA YA NO ESTA ABIERTA PARA ESA MESA. if (c != null) { if (c.insertComanda()) { //recorre la lista de form abiertos por la alicación y devuelve el form Frm_mozo si lo encuentra Form frm = Application.OpenForms.OfType <Form>().Where(Pre => Pre.Name == "FrmTicket").SingleOrDefault(); //codigo para validar si el formulario no esta abierto con anterioridad, si no lo abre if (frm != null) { frm.Select(); frm.Show(); frm.WindowState = FormWindowState.Normal; } else { frm = new FrmTicket(Frm_Principal.fechaSistema, id_mozo, num_mesa, id_comanda, 1); frm.Show(); frm.WindowState = FormWindowState.Normal; this.DialogResult = DialogResult.OK; this.Close(); } } else { Funciones.mError(this, "Error al generar la comanda"); } } } }