private void SaveProductDeleted(string lineaNo, int codigoProducto, string descripcionProducto) { try { var pedidoProductoID = DataUtil.GetNewId("pedido_producto_eliminado"); var sqlForExecute = "INSERT INTO Pedido_Producto_Eliminado (" + "Pedido_producto_id," + "Pedido_id," + "Codigo_Producto," + "Descripcion_Producto," + "Fecha_anulacion," + "Eliminado_por)" + " VALUES (" + pedidoProductoID + "," + pedidoID + "," + codigoProducto + "," + "'" + descripcionProducto + "'," + "'" + DateTime.Now + "'," + "" + AppConstant.EmployeeInfo.Codigo + "" + ")"; DataUtil.UpdateThrow(sqlForExecute); var sqlUpdate = "DELETE FROM pedido_detalle WHERE pedido_id = " + pedidoID + " AND linea = '" + lineaNo + "'"; DataUtil.UpdateThrow(sqlUpdate); } catch (Exception ex) { MessageBox.Show(@"Error en Grabar: " + ex.Message); } }
private void UpdateCurrentAccount() { string sqlForExecute = string.Empty; try { DataUtil.Update("DELETE FROM pedido_detalle WHERE Pedido_id = " + pedidoIDView + ""); foreach (DataGridViewRow row in dgwCuenta.Rows) { string descuentoValue = DataUtil.GetString(row.Cells[4].Value); if (descuentoValue.Equals(string.Empty)) { descuentoValue = "null"; } sqlForExecute = "INSERT INTO pedido_detalle (" + "Pedido_detalle_id," + "Pedido_id," + "Linea," + "Codigo_Producto," + "Descripcion_Producto," + "Descuento," + "Cantidad," + "Impreso)" + " VALUES (" + DataUtil.GetNewId("pedido_detalle") + "," + pedidoIDView + "," + "'" + DataUtil.GetString(row.Cells[0].Value) + "'," + "" + DataUtil.GetString(row.Cells[1].Value) + "," + "'" + DataUtil.GetString(row.Cells[3].Value).Replace("'", "''") + "'," + "" + descuentoValue + "," + "'" + DataUtil.GetString(row.Cells[2].Value) + "'," + "0" + ")"; DataUtil.UpdateThrow(sqlForExecute); } sqlForExecute = "UPDATE pedido SET " + "Last_Line = " + lineGrid0 + "" + ", Fecha_actualizacion = '" + DateTime.Now + "'" + ", Actualizado_por = '" + AppConstant.EmployeeInfo.Codigo + "'" + " WHERE Pedido_id = " + pedidoIDView; DataUtil.UpdateThrow(sqlForExecute); } catch (Exception ex) { MessageBox.Show("Error en Grabar: " + ex.Message); } }
private void btnAddCargo_Click(object sender, EventArgs e) { if (cbEstacion.SelectedItem != null && txtMontoInicial.Text.Trim() != string.Empty) { if (!ExisteEstacion(((System.Web.UI.WebControls.ListItem)(cbEstacion.SelectedItem)).Text)) { lineGrid = lineGrid + 1; string[] row = { DataUtil.GetString(lineGrid), ((System.Web.UI.WebControls.ListItem)(cbEstacion.SelectedItem)).Text, txtMontoInicial.Text, ((System.Web.UI.WebControls.ListItem)(cbEstacion.SelectedItem)).Value }; dgwCuenta.Rows.Add(row); CalculoMontoInicial(DataUtil.GetDouble(txtMontoInicial.Text), true); if (!adding) { sqlForExecute = "UPDATE " + tableName + " SET Fondo_inicial_total = " + txtFondoInicialTotal.Text + "" + " WHERE " + formWhereField + " = " + txtCodigo.Text; DataUtil.Update(sqlForExecute); sqlForExecute = "INSERT INTO Turno_Estacion (" + "Turno_id," + "Estacion_id," + "Linea," + "Fondo_inicial)" + " VALUES (" + txtCodigo.Text + "," + ((System.Web.UI.WebControls.ListItem)(cbEstacion.SelectedItem)).Value + "," + "'" + DataUtil.GetString(lineGrid) + "'," + "" + txtMontoInicial.Text + "" + ")"; DataUtil.UpdateThrow(sqlForExecute); } cbEstacion.Text = string.Empty; txtMontoInicial.Text = AppConstant.GeneralInfo.MontoCaja; cbEstacion.Focus(); } } else { cbEstacion.Focus(); MessageBox.Show(@"Debe ingresar la estacion y el monto inicial.", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnAnular_Click(object sender, EventArgs e) { string refValue = string.Empty; if (IsReadyToSave()) { if (frmInputBox.InputBox("Ingresar codigo de autorizacion", "Codigo", "empleado", "password", "1", ref refValue, true, AppConstant.GeneralInfo.PasswordAnulaciones) == DialogResult.OK) { string sqlForExecute = string.Empty; try { sqlForExecute = "UPDATE pedido SET " + "Comentarios = '" + txtComentarios.Text.Trim() + "'" + ", Estado = 'C'" + ", Fecha_anulacion = '" + DateTime.Now + "'" + ", Fecha_actualizacion = '" + DateTime.Now + "'" + ", Actualizado_por = '" + AppConstant.EmployeeInfo.Codigo + "'" + " WHERE pedido_id = " + pedidoID; DataUtil.UpdateThrow(sqlForExecute); if (mesaID != 0) { sqlForExecute = "UPDATE mesa SET " + "Mesa_estado = 'LIBRE'," + "Pedido_id = null" + " WHERE Mesa_id = " + mesaID; DataUtil.UpdateThrow(sqlForExecute); } if (DataUtil.Update(sqlForExecute)) { MessageBox.Show("Registro anulado correctamente", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } catch (Exception ex) { MessageBox.Show("Error en Grabar: " + ex.Message); } } } }
private void button1_Click(object sender, EventArgs e) { string refValue = string.Empty; if (frmInputBox.InputBox("Ingresar codigo de autorizacion", "Codigo", "empleado", "password", "1", ref refValue, true, AppConstant.GeneralInfo.PasswordCambioMesa) == DialogResult.OK) { if (sender is Button) { Button btn = sender as Button; string sqlForExecute = string.Empty; if (mesa != string.Empty) { sqlForExecute = "UPDATE mesa SET Mesa_estado = 'LIBRE'," + " Pedido_id = null" + " WHERE Mesa_id = " + mesa; DataUtil.UpdateThrow(sqlForExecute); } else { sqlForExecute = "UPDATE pedido SET Tipo_venta = 'SALON'" + " WHERE Pedido_id = " + pedidoID; DataUtil.UpdateThrow(sqlForExecute); } sqlForExecute = "UPDATE pedido SET Mesa_id = " + DataUtil.GetString(btn.Tag) + "" + ", Fecha_actualizacion = '" + DateTime.Now + "'" + ", Actualizado_por = '" + AppConstant.EmployeeInfo.Codigo + "'" + " WHERE Pedido_id = " + pedidoID; DataUtil.UpdateThrow(sqlForExecute); sqlForExecute = "UPDATE mesa SET " + "Mesa_estado = 'OCUPADA'," + "Pedido_id = " + pedidoID + "" + " WHERE Mesa_id = " + DataUtil.GetString(btn.Tag); DataUtil.UpdateThrow(sqlForExecute); MessageBox.Show("Se cambio la mesa correctamente.", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } }
private void AgregarTurnoEstacion(int turnoId) { DataUtil.Update("DELETE FROM Turno_Estacion WHERE " + formWhereField + " = " + turnoId); foreach (DataGridViewRow row in dgwCuenta.Rows) { sqlForExecute = "INSERT INTO Turno_Estacion (" + "Turno_id," + "Estacion_id," + "Linea," + "Fondo_inicial)" + " VALUES (" + turnoId + "," + DataUtil.GetInt(row.Cells[3].Value) + "," + "'" + DataUtil.GetString(row.Cells[0].Value) + "'," + "" + DataUtil.GetString(row.Cells[2].Value) + "" + ")"; DataUtil.UpdateThrow(sqlForExecute); } }
private void btnCerrarTurno_Click(object sender, EventArgs e) { var result = MessageBox.Show(@"Desea cerrar el turno actual?", @"Turno", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { string sqlForExecute; foreach (DataGridViewRow row in dgwEstaciones.Rows) { sqlForExecute = "INSERT INTO Turno_Cierre (" + "Turno_Cierre_id," + "Turno_id," + "Estacion_id," + "Estacion_texto," + "Grid," + "Descripcion," + "Cantidad," + "Importe)" + " VALUES (" + DataUtil.GetString(DataUtil.GetNewId("Turno_Cierre")) + "," + lblTurno.Text + "," + "" + DataUtil.GetString(row.Cells[0].Value) + "," + "'" + DataUtil.GetString(row.Cells[1].Value) + "'," + "'dgwEstaciones'," + "'" + DataUtil.GetString(row.Cells[1].Value).Replace("'", "''") + "'," + "0," + "" + DataUtil.GetCurrency(row.Cells[2].Value) + "" + ")"; DataUtil.UpdateThrow(sqlForExecute); } foreach (DataGridViewRow row in dgwCuentas.Rows) { sqlForExecute = "INSERT INTO Turno_Cierre (" + "Turno_Cierre_id," + "Turno_id," + "Estacion_id," + "Estacion_texto," + "Grid," + "Descripcion," + "Cantidad," + "Importe)" + " VALUES (" + DataUtil.GetString(DataUtil.GetNewId("Turno_Cierre")) + "," + lblTurno.Text + "," + "" + DataUtil.GetString(row.Cells[4].Value) + "," + "'" + DataUtil.GetString(row.Cells[0].Value) + "'," + "'dgwCuentas'," + "'" + DataUtil.GetString(row.Cells[1].Value).Replace("'", "''") + "'," + "" + DataUtil.GetString(row.Cells[2].Value) + "," + "" + DataUtil.GetCurrency(row.Cells[3].Value) + "" + ")"; DataUtil.UpdateThrow(sqlForExecute); } foreach (DataGridViewRow row in dgwMovimientos.Rows) { sqlForExecute = "INSERT INTO Turno_Cierre (" + "Turno_Cierre_id," + "Turno_id," + "Estacion_id," + "Estacion_texto," + "Grid," + "Descripcion," + "Cantidad," + "Importe)" + " VALUES (" + DataUtil.GetString(DataUtil.GetNewId("Turno_Cierre")) + "," + lblTurno.Text + "," + "" + DataUtil.GetString(row.Cells[4].Value) + "," + "'" + DataUtil.GetString(row.Cells[0].Value) + "'," + "'dgwMovimientos'," + "'" + DataUtil.GetString(row.Cells[1].Value).Replace("'", "''") + "'," + "" + DataUtil.GetString(row.Cells[2].Value) + "," + "" + DataUtil.GetCurrency(row.Cells[3].Value) + "" + ")"; DataUtil.UpdateThrow(sqlForExecute); } foreach (DataGridViewRow row in dgwExtra.Rows) { sqlForExecute = "INSERT INTO Turno_Cierre (" + "Turno_Cierre_id," + "Turno_id," + "Estacion_id," + "Estacion_texto," + "Grid," + "Descripcion," + "Cantidad," + "Importe)" + " VALUES (" + DataUtil.GetString(DataUtil.GetNewId("Turno_Cierre")) + "," + lblTurno.Text + "," + "null," + "''," + "'dgwExtra'," + "'" + DataUtil.GetString(row.Cells[0].Value).Replace("'", "''") + "'," + "" + DataUtil.GetString(row.Cells[1].Value) + "," + "0" + ")"; DataUtil.UpdateThrow(sqlForExecute); } sqlForExecute = "UPDATE turno SET " + "Estado = 'CERRADO'" + ", Fecha_cierre = '" + DateTime.Now + "'" + ", Cerrado_por = '" + AppConstant.EmployeeInfo.Codigo + "'" + ", Venta_total = '" + txtVentaTotal.Text + "'" + " WHERE Turno_id = " + lblTurno.Text; DataUtil.UpdateThrow(sqlForExecute); ImprimirReporteTurno(); MessageBox.Show(@"Turno cerrado correctamente", @"Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); AppConstant.Turno.Codigo = string.Empty; AppConstant.Turno.FechaHora = string.Empty; AppConstant.Turno.Estado = string.Empty; Close(); } }
private void PrintDocuments(int pedidoIdPrint, int rePrint) { string sqlUpdate; var reportViewerForm = new ReportViewer(); DataSet dsResult = null; bool printCocina = false; bool printBar = false; bool printCocinaOk = false; bool printBarOk = false; if (cbCocina.Checked) { dsResult = DataUtil.FillDataSet(DataBaseQuerys.ReporteCocina(pedidoIdPrint, rePrint), "pedido_detalle"); if (dsResult.Tables[0].Rows.Count > 0) { if (AppConstant.GeneralInfo.Impresora.Cocina != string.Empty) { if (AppConstant.GeneralInfo.PrintText.Cocina) { PrintByText.printDocument(AppConstant.GeneralInfo.Impresora.Cocina, dsResult, "C"); } else { reportViewerForm.dsReport = dsResult; reportViewerForm.reporteName = AppConstant.Reportes.Cocina; reportViewerForm.tableNameReport = "pedido_detalle"; reportViewerForm.printerName = string.Empty; reportViewerForm.printerName = AppConstant.GeneralInfo.Impresora.Cocina; reportViewerForm.ShowDialog(); } printCocina = true; } else { MessageBox.Show(@"La impresora de la cocina no esta configurada.", @"Informacion", MessageBoxButtons.OK, MessageBoxIcon.Warning); } sqlUpdate = "UPDATE pedido_detalle SET Impreso = 1 WHERE Codigo_Producto IN (SELECT Producto_id FROM Producto WHERE Producto_categoria_id <> 3) AND pedido_id = " + pedidoIdPrint + ""; DataUtil.UpdateThrow(sqlUpdate); } else { if (rePrint == 1) { MessageBox.Show(@"No existen nuevos productos o productos modificados.", @"Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } if (cbBar.Checked) { if (printCocina) { var diagResult = MessageBox.Show(@"Imprimio Correctamente el ticket de Cocina?", @"Impresion", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (diagResult == DialogResult.Yes) { printCocinaOk = true; } } else { printCocinaOk = true; } if (printCocinaOk) { dsResult = DataUtil.FillDataSet(DataBaseQuerys.ReporteBar(pedidoIdPrint, rePrint), "pedido_detalle"); if (dsResult.Tables[0].Rows.Count > 0) { if (AppConstant.GeneralInfo.Impresora.Bar != string.Empty) { if (AppConstant.GeneralInfo.PrintText.Bar) { PrintByText.printDocument(AppConstant.GeneralInfo.Impresora.Bar, dsResult, "B"); } else { reportViewerForm.dsReport = dsResult; reportViewerForm.reporteName = AppConstant.Reportes.Bar; reportViewerForm.tableNameReport = "pedido_detalle"; reportViewerForm.printerName = string.Empty; reportViewerForm.printerName = AppConstant.GeneralInfo.Impresora.Bar; reportViewerForm.ShowDialog(); } printBar = true; } else { MessageBox.Show(@"La impresora del Bar no esta configurada.", @"Informacion", MessageBoxButtons.OK, MessageBoxIcon.Warning); } sqlUpdate = "UPDATE pedido_detalle SET Impreso = 1 WHERE Codigo_Producto IN (SELECT Producto_id FROM Producto WHERE Producto_categoria_id = 3) AND pedido_id = " + pedidoIdPrint + ""; DataUtil.UpdateThrow(sqlUpdate); } else { if (rePrint == 1) { MessageBox.Show(@"No existen nuevos productos o productos modificados.", @"Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } }
private void btnCreateOrder_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show(@"Desea proceder a crear esta orden?", @"Crear", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (IsReadyToSave()) { try { string sqlForExecute; if (pedidoID.Equals(0)) { pedidoID = DataUtil.GetNewId("pedido"); ordenDiaID = DataUtil.GetOrderByTurn(DataUtil.GetInt(lblTurno.Text)); Text = Text + @": " + pedidoID; lblOrderDiaNo.Text = DataUtil.GetString(ordenDiaID); lblOrderDia.Visible = true; lblOrderDiaNo.Visible = true; string clienteIDValue = "null"; if (clienteID != string.Empty) { clienteIDValue = clienteID; } string mesaIDValue = "null"; if (mesaID != string.Empty) { mesaIDValue = mesaID; } sqlForExecute = "INSERT INTO pedido (" + "Pedido_id," + "Mesa_id," + "Turno_id," + "Fecha_Pedido," + "Atendido_por," + "Estado," + "Tipo_venta," + "Cliente_id," + "Orden_turno)" + " VALUES (" + pedidoID + "," + "" + mesaIDValue + "," + "" + lblTurno.Text + "," + "'" + DateTime.Now + "'," + "" + radmccbEmpleado.EditorControl.Rows[radmccbEmpleado.SelectedIndex].Cells["Codigo_empleado"].Value + "," + "'A'," + "'" + tipoVenta + "'," + "" + clienteIDValue + "," + "" + ordenDiaID + "" + ")"; DataUtil.UpdateThrow(sqlForExecute); } foreach (DataGridViewRow row in dgwCuenta.Rows) { string descuentoValue = DataUtil.GetString(row.Cells[gridDescuento].Value); if (descuentoValue.Equals(string.Empty)) { descuentoValue = "null"; } sqlForExecute = "INSERT INTO pedido_detalle (" + "Pedido_detalle_id," + "Pedido_id," + "Linea," + "Codigo_Producto," + "Descripcion_Producto," + "Descuento," + "Cantidad," + "Impreso)" + " VALUES (" + DataUtil.GetNewId("pedido_detalle") + "," + pedidoID + "," + "'" + DataUtil.GetString(row.Cells[gridLineaNumero].Value) + "'," + "" + DataUtil.GetString(row.Cells[gridProdCodigo].Value) + "," + "'" + DataUtil.GetString(row.Cells[gridProdDescripcion].Value).Replace("'", "''") + "'," + "" + descuentoValue + "," + "'" + DataUtil.GetString(row.Cells[gridCantidad].Value) + "'," + "0" + ")"; DataUtil.UpdateThrow(sqlForExecute); } if (mesaID != string.Empty) { sqlForExecute = "UPDATE mesa SET " + " Mesa_estado = 'OCUPADA'," + " Pedido_id = " + pedidoID + "" + " WHERE Mesa_id = " + mesaID; DataUtil.UpdateThrow(sqlForExecute); } sqlForExecute = "UPDATE pedido SET " + " Last_Line = " + lineGrid + "" + ", Fecha_actualizacion = '" + DateTime.Now + "'" + ", Actualizado_por = '" + radmccbEmpleado.EditorControl.Rows[radmccbEmpleado.SelectedIndex].Cells["Codigo_empleado"].Value + "'" + " WHERE Pedido_id = " + pedidoID; DataUtil.UpdateThrow(sqlForExecute); PrintDocuments(pedidoID, 0); btnReprint.Visible = true; btnCreateOrder.Visible = false; MessageBox.Show(@"Orden agregada correctamente.", @"Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); btnNewOrder.Visible = true; radmccbEmpleado.Enabled = false; ShowButtonsOrder(true); } catch (Exception ex) { MessageBox.Show(@"Error en Grabar: " + ex.Message); } } } }
private void SaveAccount(DataGridView dgvMain, int lineGrid) { int pedidoID = 0; int ordenDiaID = 0; string sqlForExecute = string.Empty; try { if (pedidoID.Equals(0)) { pedidoID = DataUtil.GetNewId("pedido"); ordenDiaID = DataUtil.GetOrderByTurn(DataUtil.GetInt(lblTurno.Text)); string clienteIDValue = "null"; if (clienteIDView != string.Empty) { clienteIDValue = clienteIDView; } string mesaIDValue = "null"; if (mesaIDView != string.Empty) { mesaIDValue = mesaIDView; } sqlForExecute = "INSERT INTO pedido (" + "Pedido_id," + "Mesa_id," + "Turno_id," + "Fecha_Pedido," + "Atendido_por," + "Estado," + "Tipo_venta," + "Cliente_id," + "Pedido_origen_id," + "Orden_turno)" + " VALUES (" + pedidoID + "," + "" + mesaIDValue + "," + "" + lblTurno.Text + "," + "'" + DateTime.Now + "'," + "" + AppConstant.EmployeeInfo.Codigo + "," + "'A'," + "'" + tipoVentaView + "'," + "" + clienteIDValue + "," + "" + pedidoIDView + "," + "" + ordenDiaID + "" + ")"; DataUtil.UpdateThrow(sqlForExecute); } foreach (DataGridViewRow row in dgvMain.Rows) { string descuentoValue = DataUtil.GetString(row.Cells[4].Value); if (descuentoValue.Equals(string.Empty)) { descuentoValue = "null"; } sqlForExecute = "INSERT INTO pedido_detalle (" + "Pedido_detalle_id," + "Pedido_id," + "Linea," + "Codigo_Producto," + "Descripcion_Producto," + "Descuento," + "Cantidad," + "Impreso)" + " VALUES (" + DataUtil.GetNewId("pedido_detalle") + "," + pedidoID + "," + "'" + DataUtil.GetString(row.Cells[0].Value) + "'," + "" + DataUtil.GetString(row.Cells[1].Value) + "," + "'" + DataUtil.GetString(row.Cells[3].Value).Replace("'", "''") + "'," + "" + descuentoValue + "," + "'" + DataUtil.GetString(row.Cells[2].Value) + "'," + "0" + ")"; DataUtil.UpdateThrow(sqlForExecute); } sqlForExecute = "UPDATE pedido SET " + "Last_Line = " + lineGrid + "" + ", Fecha_actualizacion = '" + DateTime.Now + "'" + ", Actualizado_por = '" + AppConstant.EmployeeInfo.Codigo + "'" + " WHERE Pedido_id = " + pedidoID; DataUtil.UpdateThrow(sqlForExecute); ordenesCreadas++; } catch (Exception ex) { MessageBox.Show("Error en Grabar: " + ex.Message); } }