Ejemplo n.º 1
0
        private void btnSaveEdit_Click(object sender, EventArgs e)
        {
            if (IsReadyToEdit())
            {
                string sqlForExecute = string.Empty;
                try
                {
                    sqlForExecute = "UPDATE " + tableName + " SET " +
                                    "Boton_descripcion = '" + txtDescripcion.Text.Trim().Replace("'", "''") + "'" +
                                    ", Boton_ruta_imagen = '" + txtRuta.Text + "'" +
                                    ", Fecha_actualizacion = '" + DateTime.Now + "'" +
                                    ", Actualizado_por = '" + AppConstant.EmployeeInfo.Codigo + "'" +
                                    " WHERE " + formWhereField + " = " + botonId;

                    if (DataUtil.Update(sqlForExecute))
                    {
                        MessageBox.Show("Registro grabado correctamente", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error en Grabar: " + ex.Message);
                }
            }
        }
Ejemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (IsReadyToSave())
            {
                string sqlForExecute = string.Empty;
                try
                {
                    string habilitado = DataUtil.GetString(cbEstado.SelectedItem) == "SI" ? "1" : "0";

                    sqlForExecute = "UPDATE mesa SET " +
                                    "Mesa_descripcion = '" + txtDescripcion.Text.Trim().Replace("'", "''") + "'" +
                                    ", Mesa_habilitado = '" + habilitado + "'" +
                                    ", Fecha_actualizacion = '" + DateTime.Now + "'" +
                                    ", Actualizado_por = '" + AppConstant.EmployeeInfo.Codigo + "'" +
                                    " WHERE Mesa_id = " + mesaID;


                    if (DataUtil.Update(sqlForExecute))
                    {
                        MessageBox.Show("Registro grabado correctamente", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        DialogResult = DialogResult.OK;
                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error en Grabar: " + ex.Message);
                }
            }
        }
Ejemplo n.º 3
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.º 4
0
        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);
                }
            }
        }
Ejemplo n.º 5
0
        private void btnDisassociate_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Está seguro de desasociar el boton actual?", "Desasociar", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                if (DataUtil.Update("DELETE FROM " + tableName + " WHERE " + formWhereField + " = " + botonId))
                {
                    MessageBox.Show(string.Format("Se desasocio el boton correctamente.", 1), "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
        private void InsertarValoresReporte(string descripcion, string valor)
        {
            string sqlForExecute = "INSERT INTO Reporte_Turno (" +
                                   "Descripcion," +
                                   "Valor," +
                                   "Turno_id)" +
                                   " VALUES (" +
                                   "'" + descripcion + "'," +
                                   "'" + valor + "'," +
                                   "" + lblTurno.Text + "" +
                                   ")";

            DataUtil.Update(sqlForExecute);
        }
Ejemplo n.º 8
0
        private void btnDeleteProducto_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection Seleccionados = dgwReceta.SelectedRows;

            foreach (DataGridViewRow item in Seleccionados)
            {
                DialogResult diagResult = MessageBox.Show("Está seguro de eliminar el producto seleccionado?", "Eliminar", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (diagResult == DialogResult.Yes)
                {
                    if (DataUtil.Update("DELETE FROM movimientos WHERE Movimiento_id = " + item.Cells["MOVIMIENTO_ID"].Value.ToString() + ""))
                    {
                        this.dgwReceta.Rows.RemoveAt(item.Index);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        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);
                    }
                }
            }
        }
Ejemplo n.º 10
0
        protected virtual void DeleteData()
        {
            DialogResult result = MessageBox.Show(@"Está seguro de eliminar el registro actual?", @"Eliminar", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                if (ExistRecord())
                {
                    if (DataUtil.Update("DELETE FROM " + tableName + " WHERE " + formWhereField + " = " + idToDelete))
                    {
                        MessageBox.Show(string.Format("Se eliminó {0} elemento(s).", 1), @"Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        idToDelete = string.Empty;
                        this.Close();
                    }
                }
            }
        }
Ejemplo n.º 11
0
        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);
            }
        }
Ejemplo n.º 12
0
        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);
                    }
                }
            }
        }
Ejemplo n.º 13
0
        private void btnAssociate_Click(object sender, EventArgs e)
        {
            if (IsReadyToAssociate())
            {
                string sqlForExecute = string.Empty;
                try
                {
                    if (adding)
                    {
                        sqlForExecute = "INSERT INTO " + tableName + " (" +
                                        formWhereField + "," +
                                        "Producto_sub_categoria_id," +
                                        "Producto_id," +
                                        "Boton_descripcion," +
                                        "Boton_ruta_imagen," +
                                        "Fecha_creacion," +
                                        "Creado_por," +
                                        "Fecha_actualizacion," +
                                        "Actualizado_por)" +
                                        " VALUES (" +
                                        botonId + "," +
                                        subCategoriaId + "," +
                                        txtCodigo.Text + "," +
                                        "'" + txtDescripcion.Text.Trim().Replace("'", "''") + "'," +
                                        "'" + txtRuta.Text + "'," +
                                        "'" + DateTime.Now + "'," +
                                        "'" + AppConstant.EmployeeInfo.Codigo + "'," +
                                        "'" + DateTime.Now + "'," +
                                        "'" + AppConstant.EmployeeInfo.Codigo + "'" +
                                        ")";
                    }

                    if (DataUtil.Update(sqlForExecute))
                    {
                        MessageBox.Show("Registro grabado correctamente", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error en Grabar: " + ex.Message);
                }
            }
        }
Ejemplo n.º 14
0
        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);
            }
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (IsReadyToSave())
            {
                try
                {
                    string sqlUpdate = "UPDATE empleado SET " +
                                       "[password] = '" + txtNewPassword.Text.Trim() + "'" +
                                       " WHERE [password] = '" + txtOldPassword.Text.Trim() + "'";

                    if (DataUtil.Update(sqlUpdate))
                    {
                        MessageBox.Show("Registro grabado correctamente", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error en Grabar: " + ex.Message);
                }
            }
        }
Ejemplo n.º 17
0
        private void frmCloseTurn_Load(object sender, EventArgs e)
        {
            DataUtil.Update("DELETE FROM reporte_turno");
            GetTurnInfo();
            int turnoID = DataUtil.GetInt(lblTurno.Text);

            CargarTurnoEstacion(turnoID);
            CargarTurnoOrdenesPagadas(turnoID);
            CargarInformacionExtra(turnoID);
            CargarGastos(turnoID);
            CargarProductos(turnoID);

            if (TurnoIDValue != 0)
            {
                lblTurnoLabel.Text     = @"Turno Cerrado:";
                btnCerrarTurno.Visible = false;
            }

            txtVentaTotal.Text = txtDetalleTotal.Text;
            txtBalance.Text    = DataUtil.GetString(DataUtil.GetDouble(txtFondoInicialTotal.Text) + DataUtil.GetDouble(txtDetalleTotal.Text) + _montoDeposito - _montoRetiro);
            InsertarValoresReporte("Venta Total", txtVentaTotal.Text);
            InsertarValoresReporte("Balance de Cajas", txtBalance.Text);
        }
Ejemplo n.º 18
0
        protected override void DeleteData()
        {
            if (lblCategoria.Text.Equals("SI"))
            {
                MessageBox.Show("No se pueden borrar categorias del sistema.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                DialogResult result = MessageBox.Show("Está seguro de eliminar el registro actual?", "Eliminar", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result == DialogResult.Yes)
                {
                    if (ExistRecord())
                    {
                        if (DataUtil.Update("DELETE FROM " + tableName + " WHERE " + formWhereField + " = " + txtCodigo.Text))
                        {
                            MessageBox.Show(string.Format("Se eliminó {0} elemento(s).", 1), "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Close();
                        }
                    }
                }
            }
        }
Ejemplo n.º 19
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (isRecordSelected())
            {
                DialogResult diagResult = MessageBox.Show("Está seguro de eliminar el movimiento seleccionado?", "Eliminar", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (diagResult == DialogResult.Yes)
                {
                    DataGridViewSelectedRowCollection Seleccionados = dgwCuenta.SelectedRows;
                    foreach (DataGridViewRow item in Seleccionados)
                    {
                        if (DataUtil.Update("DELETE FROM movimientos WHERE Movimiento_id = " + item.Cells["MOVIMIENTO_ID"].Value.ToString() + ""))
                        {
                            if (DataUtil.GetString(item.Cells["Tipo_movimiento"].Value) == "DEPOSITO")
                            {
                                totalDeposito = totalDeposito - DataUtil.GetDouble(item.Cells["ImporteNeto"].Value);
                            }
                            else
                            {
                                totalRetiro = totalRetiro - DataUtil.GetDouble(item.Cells["ImporteNeto"].Value);
                            }

                            totalGeneral      = totalRetiro + totalDeposito;
                            txtDepositro.Text = totalDeposito.ToString(DataUtil.Format.Decimals);
                            txtRetiro.Text    = totalRetiro.ToString(DataUtil.Format.Decimals);
                            txtTotal.Text     = totalGeneral.ToString(DataUtil.Format.Decimals);

                            this.dgwCuenta.Rows.RemoveAt(item.Index);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Seleccione un registro", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 20
0
        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);
                }
            }
        }
Ejemplo n.º 21
0
        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);
                }
            }
        }
Ejemplo n.º 22
0
        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);
                }
            }
        }
Ejemplo n.º 23
0
        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);
                }
            }
        }
Ejemplo n.º 24
0
        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);
                }
            }
        }
Ejemplo n.º 25
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);
                }
            }
        }
Ejemplo n.º 26
0
        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);
                }
            }
        }
Ejemplo n.º 27
0
        public static DialogResult InputBox(string title, string promptText, string tableName, string fieldName, string fieldRef, ref string value, bool validateKey, bool showDialog)
        {
            DialogResult dialogResult = DialogResult.OK;

            if (showDialog)
            {
                Form    form         = new Form();
                Label   label        = new Label();
                TextBox textBox      = new TextBox();
                Button  buttonOk     = new Button();
                Button  buttonCancel = new Button();

                form.Text  = title;
                label.Text = promptText;
                if (validateKey)
                {
                    textBox.PasswordChar = '*';
                }
                textBox.Text = value;

                buttonOk.Text             = "OK";
                buttonCancel.Text         = "Cancel";
                buttonOk.DialogResult     = DialogResult.OK;
                buttonCancel.DialogResult = DialogResult.Cancel;

                label.SetBounds(9, 20, 372, 13);
                textBox.SetBounds(12, 36, 372, 20);
                textBox.CharacterCasing = CharacterCasing.Upper;
                buttonOk.SetBounds(228, 72, 75, 23);
                buttonCancel.SetBounds(309, 72, 75, 23);

                label.AutoSize      = true;
                textBox.Anchor      = textBox.Anchor | AnchorStyles.Right;
                buttonOk.Anchor     = AnchorStyles.Bottom | AnchorStyles.Right;
                buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

                form.ClientSize = new Size(396, 107);
                form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
                form.ClientSize      = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
                form.FormBorderStyle = FormBorderStyle.FixedDialog;
                form.StartPosition   = FormStartPosition.CenterScreen;
                form.MinimizeBox     = false;
                form.MaximizeBox     = false;
                form.AcceptButton    = buttonOk;
                form.CancelButton    = buttonCancel;

                dialogResult = form.ShowDialog();
                value        = textBox.Text.Trim();

                if (validateKey)
                {
                    if (value != string.Empty)
                    {
                        string sWhere = "codigo_empleado = " + fieldRef + " AND " + fieldName + " = '" + value + "'";
                        if (DataUtil.FindSingleRow(tableName, fieldName, sWhere) == string.Empty)
                        {
                            MessageBox.Show("El password es incorrecto.", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            dialogResult = DialogResult.Cancel;
                        }
                    }
                    else
                    {
                        dialogResult = DialogResult.Cancel;
                    }
                }
                else
                {
                    if (value != string.Empty)
                    {
                        string sWhere = fieldName + " = '" + value + "'";
                        if (DataUtil.FindSingleRow(tableName, fieldName, sWhere) != string.Empty)
                        {
                            MessageBox.Show("El registro ya existe en la base de datos.", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else
                        {
                            try
                            {
                                string sqlInsert = string.Empty;
                                if (tableName.Equals("cliente_email"))
                                {
                                    sqlInsert = "INSERT INTO " + tableName + " (" +
                                                fieldName + "," +
                                                "cliente_id)" +
                                                " VALUES (" +
                                                "'" + DataUtil.GetString(value) + "'," +
                                                fieldRef + ")";
                                }
                                else
                                {
                                    sqlInsert = "INSERT INTO " + tableName + " (" +
                                                fieldName + ")" +
                                                " VALUES (" +
                                                "'" + DataUtil.GetString(value) + "')";
                                }
                                if (DataUtil.Update(sqlInsert))
                                {
                                    MessageBox.Show("Registro grabado correctamente", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("Error en Grabar: " + ex.Message);
                            }
                        }
                    }
                    else
                    {
                        dialogResult = DialogResult.Cancel;
                    }
                }
            }
            return(dialogResult);
        }