//FUNCION PARA RECUPERAR DATOS EN CASO DE QUE SI EXISTIERA private void recuperarArreglo() { try { //for (i = 0; i < Program.iContadorDetalle; i++) for (i = 0; i < 10; i++) { if (Program.sDetallesItems[i, 0] == iIdProducto.ToString()) { iPosicion = i; iNuevaPosicion = i; iBandera = 1; break; } } if (iBandera == 1) { agregarLineaProducto(); } else { agregarLinea(); } } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
//FUNCION PARA COMPROBAR LA MESA //FUNCION PARA LLENAR EL GRID DE TIEMPOS private void llenarGrid() { try { dgvDatos.Rows.Clear(); for (int i = 0; i < dtVerificadorMesa.Rows.Count; i++) { dgvDatos.Rows.Add( dtVerificadorMesa.Rows[i]["mesa"].ToString().Trim().ToUpper(), dtVerificadorMesa.Rows[i]["estado_orden"].ToString().Trim().ToUpper(), Convert.ToDateTime(dtVerificadorMesa.Rows[i]["tiempo"].ToString()).ToString("HH:mm") ); if (i % 2 == 0) { dgvDatos.Rows[i].DefaultCellStyle.BackColor = Color.DeepSkyBlue; } else { dgvDatos.Rows[i].DefaultCellStyle.BackColor = Color.White; } } dgvDatos.ClearSelection(); } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
//FUNCION PARA LLENAR EL DATATABLE Y DISEÑAR LA INTERFAZ DE MESAS private void consultarDatos() { try { sSql = ""; sSql += "select id_pos_mesa, numero_mesa, posicion_x, posicion_y, descripcion" + Environment.NewLine; sSql += "from pos_mesa" + Environment.NewLine; sSql += "where id_pos_seccion_mesa = " + iIdSeccionMesa + Environment.NewLine; sSql += "and estado = 'A'"; dtMesas = new DataTable(); dtMesas.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtMesas, sSql); if (bRespuesta == false) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); } } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
private void dgvDatos_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { grupoDatos.Enabled = true; txtCodigo.Enabled = false; btnNuevoMetodoPago.Text = "Actualizar"; chkHabilitado.Enabled = true; iIdRegistro = Convert.ToInt32(dgvDatos.CurrentRow.Cells[0].Value.ToString()); txtCodigo.Text = dgvDatos.CurrentRow.Cells[1].Value.ToString(); txtDescripcion.Text = dgvDatos.CurrentRow.Cells[2].Value.ToString(); cmbFormasPagos.SelectedValue = dgvDatos.CurrentRow.Cells[4].Value.ToString(); if (Convert.ToInt32(dgvDatos.CurrentRow.Cells[6].Value.ToString()) == 1) { chkHabilitado.Checked = true; } else { chkHabilitado.Checked = false; } txtDescripcion.Focus(); } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
//FUNCION PARA CARGAR LAS SECCIONES private void cargarAreas() { try { sSql = ""; sSql += "select id_pos_seccion_mesa, codigo, descripcion, color, fondo_pantalla" + Environment.NewLine; sSql += "from pos_seccion_mesa" + Environment.NewLine; sSql += "where estado = 'A'" + Environment.NewLine; sSql += "order by id_pos_seccion_mesa asc"; dtSecciones = new DataTable(); dtSecciones.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtSecciones, sSql); if (bRespuesta == false) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = "ERROR EN LA INSTRUCCIÓN SQL:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); return; } iCuentaSecciones = 0; if (dtSecciones.Rows.Count > 0) { if (dtSecciones.Rows.Count > 8) { btnSiguiente.Enabled = true; } else { btnSiguiente.Enabled = false; } if (mostrarBotonesSecciones() == false) { } } else { ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "No se encuentras secciones configuradas en el sistema."; ok.ShowDialog(); return; } } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
//FUNCION PARA AGREGAR LAS CAJAS DE TEXTO private void agregarLinea() { try { if (iCuentaCrear == iMaximoCrear) { return; } //AGREGAR ETIQUETAS lblNuevaLinea[iPosicion] = new Label(); lblNuevaLinea[iPosicion].Location = new Point(13, iPosicionYLabel); lblNuevaLinea[iPosicion].AutoSize = true; lblNuevaLinea[iPosicion].Font = new Font("Microsoft Sans Serif", 9.75F, FontStyle.Regular); lblNuevaLinea[iPosicion].Text = "Observación " + h + ":"; //AGREGAR CAJAS DE TEXTO txtNuevaLinea[iPosicion] = new TextBox(); txtNuevaLinea[iPosicion].Location = new Point(133, iPosicionYTextBox); txtNuevaLinea[iPosicion].Width = 225; txtNuevaLinea[iPosicion].Tag = h; txtNuevaLinea[iPosicion].MaxLength = 150; txtNuevaLinea[iPosicion].Name = "txtNuevaLinea" + h; txtNuevaLinea[iPosicion].CharacterCasing = CharacterCasing.Upper; txtNuevaLinea[iPosicion].Font = new Font("Microsoft Sans Serif", 10, FontStyle.Regular); //AGREGAR BOTON DE REMOVER btnRemoverNuevaLinea[iPosicion] = new Button(); btnRemoverNuevaLinea[iPosicion].Location = new Point(387, iPosicionYBoton); btnRemoverNuevaLinea[iPosicion].Height = 30; btnRemoverNuevaLinea[iPosicion].Width = 30; btnRemoverNuevaLinea[iPosicion].Tag = h; btnRemoverNuevaLinea[iPosicion].BackColor = Color.FromArgb(255, 255, 128); btnRemoverNuevaLinea[iPosicion].ForeColor = Color.White; btnRemoverNuevaLinea[iPosicion].Image = Palatium.Properties.Resources.menos_png; btnRemoverNuevaLinea[iPosicion].ImageAlign = ContentAlignment.TopCenter; btnRemoverNuevaLinea[iPosicion].Click += botonImprimir_clic; toolTip1.SetToolTip(btnRemoverNuevaLinea[iPosicion], "Remover Preferencia " + (h + 1).ToString()); pnlControles.Controls.Add(lblNuevaLinea[iPosicion]); pnlControles.Controls.Add(txtNuevaLinea[iPosicion]); pnlControles.Controls.Add(btnRemoverNuevaLinea[iPosicion]); txtNuevaLinea[iPosicion].Focus(); iPosicion++; iPosicionYLabel += 27; iPosicionYTextBox += 27; iPosicionYBoton += 27; h++; iCuentaCrear++; } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
//FUNCION PARA OBTENER LOS VALORES PARA INSERTAR EN LA SECCION DE PAGOS private bool obtenerDatosFormaPagoRealizada(string sCodigoFormaPago_P) { try { sSql = ""; sSql += "select * from pos_vw_obtener_datos_formas_pagos" + Environment.NewLine; sSql += "where id_localidad = @id_localidad" + Environment.NewLine; sSql += "and codigo = @codigo"; parametro = new SqlParameter[2]; parametro[0] = new SqlParameter(); parametro[0].ParameterName = "@id_localidad"; parametro[0].SqlDbType = SqlDbType.Int; parametro[0].Value = Program.iIdLocalidad; parametro[1] = new SqlParameter(); parametro[1].ParameterName = "@codigo"; parametro[1].SqlDbType = SqlDbType.VarChar; parametro[1].Value = sCodigoFormaPago_P; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro_Parametros(dtConsulta, sSql, parametro); if (bRespuesta == false) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = conexion.sMensajeError; catchMensaje.ShowDialog(); return(false); } if (dtConsulta.Rows.Count == 0) { ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "No se encuentran configurados los registros de cobros. Favor comuníquese con el administrador."; ok.ShowDialog(); return(false); } iIdTipoFormaCobro = Convert.ToInt32(dtConsulta.Rows[0]["id_pos_tipo_forma_cobro"].ToString()); sDescripcionFormaPago = dtConsulta.Rows[0]["descripcion"].ToString().Trim().ToUpper(); iIdSriFormaPago_P = Convert.ToInt32(dtConsulta.Rows[0]["id_sri_forma_pago"].ToString()); sCodigoMetodoPago = dtConsulta.Rows[0]["codigo"].ToString().Trim().ToUpper(); return(true); } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); return(false); } }
private void btnListo_Click(object sender, EventArgs e) { try { if (iBandera == 1) { //VACIAR TODO LA FILA DEL ARREGLO for (i = 0; i < 100; i++) { Program.sDetallesItems[iNuevaPosicion, i] = null; } Program.sDetallesItems[iNuevaPosicion, 0] = iIdProducto.ToString(); for (i = 0; i < iPosicion; i++) { if (txtNuevaLinea[i].Text != "") { if (txtNuevaLinea[i].ReadOnly == false) { Program.sDetallesItems[iNuevaPosicion, iAux + 1] = txtNuevaLinea[i].Text.Trim(); iAux++; } } } } else { Program.sDetallesItems[Program.iContadorDetalle, 0] = iIdProducto.ToString(); for (i = 0; i < iPosicion; i++) { if (txtNuevaLinea[i].Text != "") { if (txtNuevaLinea[i].ReadOnly == false) { Program.sDetallesItems[Program.iContadorDetalle, iAux + 1] = txtNuevaLinea[i].Text.Trim(); iAux++; } } } Program.iContadorDetalle++; } this.Close(); } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
private void llenarGrid() { try { dSuma = 0; sSql = ""; sSql += "select mesero MESERO, " + Environment.NewLine; sSql += "ltrim(str(sum(cantidad * (precio_unitario - valor_dscto + valor_iva + valor_otro)), 10,2)) TOTAL" + Environment.NewLine; sSql += "from pos_vw_factura" + Environment.NewLine; sSql += "where id_pos_cierre_cajero = " + iIdCierreCajero + Environment.NewLine; sSql += "group by mesero" + Environment.NewLine; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (bRespuesta == true) { if (dtConsulta.Rows.Count > 0) { dgvDatos.DataSource = dtConsulta; for (int i = 0; i < dtConsulta.Rows.Count; i++) { dSuma = dSuma + Convert.ToDouble(dtConsulta.Rows[i][1].ToString()); } dgvDatos.Columns[0].Width = 250; dgvDatos.Columns[1].Width = 100; dgvDatos.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; txtTotal.Text = dSuma.ToString("N2"); dgvDatos.ClearSelection(); } } else { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); } } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
//FUNCION PARA INSERTAR EN LA BASE DE DATOS private void insertarRegistro() { try { //SE INICIA UNA TRANSACCION if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION)) { ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "Error al abrir transacción."; ok.ShowDialog(); limpiar(); return; } sSql = ""; sSql = sSql + "insert into pos_porcentaje_propina (" + Environment.NewLine; sSql = sSql + "codigo, valor, estado, fecha_ingreso," + Environment.NewLine; sSql = sSql + "usuario_ingreso, terminal_ingreso)" + Environment.NewLine; sSql = sSql + "values(" + Environment.NewLine; sSql = sSql + "'" + txtCodigo.Text.Trim() + "', " + txtDescripcion.Text.Trim() + "," + Environment.NewLine; sSql = sSql + "'A', GETDATE(), '" + Program.sDatosMaximo[0] + "'," + Environment.NewLine; sSql = sSql + "'" + Program.sDatosMaximo[1] + "')"; //EJECUTAR LA INSTRUCCIÓN SQL if (!conexion.GFun_Lo_Ejecuta_SQL(sSql)) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); goto reversa; } //SI SE EJECUTA TODO REALIZA EL COMMIT conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION); ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "Registro ingresado éxitosamente."; ok.ShowDialog(); limpiar(); return; } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); goto reversa; } reversa: { conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION); } }
//FUNCION PARA ELIMINAR EN LA BASE DE DATOS private void eliminarRegistro() { try { //SE INICIA UNA TRANSACCION if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION)) { ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "Error al abrir transacción."; ok.ShowDialog(); limpiar(); return; } sSql = ""; sSql = sSql + "update pos_porcentaje_propina set" + Environment.NewLine; sSql = sSql + "estado = 'E'," + Environment.NewLine; sSql = sSql + "fecha_anula = GETDATE()," + Environment.NewLine; sSql = sSql + "usuario_anula = '" + Program.sDatosMaximo[0] + "'," + Environment.NewLine; sSql = sSql + "terminal_anula = '" + Program.sDatosMaximo[1] + "'" + Environment.NewLine; sSql = sSql + "where id_pos_porcentaje_propina = " + iIdRegistro; //EJECUTAR LA INSTRUCCIÓN SQL if (!conexion.GFun_Lo_Ejecuta_SQL(sSql)) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); goto reversa; } //SI SE EJECUTA TODO REALIZA EL COMMIT conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION); ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "Registro eliminado éxitosamente."; ok.ShowDialog(); limpiar(); return; } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); goto reversa; } reversa: { conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION); } }
public bool insertarPagoCompleto(int iIdOrden_P, double dbTotal_P, double dbRecibido_P, double dbCambio_P, int iBanderaComandaPendiente_P, int iIdPersona_P, int iNumeroPedidoOrden_P) { try { this.iIdPedido = iIdOrden_P; this.dbTotal = dbTotal_P; this.dbRecibido = dbRecibido_P; this.dbCambio = dbCambio_P; this.iBanderaComandaPendiente = iBanderaComandaPendiente_P; this.iIdPersona = iIdPersona_P; this.iNumeroPedidoOrden = iNumeroPedidoOrden_P; if (obtenerDatosFormaPagoRealizada("EF") == false) { return(false); } //EXTRAER LA FECHA DEL SISTEMA sSql = ""; sSql += "select getdate() fecha"; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (bRespuesta == false) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = conexion.sMensajeError; catchMensaje.ShowDialog(); return(false); } sFecha = Convert.ToDateTime(dtConsulta.Rows[0]["fecha"].ToString()).ToString("yyyy-MM-dd"); if (crearPagosFactura_V2() == false) { return(false); } return(true); } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); return(false); } }
//FUNCION PARA CONSULTAR LAS IMPRESORAS private void consultarImpresora() { try { sSql = ""; sSql = sSql + "select I.path_url, I.numero_impresion, I.puerto_impresora," + Environment.NewLine; sSql = sSql + "I.ip_impresora, I.descripcion, I.cortar_papel, I.abrir_cajon" + Environment.NewLine; sSql = sSql + "from pos_impresora I, pos_formato_precuenta FP" + Environment.NewLine; sSql = sSql + "where FP.id_pos_impresora = I.id_pos_impresora" + Environment.NewLine; sSql = sSql + "and FP.estado = 'A'" + Environment.NewLine; sSql = sSql + "and I.estado = 'A'" + Environment.NewLine; sSql = sSql + "and FP.id_pos_formato_precuenta = " + Program.iFormatoPrecuenta; dtImprimir = new DataTable(); dtImprimir.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtImprimir, sSql); if (bRespuesta == true) { if (dtImprimir.Rows.Count > 0) { sNombreImpresora = dtImprimir.Rows[0][0].ToString(); iCantidadImpresiones = Convert.ToInt16(dtImprimir.Rows[0][1].ToString()); sPuertoImpresora = dtImprimir.Rows[0][2].ToString(); sIpImpresora = dtImprimir.Rows[0][3].ToString(); sDescripcionImpresora = dtImprimir.Rows[0][4].ToString(); iCortarPapel = Convert.ToInt16(dtImprimir.Rows[0][5].ToString()); iAbrirCajon = Convert.ToInt16(dtImprimir.Rows[0][6].ToString()); } else { ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "No existe el registro de configuración de impresora. Comuníquese con el administrador."; ok.ShowDialog(); } } else { ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "Ocurrió un problema al realizar la consulta."; ok.ShowDialog(); } } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
//FUNCION PARA CONCATENAR private void concatenarValores(string sValor) { try { if ((txtValor.Text == "0") && (sValor == "0")) { return; } else if ((txtValor.Text == "0") && (sValor != "0")) { txtValor.Clear(); } if (txtValor.Text.Trim().Contains('.') == true) { int longi = txtValor.Text.Trim().Length; int band = 0, cont = 0; for (int i = 0; i < longi; i++) { if (band == 1) { cont++; } if (txtValor.Text.Substring(i, 1) == ".") { band = 1; } } if (cont < 2) { txtValor.Text = txtValor.Text + sValor; } } else { txtValor.Text = txtValor.Text + sValor; } txtValor.Focus(); txtValor.SelectionStart = txtValor.Text.Trim().Length; } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; ok.ShowDialog(); } }
//FUNCION PARA EXTRAER EL NUMERO DE LOTE private void numeroLote(string sCodigo_P) { try { sSql = ""; sSql += "select NL.lote" + Environment.NewLine; sSql += "from pos_numero_lote NL INNER JOIN" + Environment.NewLine; sSql += "pos_operador_tarjeta OP ON OP.id_pos_operador_tarjeta = NL.id_pos_operador_tarjeta" + Environment.NewLine; sSql += "and NL.estado = 'A'" + Environment.NewLine; sSql += "and OP.estado = 'A'" + Environment.NewLine; sSql += "where NL.id_localidad = " + Program.iIdLocalidad + Environment.NewLine; sSql += "and NL.estado_lote = 'Abierta'" + Environment.NewLine; sSql += "and NL.id_pos_cierre_cajero = " + Program.iIdPosCierreCajero + Environment.NewLine; sSql += "and OP.codigo = '" + sCodigo_P + "'" + Environment.NewLine; sSql += "and NL.id_pos_jornada = " + Program.iJORNADA; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (bRespuesta == false) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = conexion.sMensajeError; catchMensaje.ShowDialog(); return; } if (dtConsulta.Rows.Count == 0) { txtNumeroLote.ReadOnly = false; sLoteRecuperado = ""; txtNumeroLote.Text = sLoteRecuperado; iBanderaInsertarLote = 1; } else { sLoteRecuperado = dtConsulta.Rows[0]["lote"].ToString().Trim(); txtNumeroLote.Text = sLoteRecuperado; txtNumeroLote.ReadOnly = true; iBanderaInsertarLote = 0; } } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
//FUNCION PARA ACTUALIZAR EN LA BASE DE DATOS private void actualizarRegistro() { try { //SE INICIA UNA TRANSACCION if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION)) { ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "Error al abrir transacción."; ok.ShowDialog(); limpiar(); return; } sSql = ""; sSql = sSql + "update pos_porcentaje_propina set" + Environment.NewLine; sSql = sSql + "valor = " + txtDescripcion.Text.Trim() + Environment.NewLine; sSql = sSql + "where id_pos_porcentaje_propina = " + iIdRegistro + Environment.NewLine; sSql = sSql + "and estado = 'A'"; //EJECUTAR LA INSTRUCCIÓN SQL if (!conexion.GFun_Lo_Ejecuta_SQL(sSql)) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); goto reversa; } //SI SE EJECUTA TODO REALIZA EL COMMIT conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION); ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "Registro actualizado éxitosamente."; ok.ShowDialog(); limpiar(); return; } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); goto reversa; } reversa: { conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION); } }
//FUNCION PARA LLENAR LOS VALORES DEL COMBOBOX private void llenarComboBancos() { try { sSql = ""; sSql += "Select correlativo, substring(valor_texto,1,60) valor_texto " + Environment.NewLine; sSql += "from tp_codigos" + Environment.NewLine; sSql += "where tabla = @tabla" + Environment.NewLine; sSql += "and estado = @estado" + Environment.NewLine; sSql += "order by valor_texto"; parametro = new SqlParameter[2]; parametro[0] = new SqlParameter(); parametro[0].ParameterName = "@tabla"; parametro[0].SqlDbType = SqlDbType.VarChar; parametro[0].Value = "SYS$00250"; parametro[1] = new SqlParameter(); parametro[1].ParameterName = "@estado"; parametro[1].SqlDbType = SqlDbType.VarChar; parametro[1].Value = "A"; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro_Parametros(dtConsulta, sSql, parametro); if (bRespuesta == false) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = conexion.sMensajeError; catchMensaje.ShowDialog(); return; } DataRow row = dtConsulta.NewRow(); row["correlativo"] = "0"; row["valor_texto"] = "Seleccione...!!!"; dtConsulta.Rows.InsertAt(row, 0); cmbBanco.DisplayMember = "valor_texto"; cmbBanco.ValueMember = "correlativo"; cmbBanco.DataSource = dtConsulta; } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
//FUNCION PARA ACTUALIZAR EL REGISTRO private void actualizarRegistro() { try { //AQUI INICIA PROCESO DE ACTUALIZACION if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION)) { ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "Error al abrir transacción."; ok.ShowDialog(); limpiar(); return; } sSql = ""; sSql += "update pos_movimiento_caja set " + Environment.NewLine; sSql += "tipo_movimiento = " + iTipoMovimiento + "," + Environment.NewLine; sSql += "id_persona = " + Convert.ToInt32(cmbEmpleados.SelectedValue) + "," + Environment.NewLine; sSql += "id_caja = " + Convert.ToInt32(cmbCaja.SelectedValue) + "," + Environment.NewLine; sSql += "id_pos_cargo = " + Convert.ToInt32(cmbCargo.SelectedValue) + "," + Environment.NewLine; sSql += "valor = " + Convert.ToDouble(txtValor.Text) + "," + Environment.NewLine; sSql += "concepto = '" + txtConcepto.Text + "'" + Environment.NewLine; sSql += "where id_pos_movimiento_caja = " + iIdPosMovimientoCaja + Environment.NewLine; sSql += "and estado = 'A'"; if (!conexion.GFun_Lo_Ejecuta_SQL(sSql)) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); goto reversa; } conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION); ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "Movimiento actualizado éxitosamente."; ok.ShowDialog(); llenarGrid(1); limpiar(); return; } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); goto reversa; } reversa : { conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION); } }
//FUNCION PARA CREAR LA TABLA DE ITEMS PARA ENVIAR POR PARAMETRO private bool crearTablaItems() { try { dtItems = new DataTable(); dtItems.Clear(); dtItems.Columns.Add("id_producto"); dtItems.Columns.Add("valor_unitario"); dtItems.Columns.Add("cantidad"); dtItems.Columns.Add("valor_descuento"); dtItems.Columns.Add("paga_iva"); dtItems.Columns.Add("bandera_cortesia"); dtItems.Columns.Add("bandera_descuento"); dtItems.Columns.Add("bandera_comentario"); dtItems.Columns.Add("id_mascara"); dtItems.Columns.Add("id_ordenamiento"); dtItems.Columns.Add("secuencia_impresion"); dtItems.Columns.Add("motivo_cortesia"); dtItems.Columns.Add("motivo_descuento"); dtItems.Columns.Add("codigo_producto"); dtItems.Columns.Add("nombre_producto"); dtItems.Columns.Add("porcentaje_descuento"); dtItems.Columns.Add("paga_servicio"); for (int i = 0; i < dgvPedido.Rows.Count; i++) { dtItems.Rows.Add(dgvPedido.Rows[i].Cells["idProducto"].Value, dgvPedido.Rows[i].Cells["valuni"].Value, dgvPedido.Rows[i].Cells["cantidad"].Value, "0", dgvPedido.Rows[i].Cells["pagaIva"].Value, "0", "0", "0", "0", "0", "1", "", "", dgvPedido.Rows[i].Cells["tipoProducto"].Value, dgvPedido.Rows[i].Cells["producto"].Value, "0", dgvPedido.Rows[i].Cells["paga_servicio"].Value ); } return(true); } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); return(false); } }
//FUNCION PARA LLENAR EL DATAGRIDVIEW private void llenarGrid(int iOp) { try { sSql = ""; sSql = sSql + "select id_pos_porcentaje_propina as 'ID', codigo as CÓDIGO, valor as VALOR," + Environment.NewLine; sSql = sSql + "case estado when 'A' then 'ACTIVO' else 'INACTIVO' end as ESTADO" + Environment.NewLine; sSql = sSql + "from pos_porcentaje_propina" + Environment.NewLine; sSql = sSql + "where estado = 'A'" + Environment.NewLine; if (iOp == 1) { sSql = sSql + "and (codigo like '%" + txtBuscar.Text.Trim() + "%'" + Environment.NewLine; sSql = sSql + "or valor like '%" + txtBuscar.Text.Trim() + "%')"; } sSql = sSql + "order by id_pos_porcentaje_propina"; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (bRespuesta == true) { dgvDatos.DataSource = dtConsulta; dgvDatos.Columns[1].Width = 60; dgvDatos.Columns[2].Width = 185; dgvDatos.Columns[3].Width = 60; dgvDatos.Columns[0].Visible = false; } else { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); } lblRegistros.Text = dgvDatos.Rows.Count.ToString() + " Registros Encontrados"; dgvDatos.ClearSelection(); } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
private void btnBuscarMetodoPago_Click(object sender, EventArgs e) { try { llenarGrid(); } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
//FUNCION PARA LLENAR EL GRID private void llenarGrid() { try { sSql = ""; sSql += "select MP.id_pos_metodo_pago, MP.codigo CÓDIGO, MP.descripcion DESCRIPCIÓN," + Environment.NewLine; //sSql += "case MP.estado when 'A' then 'ACTIVO' else 'INACTIVO' end ESTADO," + Environment.NewLine; sSql += "case MP.is_active when 1 then 'ACTIVO' else 'INACTIVO' end ESTADO," + Environment.NewLine; sSql += "isnull(FP.id_sri_forma_pago, 0) id_sri_forma_pago," + Environment.NewLine; sSql += "isnull(FP.descripcion, 'SIN ASIGNAR') FORMA_PAGO," + Environment.NewLine; sSql += "isnull(MP.is_active, 0) is_active" + Environment.NewLine; sSql += "from pos_metodo_pago MP LEFT OUTER JOIN" + Environment.NewLine; sSql += "sri_forma_pago FP ON FP.id_sri_forma_pago = MP.id_sri_forma_pago" + Environment.NewLine; sSql += "and MP.estado in ('A', 'N')" + Environment.NewLine; sSql += "and FP.estado = 'A'" + Environment.NewLine; if (txtBuscar.Text.Trim() != "") { sSql += "and (MP.codigo like '%" + txtBuscar.Text.Trim() + "%'" + Environment.NewLine; sSql += "or MP.descripcion like '%" + txtBuscar.Text.Trim() + "%')" + Environment.NewLine; } sSql += "order by MP.codigo" + Environment.NewLine; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (bRespuesta == true) { dgvDatos.DataSource = dtConsulta; columnasGrid(false); } else { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); } } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
//FUNCION PARA ELIMINAR EL REGISTRO private void eliminarRegistro() { try { //AQUI INICIA PROCESO DE ACTUALIZACION if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION)) { ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "Error al abrir transacción."; ok.ShowDialog(); limpiar(); return; } sSql = ""; sSql += "update pos_movimiento_caja set " + Environment.NewLine; sSql += "estado = 'E'," + Environment.NewLine; sSql += "fecha_anula = GETDATE()," + Environment.NewLine; sSql += "usuario_anula = '" + Program.sDatosMaximo[0] + "'," + Environment.NewLine; sSql += "terminal_anula = '" + Program.sDatosMaximo[1] + "'" + Environment.NewLine; sSql += "where id_pos_movimiento_caja = " + iIdPosMovimientoCaja + Environment.NewLine; sSql += "and estado = 'A'"; if (!conexion.GFun_Lo_Ejecuta_SQL(sSql)) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); goto reversa; } conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION); ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "Movimiento eliminado éxitosamente."; ok.ShowDialog(); llenarGrid(1); limpiar(); return; } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); goto reversa; } reversa : { conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION); } }
//FUNCION PARA ACTUALIZAR UN REGISTRO private void actualizarRegistro() { try { //AQUI INICIA PROCESO DE ELIMINAR if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION)) { ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "Error al abrir transacción."; ok.ShowDialog(); return; } sSql = ""; sSql += "update pos_metodo_pago set" + Environment.NewLine; sSql += "descripcion = '" + txtDescripcion.Text.Trim().ToUpper() + "'," + Environment.NewLine; sSql += "id_sri_forma_pago = " + Convert.ToInt32(cmbFormasPagos.SelectedValue) + "," + Environment.NewLine; sSql += "is_active = " + iHabilitado + Environment.NewLine; sSql += "where id_pos_metodo_pago = " + iIdRegistro + Environment.NewLine; sSql += "and estado in ('A', 'N')"; if (!conexion.GFun_Lo_Ejecuta_SQL(sSql)) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); goto reversa; } conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION); ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "Registro actualizado éxitosamente."; ok.ShowDialog(); limpiar(); return; } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); goto reversa; } reversa : { conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION); } }
//EXTRAER LOS DATOS LAS IMPRESORAS public void consultarImpresoraAbrirCajon() { try { sSql = ""; sSql = sSql + "select I.path_url" + Environment.NewLine; sSql = sSql + "from pos_impresora I, pos_formato_factura FF" + Environment.NewLine; sSql = sSql + "where FF.id_pos_impresora = I.id_pos_impresora" + Environment.NewLine; sSql = sSql + "and FF.estado = 'A'" + Environment.NewLine; sSql = sSql + "and I.estado = 'A'" + Environment.NewLine; sSql = sSql + "and FF.id_pos_formato_factura = " + Program.iFormatoFactura; dtImprimir = new DataTable(); dtImprimir.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtImprimir, sSql); if (bRespuesta == true) { if (dtImprimir.Rows.Count > 0) { sNombreImpresoraAbrirCajon = dtImprimir.Rows[0][0].ToString(); } else { ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "No existe el registro de configuración de impresora. Comuníquese con el administrador."; ok.ShowInTaskbar = false; ok.ShowDialog(); } } else { ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "Ocurrió un problema al realizar la consulta."; ok.ShowDialog(); } } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
//FUNCION PARA INSERTAR UN REGISTRO private void insertarRegistro() { try { //AQUI INICIA PROCESO DE ELIMINAR if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION)) { ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "Error al abrir transacción."; ok.ShowDialog(); return; } sSql = ""; sSql += "insert into pos_metodo_pago (" + Environment.NewLine; sSql += "codigo, descripcion, id_sri_forma_pago, is_active, estado," + Environment.NewLine; sSql += "fecha_ingreso, usuario_ingreso, terminal_ingreso)" + Environment.NewLine; sSql += "values (" + Environment.NewLine; sSql += "'" + txtCodigo.Text.ToString().Trim() + "', '" + txtDescripcion.Text.ToString().Trim() + "'," + Environment.NewLine; sSql += Convert.ToInt32(cmbFormasPagos.SelectedValue) + ", 1, 'A'," + Environment.NewLine; sSql += "GETDATE(), '" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')"; if (!conexion.GFun_Lo_Ejecuta_SQL(sSql)) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); goto reversa; } conexion.GFun_Lo_Maneja_Transaccion(Program.G_TERMINA_TRANSACCION); ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "Registro agregado éxitosamente."; ok.ShowDialog(); limpiar(); return; } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); goto reversa; } reversa : { conexion.GFun_Lo_Maneja_Transaccion(Program.G_REVERSA_TRANSACCION); } }
//FUNCION PARA ENVIAR AL CORREO ELECTRONICO REENVIO private bool enviarMailReenvio(int iFila_P, long iIdFactura_P, string sNumeroDocumento_P) { try { filenameRide = sDirAutorizados + @"\" + sNumeroDocumento_P + ".pdf"; crearRide(iIdFactura_P, sNumeroDocumento); sCorreoCliente = dgvDatos.Rows[iFila_P].Cells["colMail"].Value.ToString(); sAsuntoMail = P_St_nombre_comercial + ", Envio de Comprobante electrónico " + sNumeroDocumento_P; srutaXML = sDirFirmados + @"\" + sNumeroDocumento_P + ".xml"; srutaRIDE = sDirAutorizados + @"\" + sNumeroDocumento_P + ".pdf"; sRutaAdjuntos = ""; if (srutaRIDE != "") { sRutaAdjuntos = sRutaAdjuntos + srutaXML + "|" + srutaRIDE; } else { sRutaAdjuntos = sRutaAdjuntos + srutaXML; } sMensajeRetorno = crearMensajeEnvio(iFila_P, sNumeroDocumento_P); bRespuestaEnvioMail = correo.enviarCorreo(P_St_correo_server_smtp, Convert.ToInt32(P_Ln_correo_puerto_smtp), P_St_from, P_St_correo_palabra_clave, P_St_fromname, sCorreoCliente, P_St_correo_con_copia, P_St_correo_consumidor_final, sAsuntoMail, sRutaAdjuntos, sMensajeRetorno, P_In_maneja_SSL); if (bRespuestaEnvioMail == true) { return(true); } else { return(false); } } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); return(false); } }
//FUNCION PARA CARGAR LAS MESAS private void cargarMesas() { try { sSql = ""; sSql += "select id_pos_mesa, numero_mesa, posicion_x, posicion_y, descripcion" + Environment.NewLine; sSql += "from pos_mesa" + Environment.NewLine; sSql += "where id_pos_seccion_mesa = " + iIdPosSeccionMesa + Environment.NewLine; sSql += "and estado = 'A'"; dtMesas = new DataTable(); dtMesas.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtMesas, sSql); if (bRespuesta == false) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = "ERROR EN LA INSTRUCCIÓN SQL:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); return; } if (dtMesas.Rows.Count > 0) { if (mostrarBotonesMesas() == false) { return; } } else { pnlMesas.Controls.Clear(); ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "No se encuentras mesas configuradas en el área seleccinada."; ok.ShowDialog(); return; } } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
//FUNCION PARA CONCATENAR private void concatenarValores(string sValor) { try { txtBusqueda.Text = txtBusqueda.Text + sValor; txtBusqueda.Focus(); txtBusqueda.SelectionStart = txtBusqueda.Text.Trim().Length; } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
//FUNCION PARA CONSULTAR EL TIPO DE EMISION CONFIGURADO EN EL SISTEMA private void consultarTipoEmision() { try { sSql = ""; sSql += "select TE.codigo" + Environment.NewLine; sSql += "from sis_empresa E,cel_tipo_emision TE" + Environment.NewLine; sSql += "where E.id_tipo_emision = TE.id_tipo_emision" + Environment.NewLine; sSql += "and E.estado = 'A'" + Environment.NewLine; sSql += "and TE.estado = 'A'" + Environment.NewLine; sSql += "order By TE.codigo"; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (bRespuesta == true) { if (dtConsulta.Rows.Count > 0) { sIdTipoEmision = dtConsulta.Rows[0][0].ToString(); } else { ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "No se encuentra información de configuración del Tipo de Emisión"; ok.ShowDialog(); } } else { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); } } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }