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 btnAddCargo_Click(object sender, EventArgs e) { if (IsReadyToSaveFirst()) { int movimientoID = DataUtil.GetNewId("movimientos"); string tipoMovimiento = "RETIRO"; if (rbtnDeposito.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On) { totalDeposito = totalDeposito + DataUtil.GetDouble(txtImporte.Text); tipoMovimiento = "DEPOSITO"; } else { totalRetiro = totalRetiro + DataUtil.GetDouble(txtImporte.Text); } string sqlForExecute = "INSERT INTO movimientos (" + "Movimiento_id," + "Turno_id," + "Estacion_id," + "Tipo_movimiento," + "Concepto," + "Referencia," + "Importe," + "Fecha_creacion," + "Creado_por)" + " VALUES (" + movimientoID + "," + "" + lblTurno.Text + "," + "" + ((System.Web.UI.WebControls.ListItem)(cbEstacion.SelectedItem)).Value + "," + "'" + tipoMovimiento + "'," + "'" + txtConcepto.Text.Trim() + "'," + "'" + txtReferencia.Text.Trim() + "'," + "'" + DataUtil.GetDouble(txtImporte.Text) + "'," + "'" + DateTime.Now + "'," + "'" + AppConstant.EmployeeInfo.Codigo + "'" + ")"; if (DataUtil.Update(sqlForExecute)) { totalGeneral = totalRetiro + totalDeposito; txtDepositro.Text = totalDeposito.ToString(DataUtil.Format.Decimals); txtRetiro.Text = totalRetiro.ToString(DataUtil.Format.Decimals); txtTotal.Text = totalGeneral.ToString(DataUtil.Format.Decimals); string[] row = { DataUtil.GetString(movimientoID), DataUtil.GetString(tipoMovimiento), DataUtil.GetString(txtConcepto.Text.Trim()), DataUtil.GetCurrency(txtImporte.Text), DataUtil.GetString(DateTime.Now) }; dgwCuenta.Rows.Add(row); txtConcepto.Text = string.Empty; txtReferencia.Text = string.Empty; txtImporte.Text = string.Empty; MessageBox.Show("Registro grabado correctamente", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); txtConcepto.Focus(); } } }
private void btnSave_Click(object sender, EventArgs e) { if (IsReadyToSave()) { string sqlForExecute = string.Empty; try { string categoriaWhere = "Producto_categoria_descripcion = '" + DataUtil.GetString(cbCategoria.SelectedItem) + "'"; if (adding) { sqlForExecute = "INSERT INTO " + tableName + " (" + formWhereField + "," + "Producto_sub_categoria_descripcion," + "Producto_categoria_id," + "Estado," + "Fecha_creacion," + "Creado_por," + "Fecha_actualizacion," + "Actualizado_por)" + " VALUES (" + DataUtil.GetNewId(tableName) + "," + "'" + txtDescripcion.Text.Trim() + "'," + "'" + DataUtil.FindSingleRow("producto_categoria", "Producto_categoria_id", categoriaWhere) + "'," + "'" + cbEstado.SelectedItem + "'," + "'" + DateTime.Now + "'," + "'" + AppConstant.EmployeeInfo.Codigo + "'," + "'" + DateTime.Now + "'," + "'" + AppConstant.EmployeeInfo.Codigo + "'" + ")"; } else { sqlForExecute = "UPDATE " + tableName + " SET " + " Producto_sub_categoria_descripcion = '" + txtDescripcion.Text.Trim() + "'" + ", Producto_categoria_id = '" + DataUtil.FindSingleRow("producto_categoria", "Producto_categoria_id", categoriaWhere) + "'" + ", Estado = '" + cbEstado.SelectedItem + "'" + ", Fecha_actualizacion = '" + DateTime.Now + "'" + ", Actualizado_por = '" + AppConstant.EmployeeInfo.Codigo + "'" + " WHERE " + formWhereField + " = " + txtCodigo.Text; } if (DataUtil.Update(sqlForExecute)) { MessageBox.Show("Registro grabado correctamente", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); if (adding) { this.Close(); } } } 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 btnSave_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show(@"Está seguro de abrir el turno?", @"Abrir", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (IsReadyToSave()) { try { if (adding) { txtCodigo.Text = DataUtil.GetString(DataUtil.GetNewId(tableName)); sqlForExecute = "INSERT INTO " + tableName + " (" + formWhereField + "," + "Estado," + "Fondo_inicial_total," + "Venta_total," + "Fecha_apertura," + "Aperturado_por)" + " VALUES (" + txtCodigo.Text + "," + "'ABIERTO'," + "" + txtFondoInicialTotal.Text + "," + "'0.00'," + "'" + DateTime.Now + "'," + "'" + AppConstant.EmployeeInfo.Codigo + "'" + ")"; } if (DataUtil.Update(sqlForExecute)) { AgregarTurnoEstacion(DataUtil.GetInt(txtCodigo.Text)); if (adding) { this.Close(); } } } catch (Exception ex) { MessageBox.Show("Error en Grabar: " + ex.Message + " " + sqlForExecute); } } } }
private void UpdateLog(int recordId, string field, string oldValue, string newValue) { var sqlForExecute = "INSERT INTO Estacion_Log (" + "Estacion_Log_id," + "Estacion_id," + "Campo," + "Valor_antiguo," + "Valor_nuevo," + "Fecha_actualizacion," + "Actualizado_por)" + " VALUES (" + DataUtil.GetNewId("Estacion_Log") + "," + recordId + "," + "'" + field + "'," + "'" + oldValue + "'," + "'" + newValue + "'," + "'" + DateTime.Now + "'," + "'" + AppConstant.EmployeeInfo.Codigo + "'" + ")"; DataUtil.Update(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 btnSave_Click(object sender, EventArgs e) { if (IsReadyToSave()) { try { string sqlForExecute; if (adding) { txtCodigo.Text = DataUtil.GetString(DataUtil.GetNewId(tableName)); sqlForExecute = "INSERT INTO " + tableName + " (" + formWhereField + "," + "Cliente_apellidos," + "Cliente_nombres," + "Cliente_direccion," + "Telefono_casa," + "Telefono_celular," + "Telefono_trabajo," + "Documento," + "Tipo_documento," + "Comentario," + "Email_principal," + "Estado," + "Fecha_creacion," + "Creado_por," + "Fecha_actualizacion," + "Actualizado_por)" + " VALUES (" + txtCodigo.Text + "," + "'" + txtApellidos.Text.Trim().Replace("'", "''") + "'," + "'" + txtNombres.Text.Trim().Replace("'", "''") + "'," + "'" + txtDireccion.Text.Trim() + "'," + "'" + txtTelefono.Text.Trim() + "'," + "'" + txtCelular.Text.Trim() + "'," + "'" + txtTrabajo.Text.Trim() + "'," + "'" + txtDocumento.Text.Trim() + "'," + "'" + cbTipo.SelectedItem + "'," + "'" + txtComentarios.Text.Trim() + "'," + "'" + cbEmail.SelectedItem + "'," + "'" + cbEstado.SelectedItem + "'," + "'" + DateTime.Now + "'," + "'" + AppConstant.EmployeeInfo.Codigo + "'," + "'" + DateTime.Now + "'," + "'" + AppConstant.EmployeeInfo.Codigo + "'" + ")"; } else { sqlForExecute = "UPDATE " + tableName + " SET " + "Cliente_nombres = '" + txtNombres.Text.Trim().Replace("'", "''") + "'" + ", Cliente_apellidos = '" + txtApellidos.Text.Trim().Replace("'", "''") + "'" + ", Cliente_direccion = '" + txtDireccion.Text.Trim() + "'" + ", Telefono_casa = '" + txtTelefono.Text.Trim() + "'" + ", Telefono_celular = '" + txtCelular.Text.Trim() + "'" + ", Telefono_trabajo = '" + txtTrabajo.Text.Trim() + "'" + ", Email_principal = '" + cbEmail.SelectedItem + "'" + ", Comentario = '" + txtComentarios.Text.Trim() + "'" + ", Documento = '" + txtDocumento.Text.Trim() + "'" + ", Tipo_documento = '" + cbTipo.SelectedItem + "'" + ", Estado = '" + cbEstado.SelectedItem + "'" + ", Fecha_actualizacion = '" + DateTime.Now + "'" + ", Actualizado_por = '" + AppConstant.EmployeeInfo.Codigo + "'" + " WHERE " + formWhereField + " = " + txtCodigo.Text; } if (DataUtil.Update(sqlForExecute)) { MessageBox.Show(@"Registro grabado correctamente", @"Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); if (adding) { if (CreateSpecial) { if (cbTipo.SelectedItem.Equals("RUC")) { AppConstant.Customer.ClienteNombre = txtApellidos.Text.Trim(); } else { AppConstant.Customer.ClienteNombre = txtApellidos.Text.Trim() + ", " + txtNombres.Text.Trim(); } AppConstant.Customer.ClienteCodigo = txtCodigo.Text; AppConstant.Customer.ClienteTelefono = txtTelefono.Text; AppConstant.Customer.ClienteDireccion = txtDireccion.Text; AppConstant.Customer.ClienteDocumento = txtDocumento.Text; AppConstant.Customer.ClienteTipoDocumento = cbTipo.SelectedItem.ToString(); } Close(); } } } catch (Exception ex) { MessageBox.Show(@"Error en Grabar: " + ex.Message); } } }
private void btnSave_Click(object sender, EventArgs e) { if (IsReadyToSave()) { string sqlForExecute = string.Empty; try { string categoriaWhere = "Producto_categoria_descripcion = '" + DataUtil.GetString(cbCategoria.SelectedItem) + "'"; string subCategoriaWhere = "Producto_sub_categoria_descripcion = '" + DataUtil.GetString(cbSubCategoria.SelectedItem) + "'"; string proveedorWhere = "Proveedor_nombre = '" + DataUtil.GetString(cbProveedor.SelectedItem) + "'"; string proveedorValue = "null"; if (DataUtil.GetString(cbProveedor.SelectedItem) != string.Empty) { proveedorValue = DataUtil.FindSingleRow("proveedor", "Proveedor_id", proveedorWhere); } string alertaFueraStock = cbStock.Checked ? "1" : "0"; if (adding) { txtCodigo.Text = DataUtil.GetString(DataUtil.GetNewId(tableName)); if (DataUtil.GetString(cbProveedor.SelectedItem) != string.Empty) { proveedorValue = "'" + proveedorValue + "',"; } else { proveedorValue = "" + proveedorValue + ","; } string descripcion = txtDescripcion.Text.Trim(); if (DataUtil.GetString(cbTipoProducto.SelectedItem).Equals("ADICIONAL")) { descripcion = "- " + txtDescripcion.Text.Trim(); } sqlForExecute = "INSERT INTO " + tableName + " (" + formWhereField + "," + "Producto_descripcion," + "Producto_descripcion_corta," + "Producto_categoria_id," + "Producto_sub_categoria_id," + "Proveedor_id," + "Precio_proveedor," + "Margen_ganancia," + "Precio_final," + "Producto_tipo," + "Cantidad_actual," + "Alerta_fuera_stock," + "Cantidad_fuera_stock," + "Fecha_creacion," + "Creado_por," + "Fecha_actualizacion," + "Actualizado_por," + "Estado)" + " VALUES (" + txtCodigo.Text + "," + "'" + descripcion.Replace("'", "''") + "'," + "'" + txtDescripcionCorta.Text.Replace("'", "''") + "'," + "'" + DataUtil.FindSingleRow("producto_categoria", "Producto_categoria_id", categoriaWhere) + "'," + "'" + DataUtil.FindSingleRow("producto_sub_categoria", "Producto_sub_categoria_id", subCategoriaWhere) + "'," + proveedorValue + "'" + txtPrecioProveedor.Text.Trim() + "'," + "'" + txtMargen.Text.Trim() + "'," + "'" + txtPrecioFinal.Text.Trim() + "'," + "'" + cbTipoProducto.SelectedItem + "'," + "'" + txtStock.Text.Trim() + "'," + "'" + alertaFueraStock + "'," + "'" + txtStockAlert.Text.Trim() + "'," + "'" + DateTime.Now + "'," + "'" + AppConstant.EmployeeInfo.Codigo + "'," + "'" + DateTime.Now + "'," + "'" + AppConstant.EmployeeInfo.Codigo + "'," + "'" + cbEstado.SelectedItem + "'" + ")"; } else { if (DataUtil.GetString(cbProveedor.SelectedItem) != string.Empty) { proveedorValue = ", Proveedor_id = '" + proveedorValue + "'"; } else { proveedorValue = ", Proveedor_id = " + proveedorValue + ""; } sqlForExecute = "UPDATE " + tableName + " SET " + "Producto_descripcion = '" + txtDescripcion.Text.Trim().Replace("'", "''") + "'" + ",Producto_descripcion_corta = '" + txtDescripcionCorta.Text.Trim().Replace("'", "''") + "'" + ", Producto_categoria_id = '" + DataUtil.FindSingleRow("producto_categoria", "Producto_categoria_id", categoriaWhere) + "'" + ", Producto_sub_categoria_id = '" + DataUtil.FindSingleRow("producto_sub_categoria", "Producto_sub_categoria_id", subCategoriaWhere) + "'" + proveedorValue + ", Precio_proveedor = '" + txtPrecioProveedor.Text.Trim() + "'" + ", Margen_ganancia = '" + txtMargen.Text.Trim() + "'" + ", Precio_final = '" + txtPrecioFinal.Text.Trim() + "'" + ", Producto_tipo = '" + cbTipoProducto.SelectedItem + "'" + ", Cantidad_actual = '" + txtStock.Text.Trim() + "'" + ", Alerta_fuera_stock = '" + alertaFueraStock + "'" + ", Cantidad_fuera_stock = '" + txtStockAlert.Text.Trim() + "'" + ", Fecha_actualizacion = '" + DateTime.Now + "'" + ", Actualizado_por = '" + AppConstant.EmployeeInfo.Codigo + "'" + ", Estado = '" + cbEstado.SelectedItem + "'" + " WHERE " + formWhereField + " = " + txtCodigo.Text; } if (DataUtil.Update(sqlForExecute)) { MessageBox.Show("Registro grabado correctamente", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); if (adding) { if (createSpecial) { AppConstant.Product.ProductoDescription = txtDescripcion.Text.Trim(); AppConstant.Product.ProductoDescriptionCorta = txtDescripcionCorta.Text.Trim(); AppConstant.Product.ProductoCodigo = txtCodigo.Text; AppConstant.Product.ProductoPrecio = txtPrecioFinal.Text; AppConstant.Product.ProductoPrecioProveedor = txtPrecioProveedor.Text; } this.Close(); } else { oldEstado = DataUtil.GetString(cbEstado.SelectedItem); } } } catch (Exception ex) { MessageBox.Show("Error en Grabar: " + ex.Message); } } }
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 btnSave_Click(object sender, EventArgs e) { if (IsReadyToSave()) { string sqlForExecute = string.Empty; try { string grupoWhere = "Insumo_grupo_descripcion = '" + DataUtil.GetString(cbGrupo.SelectedItem) + "'"; string insumoWhere = "Insumo_descripcion = '" + DataUtil.GetString(cbInsumoBase.SelectedItem) + "'"; string proveedorWhere = "Proveedor_nombre = '" + DataUtil.GetString(cbProveedor.SelectedItem) + "'"; string proveedorValue = "null"; string insumoValue = "null"; if (DataUtil.GetString(cbProveedor.SelectedItem) != string.Empty) { proveedorValue = DataUtil.FindSingleRow("proveedor", "Proveedor_id", proveedorWhere); } if (DataUtil.GetString(cbInsumoBase.SelectedItem) != string.Empty) { insumoValue = DataUtil.FindSingleRow("insumo", "Insumo_id", proveedorWhere); } if (adding) { txtCodigo.Text = DataUtil.GetString(DataUtil.GetNewId(tableName)); if (DataUtil.GetString(cbProveedor.SelectedItem) != string.Empty) { proveedorValue = "'" + proveedorValue + "',"; } else { proveedorValue = "" + proveedorValue + ","; } if (DataUtil.GetString(cbInsumoBase.SelectedItem) != string.Empty) { insumoValue = "'" + insumoValue + "',"; } else { insumoValue = "" + insumoValue + ","; } sqlForExecute = "INSERT INTO " + tableName + " (" + formWhereField + "," + "Insumo_grupo_id," + "Presentacion_descripcion," + "Ultimo_costo," + "Costo_promedio," + "IGV," + "Costo_impuesto," + "Proveedor_id," + "Insumo_base_id," + "Rendimiento_valor," + "Rendimiento_unidad," + "Fecha_creacion," + "Creado_por," + "Fecha_actualizacion," + "Actualizado_por," + "Estado)" + " VALUES (" + txtCodigo.Text + "," + "'" + DataUtil.FindSingleRow("Insumo_grupo", "Insumo_grupo_id", grupoWhere) + "'," + "'" + txtDescripcion.Text.Replace("'", "''") + "'," + "'" + txtUltimoCosto.Text.Trim() + "'," + "'" + txtCostoPromedio.Text.Trim() + "'," + "'" + txtIGV.Text.Trim() + "'," + "'" + txtCostoImpuesto.Text.Trim() + "'," + proveedorValue + insumoValue + "'" + txtRendimiento.Text.Trim() + "'," + "'" + txtRendimientoUnidad.Text.Trim() + "'," + "'" + DateTime.Now + "'," + "'" + AppConstant.EmployeeInfo.Codigo + "'," + "'" + DateTime.Now + "'," + "'" + AppConstant.EmployeeInfo.Codigo + "'," + "'" + cbEstado.SelectedItem + "'" + ")"; } else { if (DataUtil.GetString(cbProveedor.SelectedItem) != string.Empty) { proveedorValue = ", Proveedor_id = '" + proveedorValue + "'"; } else { proveedorValue = ", Proveedor_id = " + proveedorValue + ""; } if (DataUtil.GetString(cbInsumoBase.SelectedItem) != string.Empty) { insumoValue = ", Insumo_base_id = '" + insumoValue + "'"; } else { insumoValue = ", Insumo_base_id = " + insumoValue + ""; } sqlForExecute = "UPDATE " + tableName + " SET " + " Insumo_grupo_id = '" + DataUtil.FindSingleRow("Insumo_grupo", "Insumo_grupo_id", grupoWhere) + "'" + ",Presentacion_descripcion = '" + txtDescripcion.Text.Trim().Replace("'", "''") + "'" + ",Ultimo_costo = '" + txtUltimoCosto.Text.Trim() + "'" + ",Costo_promedio = '" + txtCostoPromedio.Text.Trim() + "'" + ",IGV = '" + txtIGV.Text.Trim() + "'" + ",Costo_impuesto = '" + txtCostoImpuesto.Text.Trim() + "'" + proveedorValue + insumoValue + ",Rendimiento_valor = '" + txtRendimiento.Text.Trim() + "'" + ",Rendimiento_unidad = '" + txtRendimientoUnidad.Text.Trim() + "'" + ", Fecha_actualizacion = '" + DateTime.Now + "'" + ", Actualizado_por = '" + AppConstant.EmployeeInfo.Codigo + "'" + ", Estado = '" + cbEstado.SelectedItem + "'" + " WHERE " + formWhereField + " = " + txtCodigo.Text; } if (DataUtil.Update(sqlForExecute)) { MessageBox.Show("Registro grabado correctamente", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); if (adding) { this.Close(); } } } 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); } }
private void btnSave_Click(object sender, EventArgs e) { if (IsReadyToSave()) { var dtpFechaNacimientoObj = "'" + DataUtil.GetString(dtpFechaNacimiento.Value) + "'"; var dtpFechaIngresoObj = "'" + DataUtil.GetString(dtpFechaIngreso.Value) + "'"; if (dtpFechaNacimiento.Value == DateTime.MinValue) { dtpFechaNacimientoObj = "null"; } if (dtpFechaIngreso.Value == DateTime.MinValue) { dtpFechaIngresoObj = "null"; } try { string sqlForExecute; if (adding) { sqlForExecute = "INSERT INTO " + tableName + " (" + formWhereField + "," + "Nombres_empleado," + "Apellidos_empleado," + "Direccion," + "Telefono_fijo," + "Celular," + "Email," + "Fecha_nacimiento," + "Fecha_ingreso," + "[Password]," + "Comentarios," + "Estado," + "Cargo," + "Fecha_creacion," + "Creado_por," + "Fecha_actualizacion," + "Actualizado_por)" + " VALUES (" + DataUtil.GetNewId(tableName) + "," + "'" + txtNombres.Text.Trim() + "'," + "'" + txtApellidos.Text.Trim() + "'," + "'" + txtDireccion.Text.Trim() + "'," + "'" + txtTelefono.Text.Trim() + "'," + "'" + txtCelular.Text.Trim() + "'," + "'" + txtEmail.Text.Trim() + "'," + "" + dtpFechaNacimientoObj + "," + "" + dtpFechaIngresoObj + "," + "'" + txtPassword.Text.Trim() + "'," + "'" + txtComentarios.Text.Trim() + "'," + "'" + cbEstado.SelectedItem + "'," + "'" + cbCargo.SelectedItem + "'," + "'" + DateTime.Now + "'," + "'" + AppConstant.EmployeeInfo.Codigo + "'," + "'" + DateTime.Now + "'," + "'" + AppConstant.EmployeeInfo.Codigo + "'" + ")"; } else { sqlForExecute = "UPDATE " + tableName + " SET " + "Nombres_empleado = '" + txtNombres.Text.Trim() + "'" + ", Apellidos_empleado = '" + txtApellidos.Text.Trim() + "'" + ", Direccion = '" + txtDireccion.Text.Trim() + "'" + ", Telefono_fijo = '" + txtTelefono.Text.Trim() + "'" + ", Celular = '" + txtCelular.Text.Trim() + "'" + ", Email = '" + txtEmail.Text.Trim() + "'" + ", Comentarios = '" + txtComentarios.Text.Trim() + "'" + ", Estado = '" + cbEstado.SelectedItem + "'" + ", Cargo = '" + cbCargo.SelectedItem + "'" + ", Fecha_nacimiento = " + dtpFechaNacimientoObj + "" + ", Fecha_ingreso = " + dtpFechaIngresoObj + "" + ", Fecha_actualizacion = '" + DateTime.Now + "'" + ", Actualizado_por = '" + AppConstant.EmployeeInfo.Codigo + "'" + " WHERE " + formWhereField + " = " + txtCodigo.Text; } if (DataUtil.Update(sqlForExecute)) { MessageBox.Show(@"Registro grabado correctamente", @"Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); if (adding) { Close(); } } } catch (Exception ex) { MessageBox.Show(@"Error en Grabar: " + ex.Message); } } }
private void btnSave_Click(object sender, EventArgs e) { if (IsReadyToSave()) { var tableId = 0; try { string sqlForExecute; if (adding) { tableId = DataUtil.GetNewId(tableName); sqlForExecute = "INSERT INTO " + tableName + " (" + formWhereField + "," + "Estacion_descripcion," + "Persona_asignada," + "Estado," + "Fecha_creacion," + "Creado_por," + "Fecha_actualizacion," + "Actualizado_por)" + " VALUES (" + tableId + "," + "'" + txtDescripcion.Text.Trim() + "'," + "'" + ((System.Web.UI.WebControls.ListItem)(cbCajero.SelectedItem)).Value + "'," + "'" + cbEstado.SelectedItem + "'," + "'" + DateTime.Now + "'," + "'" + AppConstant.EmployeeInfo.Codigo + "'," + "'" + DateTime.Now + "'," + "'" + AppConstant.EmployeeInfo.Codigo + "'" + ")"; } else { sqlForExecute = "UPDATE " + tableName + " SET " + "Estacion_descripcion = '" + txtDescripcion.Text.Trim() + "'" + ", Estado = '" + cbEstado.SelectedItem + "'" + ", Persona_asignada = '" + ((System.Web.UI.WebControls.ListItem)(cbCajero.SelectedItem)).Value + "'" + ", Fecha_actualizacion = '" + DateTime.Now + "'" + ", Actualizado_por = '" + AppConstant.EmployeeInfo.Codigo + "'" + " WHERE " + formWhereField + " = " + txtCodigo.Text; } if (DataUtil.Update(sqlForExecute)) { if (adding) { UpdateLog(tableId, "Cajero Asignado", string.Empty, cbCajero.SelectedItem.ToString()); } else { oldEstado = DataUtil.GetString(cbEstado.SelectedItem); if (personaAsignadaOld != DataUtil.GetString(cbCajero.SelectedItem)) { UpdateLog(tableId, "Cajero Asignado", personaAsignadaOld, cbCajero.SelectedItem.ToString()); } } MessageBox.Show(@"Registro grabado correctamente", @"Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); if (adding) { Close(); } } } catch (Exception ex) { MessageBox.Show(@"Error en Grabar: " + ex.Message); } } }
private void btnSave_Click(object sender, EventArgs e) { if (IsReadyToSave()) { string sqlForExecute = string.Empty; try { if (adding) { sqlForExecute = "INSERT INTO " + tableName + " (" + formWhereField + "," + "Proveedor_nombre," + "Proveedor_ruc," + "Proveedor_Telefono," + "Proveedor_Fax," + "Proveedor_web," + "Proveedor_email," + "Proveedor_comentarios," + "Proveedor_contacto," + "Estado," + "Fecha_creacion," + "Creado_por," + "Fecha_actualizacion," + "Actualizado_por)" + " VALUES (" + DataUtil.GetNewId(tableName) + "," + "'" + txtNombre.Text.Trim() + "'," + "'" + txtDocumento.Text.Trim() + "'," + "'" + txtTelefono.Text.Trim() + "'," + "'" + txtFax.Text.Trim() + "'," + "'" + txtWeb.Text.Trim() + "'," + "'" + txtEmail.Text.Trim() + "'," + "'" + txtComentarios.Text.Trim() + "'," + "'" + txtContacto.Text.Trim() + "'," + "'" + cbEstado.SelectedItem + "'," + "'" + DateTime.Now + "'," + "'" + AppConstant.EmployeeInfo.Codigo + "'," + "'" + DateTime.Now + "'," + "'" + AppConstant.EmployeeInfo.Codigo + "'" + ")"; } else { sqlForExecute = "UPDATE " + tableName + " SET " + "Proveedor_nombre = '" + txtNombre.Text.Trim() + "'" + ", Proveedor_ruc = '" + txtDocumento.Text.Trim() + "'" + ", Proveedor_Telefono = '" + txtTelefono.Text.Trim() + "'" + ", Proveedor_Fax = '" + txtFax.Text.Trim() + "'" + ", Proveedor_web = '" + txtWeb.Text.Trim() + "'" + ", Proveedor_email = '" + txtEmail.Text.Trim() + "'" + ", Proveedor_comentarios = '" + txtComentarios.Text.Trim() + "'" + ", Proveedor_contacto = '" + txtContacto.Text.Trim() + "'" + ", Estado = '" + cbEstado.SelectedItem + "'" + ", Fecha_actualizacion = '" + DateTime.Now + "'" + ", Actualizado_por = '" + AppConstant.EmployeeInfo.Codigo + "'" + " WHERE " + formWhereField + " = " + txtCodigo.Text; } if (DataUtil.Update(sqlForExecute)) { MessageBox.Show(@"Registro grabado correctamente", @"Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); if (adding) { this.Close(); } } } catch (Exception ex) { MessageBox.Show(@"Error en Grabar: " + ex.Message); } } }