Ejemplo n.º 1
0
        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();
                }
            }
        }
Ejemplo n.º 2
0
        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();
            }
        }
Ejemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (IsReadyToSave() && IsReadyToSaveFont())
            {
                try
                {
                    var valueAnulaciones      = "0";
                    var valueNotaVenta        = "0";
                    var valueDividirCuentas   = "0";
                    var valueCambioMesero     = "0";
                    var valueReImpresiones    = "0";
                    var valueCambioMesa       = "0";
                    var valueContrasenaSalir  = "0";
                    var valueEliminarProducto = "0";

                    var valuePreviewBar      = "0";
                    var valuePreviewCocina   = "0";
                    var valuePreviewBoletas  = "0";
                    var valuePreviewRecibos  = "0";
                    var valuePreviewReportes = "0";

                    var valueBarTexto    = "0";
                    var valueCocinaTexto = "0";

                    var valueMostrarIgvBoleta = "0";

                    if (cbAnulaciones.Checked)
                    {
                        valueAnulaciones = "1";
                    }
                    if (cbNotaVenta.Checked)
                    {
                        valueNotaVenta = "1";
                    }
                    if (cbDividirCuentas.Checked)
                    {
                        valueDividirCuentas = "1";
                    }
                    if (cbCambioMesero.Checked)
                    {
                        valueCambioMesero = "1";
                    }
                    if (cbReImpresiones.Checked)
                    {
                        valueReImpresiones = "1";
                    }
                    if (cbCambioMesa.Checked)
                    {
                        valueCambioMesa = "1";
                    }
                    if (cbContrasenaSalir.Checked)
                    {
                        valueContrasenaSalir = "1";
                    }
                    if (cbEliminarProducto.Checked)
                    {
                        valueEliminarProducto = "1";
                    }


                    if (cbPreviewBar.Checked)
                    {
                        valuePreviewBar = "1";
                    }
                    if (cbPreviewCocina.Checked)
                    {
                        valuePreviewCocina = "1";
                    }
                    if (cbPreviewBoletas.Checked)
                    {
                        valuePreviewBoletas = "1";
                    }
                    if (cbPreviewRecibos.Checked)
                    {
                        valuePreviewRecibos = "1";
                    }
                    if (cbPreviewReportes.Checked)
                    {
                        valuePreviewReportes = "1";
                    }

                    if (cbBarTexto.Checked)
                    {
                        valueBarTexto = "1";
                    }
                    if (cbCocinaTexto.Checked)
                    {
                        valueCocinaTexto = "1";
                    }

                    if (cbMostrarIGVBoletas.Checked)
                    {
                        valueMostrarIgvBoleta = "1";
                    }

                    var sqlForExecute = "UPDATE Impresora SET " +
                                        " Font_header = '" + DataUtil.GetDouble(txtFontHeaderBar.Text) + "'" +
                                        ", Font_detail = '" + DataUtil.GetDouble(txtFontDetailBar.Text) + "'" +
                                        ", Ruta = '" + cbBar.Text + "'" +
                                        ", Preview = '" + valuePreviewBar + "'" +
                                        ", Texto = '" + valueBarTexto + "'" +
                                        " WHERE tipo = 'B'";
                    DataUtil.Update(sqlForExecute);

                    sqlForExecute = "UPDATE Impresora SET " +
                                    " Font_header = '" + DataUtil.GetDouble(txtFontHeaderCocina.Text) + "'" +
                                    ", Font_detail = '" + DataUtil.GetDouble(txtFontDetailCocina.Text) + "'" +
                                    ", Ruta = '" + cbCocina.Text + "'" +
                                    ", Preview = '" + valuePreviewCocina + "'" +
                                    ", Texto = '" + valueCocinaTexto + "'" +
                                    " WHERE tipo = 'C'";
                    DataUtil.Update(sqlForExecute);

                    sqlForExecute = "UPDATE Impresora SET " +
                                    " Font_header = '" + DataUtil.GetDouble(txtFontHeaderBoletas.Text) + "'" +
                                    ", Font_detail = '" + DataUtil.GetDouble(txtFontDetailBoletas.Text) + "'" +
                                    ", Ruta = '" + cbBoletas.Text + "'" +
                                    ", Preview = '" + valuePreviewBoletas + "'" +
                                    " WHERE tipo = 'L'";
                    DataUtil.Update(sqlForExecute);

                    sqlForExecute = "UPDATE Impresora SET " +
                                    " Font_header = '" + DataUtil.GetDouble(txtFontHeaderRecibos.Text) + "'" +
                                    ", Font_detail = '" + DataUtil.GetDouble(txtFontDetailRecibos.Text) + "'" +
                                    ", Ruta = '" + cbRecibos.Text + "'" +
                                    ", Preview = '" + valuePreviewRecibos + "'" +
                                    " WHERE tipo = 'R'";
                    DataUtil.Update(sqlForExecute);

                    sqlForExecute = "UPDATE Impresora SET " +
                                    " Font_header = '" + DataUtil.GetDouble(txtFontHeaderReportes.Text) + "'" +
                                    ", Font_detail = '" + DataUtil.GetDouble(txtFontDetailReportes.Text) + "'" +
                                    ", Ruta = '" + cbReportes.Text + "'" +
                                    ", Preview = '" + valuePreviewReportes + "'" +
                                    " WHERE tipo = 'P'";
                    DataUtil.Update(sqlForExecute);

                    sqlForExecute = "UPDATE configuracion_general SET " +
                                    "  Nombre_compania = '" + txtCompania.Text.Trim().Replace("'", "''") + "'" +
                                    ", Razon_social = '" + txtRazonSocial.Text.Trim().Replace("'", "''") + "'" +
                                    ", Documento_compania = '" + txtRUC.Text.Trim() + "'" +
                                    ", Telefono1_compania = '" + txtTelefono.Text.Trim() + "'" +
                                    ", Telefono2_compania = '" + txtFax.Text.Trim() + "'" +
                                    ", Telefono3_compania = '" + txtMobile.Text.Trim() + "'" +
                                    ", Direccion_compania = '" + txtDireccion.Text.Trim().Replace("'", "''") + "'" +
                                    ", Direccion_fiscal = '" + txtDireccionFiscal.Text.Trim().Replace("'", "''") + "'" +
                                    ", Mensaje_recibo_1 = '" + txtLinea1.Text.Trim().Replace("'", "''") + "'" +
                                    ", Mensaje_recibo_2 = '" + txtLinea2.Text.Trim().Replace("'", "''") + "'" +
                                    ", Mensaje_recibo_3 = '" + txtLinea3.Text.Trim().Replace("'", "''") + "'" +
                                    ", Ruta_logo_compania = '" + txtLogo.Text.Trim().Replace("'", "''") + "'" +
                                    ", Departamento = '" + txtDepartamento.Text.Trim().Replace("'", "''") + "'" +
                                    ", Provincia = '" + txtProvincia.Text.Trim().Replace("'", "''") + "'" +
                                    ", Urbanizacion = '" + txtUrbanizacion.Text.Trim().Replace("'", "''") + "'" +
                                    ", Codigo_Postal = '" + txtCodigoPostal.Text.Trim().Replace("'", "''") + "'" +
                                    ", Alegra_Usuario = '" + txtAlegraUsuario.Text.Trim().Replace("'", "''") + "'" +
                                    ", Alegra_Token = '" + txtAlegraToken.Text.Trim().Replace("'", "''") + "'" +
                                    ", Email_compania = '" + txtEmail.Text.Trim().Replace("'", "''") + "'" +
                                    ", Web_compania = '" + txtWeb.Text.Trim().Replace("'", "''") + "'" +
                                    ", IGV = '" + txtIGV.Text.Trim() + "'" +
                                    ", Monto_caja = '" + DataUtil.GetCurrency(txtCaja.Text) + "'" +
                                    ", Fecha_actualizacion = '" + DateTime.Now + "'" +
                                    ", Actualizado_por = '" + AppConstant.EmployeeInfo.Codigo + "'" +
                                    ", Ultima_boleta = '" + txtBoleta.Text.Trim() + "'" +
                                    ", Ultima_factura = '" + txtFactura.Text.Trim() + "'" +
                                    ", Prefijo_Boleta = '" + txtPrefijoBoleta.Text.Trim() + "'" +
                                    ", Prefijo_Factura = '" + txtPrefijoFactura.Text.Trim() + "'" +
                                    ", Ultima_Nota_Credito = '" + txtNotaCredito.Text.Trim() + "'" +
                                    ", Ultima_Nota_Debito = '" + txtNotaDebito.Text.Trim() + "'" +
                                    ", Prefijo_Nota_Credito = '" + txtPrefijoNotaCredito.Text.Trim() + "'" +
                                    ", Prefijo_Nota_Debito = '" + txtPrefijoNotaDebito.Text.Trim() + "'" +
                                    ", Contrasena_Anulaciones = '" + valueAnulaciones + "'" +
                                    ", Contrasena_NotaVenta = '" + valueNotaVenta + "'" +
                                    ", Contrasena_DividirCuenta = '" + valueDividirCuentas + "'" +
                                    ", Contrasena_CambioMesero = '" + valueCambioMesero + "'" +
                                    ", Contrasena_ReImpresiones = '" + valueReImpresiones + "'" +
                                    ", Contrasena_CambioMesa = '" + valueCambioMesa + "'" +
                                    ", Contrasena_Salir = '" + valueContrasenaSalir + "'" +
                                    ", Contrasena_EliminarProducto = '" + valueEliminarProducto + "'" +
                                    ", Mostrar_IGV_Boleta = '" + valueMostrarIgvBoleta + "'";


                    if (!DataUtil.Update(sqlForExecute))
                    {
                        return;
                    }
                    MessageBox.Show(@"Registro grabado correctamente", @"Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult = DialogResult.OK;
                    Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(@"Error en Grabar: " + ex.Message);
                }
            }
        }