//FUNCION PARA VERIFICAR SI YA ESTÁ EMITIDA UNA FACTURA EN UNA ORDEN private int validarPedido() { try { sSql = ""; sSql = sSql + "select top 1 NCP.id_pedido, F.id_persona, TP.identificacion," + Environment.NewLine; sSql = sSql + conexion.GFun_St_esnulo() + "(F.autorizacion, 0) autorizacion, F.id_factura, F.idtipocomprobante" + Environment.NewLine; sSql = sSql + "from cv403_numero_cab_pedido NCP, cv403_facturas_pedidos FP," + Environment.NewLine; sSql = sSql + "cv403_facturas F, tp_personas TP" + Environment.NewLine; sSql = sSql + "where FP.id_pedido = NCP.id_pedido" + Environment.NewLine; sSql = sSql + "and FP.id_factura = F.id_factura" + Environment.NewLine; sSql = sSql + "and F.id_persona = TP.id_persona" + Environment.NewLine; sSql = sSql + "and FP.estado = 'A'" + Environment.NewLine; sSql = sSql + "and NCP.estado = 'A'" + Environment.NewLine; sSql = sSql + "and TP.estado = 'A'" + Environment.NewLine; sSql = sSql + "and F.estado = 'A'" + Environment.NewLine; sSql = sSql + "and NCP.numero_pedido = " + Convert.ToInt32(txtBuscar.Text.Trim()) + Environment.NewLine; sSql = sSql + "order by NCP.id_numero_cab_pedido desc"; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (bRespuesta == true) { if (dtConsulta.Rows.Count > 0) { iIdOrden = Convert.ToInt32(dtConsulta.Rows[0][0].ToString()); iIdPersona = Convert.ToInt32(dtConsulta.Rows[0][1].ToString()); txtIdentificacion.Text = dtConsulta.Rows[0][2].ToString(); sAutorizacion = dtConsulta.Rows[0][3].ToString(); iIdFactura = Convert.ToInt32(dtConsulta.Rows[0][4].ToString()); iIdTipoComprobante = Convert.ToInt32(dtConsulta.Rows[0][5].ToString()); return(1); } else { return(0); } } else { return(0); } } catch (Exception ex) { catchMensaje.LblMensaje.Text = ex.ToString(); catchMensaje.ShowDialog(); return(0); } }
//Función para llenar el grid private void llenarGrid(int iBandera) { try { dgvAyudaConsumoEmpleados.Rows.Clear(); sSql = ""; sSql += "select PER.apellidos + ' ' + " + conexion.GFun_St_esnulo() + "(PER.nombres,'') Apellidos_nombres," + Environment.NewLine; sSql += "PER.identificacion,PER.id_persona" + Environment.NewLine; sSql += "FROM cv408_cabecera_contrato CC, tp_personas PER" + Environment.NewLine; sSql += "where CC.id_persona = PER.id_persona" + Environment.NewLine; sSql += "and CC.estado = 'A'" + Environment.NewLine; sSql += "and PER.estado='A'" + Environment.NewLine; sSql += "and CC.fecha_salida is null" + Environment.NewLine; if (iBandera == 1) { sSql += "and (PER.identificacion like '%" + TxtBusqueda.Text.Trim() + "%'" + Environment.NewLine; sSql += "or PER.apellidos like '%" + TxtBusqueda.Text.Trim() + "%'" + Environment.NewLine; sSql += "or PER.nombres like '%" + TxtBusqueda.Text.Trim() + "%')" + Environment.NewLine; } sSql += "order by PER.apellidos"; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (bRespuesta == true) { if (dtConsulta.Rows.Count > 0) { for (int i = 0; i < dtConsulta.Rows.Count; i++) { dgvAyudaConsumoEmpleados.Rows.Add(dtConsulta.Rows[i].ItemArray[0].ToString(), dtConsulta.Rows[i].ItemArray[1].ToString(), dtConsulta.Rows[i].ItemArray[2].ToString()); } } } else { catchMensaje.LblMensaje.Text = sSql; catchMensaje.ShowDialog(); } } catch (Exception ex) { catchMensaje.LblMensaje.Text = ex.ToString(); catchMensaje.ShowDialog(); } }
//CONSULTAR LA CLAVE DE ACCESO DE CADA FACTURA DEL GRID private string consultarClaveAcceso(long iIdFactura_P) { try { sSql = ""; sSql += "select " + conexion.GFun_St_esnulo() + "(clave_acceso, 'NINGUNA') clave_acceso " + Environment.NewLine; sSql += "from cv403_facturas " + Environment.NewLine; sSql += "where id_factura = " + iIdFactura_P; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (bRespuesta == true) { if (dtConsulta.Rows.Count > 0) { return(dtConsulta.Rows[0][0].ToString()); } else { return(""); } } else { catchMensaje.LblMensaje.Text = sSql; catchMensaje.ShowDialog(); return(""); } } catch (Exception ex) { catchMensaje.LblMensaje.Text = ex.ToString(); catchMensaje.ShowDialog(); return(""); } }
//FUNCION PARA CONSULTAR DATOS DEL CLIENTE private void consultarRegistro() { try { sSql = ""; sSql += "SELECT isnull(TP.correo_electronico, '') correo_electronico," + Environment.NewLine; sSql += "isnull(TD.direccion + ', ' + TD.calle_principal + ' ' + TD.numero_vivienda + ' ' + TD.calle_interseccion, '') direccion_cliente," + Environment.NewLine; sSql += conexion.GFun_St_esnulo() + "(TT.domicilio, TT.oficina) telefono_domicilio, TT.celular, isnull(TD.direccion, '') direccion" + Environment.NewLine; sSql += "FROM tp_personas TP" + Environment.NewLine; sSql += "LEFT OUTER JOIN tp_direcciones TD ON TP.id_persona = TD.id_persona" + Environment.NewLine; sSql += "and TP.estado = 'A'" + Environment.NewLine; sSql += "and TD.estado = 'A'" + Environment.NewLine; sSql += "LEFT OUTER JOIN tp_telefonos TT ON TP.id_persona = TT.id_persona" + Environment.NewLine; sSql += "and TT.estado = 'A'" + Environment.NewLine; sSql += "WHERE TP.id_persona = " + iIdPersona; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (bRespuesta == false) { catchMensaje = new VentanasMensajes.frmMensajeCatch();; catchMensaje.LblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); return; } sDireccionEmpleado = dtConsulta.Rows[0]["direccion_cliente"].ToString().Trim().ToUpper(); sTelefonoEmpleado = dtConsulta.Rows[0]["telefono_domicilio"].ToString().Trim().ToUpper(); sMailEmpleado = dtConsulta.Rows[0]["correo_electronico"].ToString().Trim().ToUpper(); sCiudadEmpleado = dtConsulta.Rows[0]["direccion"].ToString().Trim().ToUpper(); } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeCatch(); catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
private void btnOK_Click(object sender, EventArgs e) { try { iIdFactura = dB_Ayuda_Facturas.iId; if (iIdFactura == 0) { ok.lblMensaje.Text = "No ha seleccionado ninguna factura."; ok.ShowDialog(); } else { sSql = ""; sSql += "select " + conexion.GFun_St_esnulo() + "(clave_acceso, 'NINGUNA') clave_acceso," + Environment.NewLine; sSql += "id_tipo_ambiente" + Environment.NewLine; sSql += "from cv403_facturas " + Environment.NewLine; sSql += "where id_factura = " + iIdFactura; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (bRespuesta == true) { if (dtConsulta.Rows.Count > 0) { if (dtConsulta.Rows[0].ItemArray[0].ToString() == "NINGUNA") { ok.lblMensaje.Text = "No ha generado el archivo xml. Favor vuelva a generar."; ok.ShowDialog(); } else { txtClaveAcceso.Text = dtConsulta.Rows[0]["clave_acceso"].ToString(); iIdTipoAmbiente = Convert.ToInt32(this.dtConsulta.Rows[0]["id_tipo_ambiente"].ToString()); llenarInformacionFactura(iIdFactura); } } else { ok.lblMensaje.Text = "No existe un registro de factura. Comuníquese con el administrador."; ok.ShowDialog(); } } else { catchMensaje.lblMensaje.Text = sSql; catchMensaje.ShowDialog(); } } } catch (Exception ex) { catchMensaje.lblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
public string GSub_ActualizaPantalla(string P_St_CodDoc, long P_Ln_Orden) { // P_Ln_Orden // 1 Comprobantes generados // 2 Firmados // 3 Autorizados // 4 No autorizados //FACTURA if (P_St_CodDoc == "01") { sTipoComprobanteVenta = "Fac"; sAyuda = ""; sAyuda = sAyuda + "select" + Environment.NewLine; sAyuda = sAyuda + "NF.Numero_Factura," + Environment.NewLine; if (conexion.GFun_St_Conexion() == "MYSQL") { sAyuda = sAyuda + "ltrim(concat(P.apellidos,' '," + conexion.GFun_St_esnulo() + "(P.nombres,''))) Cliente," + Environment.NewLine; } else { sAyuda = sAyuda + "ltrim(P.apellidos + ' ' + " + conexion.GFun_St_esnulo() + "(P.nombres,'')) Cliente," + Environment.NewLine; } sAyuda = sAyuda + "SubString(LOCALIDAD.valor_texto, 1, 25) Localidad,F.fecha_factura," + Environment.NewLine; sAyuda = sAyuda + "F.id_factura," + Environment.NewLine; sAyuda = sAyuda + "F.clave_acceso," + Environment.NewLine; sAyuda = sAyuda + "L.establecimiento estab,isnull(L.punto_emision,'009') ptoEmi," + Environment.NewLine; sAyuda = sAyuda + conexion.GFun_St_esnulo() + "(autorizacion,'') autorizacion," + Environment.NewLine; sAyuda = sAyuda + conexion.GFun_St_esnulo() + "(CONVERT (nvarchar(19), fecha_autorizacion, 120),'') fecha_autorizacion," + Environment.NewLine; sAyuda = sAyuda + "id_tipo_emision,id_tipo_ambiente" + Environment.NewLine; sAyuda = sAyuda + "from" + Environment.NewLine; sAyuda = sAyuda + "cv403_facturas F," + Environment.NewLine; sAyuda = sAyuda + "cv403_numeros_facturas NF," + Environment.NewLine; sAyuda = sAyuda + "tp_personas P," + Environment.NewLine; sAyuda = sAyuda + "tp_localidades L," + Environment.NewLine; sAyuda = sAyuda + "tp_codigos LOCALIDAD," + Environment.NewLine; sAyuda = sAyuda + "vta_tipocomprobante TC" + Environment.NewLine; sAyuda = sAyuda + "where" + Environment.NewLine; sAyuda = sAyuda + "F.idempresa = " + Program.iIdEmpresa + Environment.NewLine; sAyuda = sAyuda + "and F.estado = 'A'" + Environment.NewLine; sAyuda = sAyuda + "and F.estado in ('A','E')" + Environment.NewLine; sAyuda = sAyuda + "and NF.estado = 'A'" + Environment.NewLine; sAyuda = sAyuda + "and NF.id_factura = F.id_factura" + Environment.NewLine; sAyuda = sAyuda + "and F.id_persona = P.id_persona" + Environment.NewLine; sAyuda = sAyuda + "and F.id_localidad = L.id_localidad" + Environment.NewLine; // Generadas if (P_Ln_Orden == 1) { sAyuda = sAyuda + "and F.clave_acceso is not null" + Environment.NewLine; } // Firmadas else if (P_Ln_Orden == 2) { sAyuda = sAyuda + "and F.clave_acceso is not null" + Environment.NewLine; } // Autorizadas else if (P_Ln_Orden == 3) { sAyuda = sAyuda + "and F.autorizacion is not null" + Environment.NewLine; } sAyuda = sAyuda + "and L.cg_localidad = LOCALIDAD.correlativo" + Environment.NewLine; sAyuda = sAyuda + "and TC.idtipocomprobante=F.idtipocomprobante" + Environment.NewLine; sAyuda = sAyuda + "and TC.codigo='" + sTipoComprobanteVenta + "'" + Environment.NewLine; sAyuda = sAyuda + "order by F.id_factura desc"; } //RETENCION if (P_St_CodDoc == "07") { sAyuda = ""; sAyuda = sAyuda + "SELECT DISTINCT" + Environment.NewLine; if (conexion.GFun_St_Conexion() == "MYSQL") { sAyuda = sAyuda + "convert(CABCR.NUMERO_PREIMPRESO,decimal) numero_secuencial," + Environment.NewLine; sAyuda = sAyuda + "concat(PER.apellidos , ' ' , " + conexion.GFun_St_esnulo() + "(PER.nombres,'')) Razon_Social," + Environment.NewLine; } else { sAyuda = sAyuda + "convert(numeric,CABCR.NUMERO_PREIMPRESO) numero_secuencial," + Environment.NewLine; sAyuda = sAyuda + "PER.apellidos + ' ' + " + conexion.GFun_St_esnulo() + "(PER.nombres,'') Razon_Social," + Environment.NewLine; } sAyuda = sAyuda + "CABM.numero_movimiento,CABM.FECHA_MOVIMIENTO," + Environment.NewLine; sAyuda = sAyuda + "CABCR.ID_CAB_COMPROBANTE_RETENCION,CABCR.clave_acceso," + Environment.NewLine; sAyuda = sAyuda + "EstabRetencion1, ptoEmiRetencion1," + Environment.NewLine; sAyuda = sAyuda + conexion.GFun_St_esnulo() + "(autorizacion,'') autorizacion," + Environment.NewLine; sAyuda = sAyuda + conexion.GFun_St_esnulo() + "(CONVERT (nvarchar(19), fecha_autorizacion, 120),'') fecha_autorizacion," + Environment.NewLine; sAyuda = sAyuda + "id_tipo_emision,id_tipo_ambiente" + Environment.NewLine; sAyuda = sAyuda + "from" + Environment.NewLine; sAyuda = sAyuda + "cv405_comprobantes_retencion CR," + Environment.NewLine; sAyuda = sAyuda + "cv405_c_movimientos CABM," + Environment.NewLine; sAyuda = sAyuda + "cv404_auxiliares_contables AUX," + Environment.NewLine; sAyuda = sAyuda + "tp_personas PER," + Environment.NewLine; sAyuda = sAyuda + "cv405_cab_comprobantes_retencion CABCR" + Environment.NewLine; sAyuda = sAyuda + "where" + Environment.NewLine; sAyuda = sAyuda + "CABM.id_c_movimiento = CR.id_c_movimiento" + Environment.NewLine; sAyuda = sAyuda + "and AUX.id_auxiliar = CABM.id_beneficiario" + Environment.NewLine; sAyuda = sAyuda + "and PER.id_persona = CABM.id_persona" + Environment.NewLine; sAyuda = sAyuda + "and CR.ID_CAB_COMPROBANTE_RETENCION = CABCR.ID_CAB_COMPROBANTE_RETENCION" + Environment.NewLine; // Generadas if (P_Ln_Orden == 1) { sAyuda = sAyuda + "and CABCR.clave_acceso is not null" + Environment.NewLine; } // Firmadas else if (P_Ln_Orden == 2) { sAyuda = sAyuda + "and CABCR.clave_acceso is not null" + Environment.NewLine; } // Autorizadas else if (P_Ln_Orden == 3) { sAyuda = sAyuda + "and CABCR.autorizacion is not null" + Environment.NewLine; } sAyuda = sAyuda + "AND CABM.ESTADO = 'A'" + Environment.NewLine; sAyuda = sAyuda + "AND CR.ESTADO = 'A'" + Environment.NewLine; sAyuda = sAyuda + "AND CABCR.ESTADO = 'A'" + Environment.NewLine; if (conexion.GFun_St_Conexion() == "MYSQL") { sAyuda = sAyuda + "Order by convert(CABCR.NUMERO_PREIMPRESO, decimal) desc, CABM.FECHA_MOVIMIENTO desc"; } else { sAyuda = sAyuda + "Order by convert(numeric,CABCR.NUMERO_PREIMPRESO) desc, CABM.FECHA_MOVIMIENTO desc"; } } //NOTA DE CREDITO if (P_St_CodDoc == "04") { sAyuda = ""; sAyuda = sAyuda + "select" + Environment.NewLine; sAyuda = sAyuda + "NNC.Numero_Nota," + Environment.NewLine; if (conexion.GFun_St_Conexion() == "MYSQL") { sAyuda = sAyuda + "concat(P.apellidos,' '," + conexion.GFun_St_esnulo() + "(P.nombres,'')) Cliente," + Environment.NewLine; } else { sAyuda = sAyuda + "P.apellidos + ' ' + " + conexion.GFun_St_esnulo() + "(P.nombres,'') Cliente," + Environment.NewLine; } sAyuda = sAyuda + "SubString(LOCALIDAD.valor_texto, 1, 25) Localidad," + Environment.NewLine; sAyuda = sAyuda + "N.fecha_vcto," + Environment.NewLine; sAyuda = sAyuda + "N.Id_Nota_Credito,N.clave_acceso," + Environment.NewLine; sAyuda = sAyuda + "L.establecimiento estab,isnull(L.punto_emision,'009') ptoEmi," + Environment.NewLine; sAyuda = sAyuda + conexion.GFun_St_esnulo() + "(autorizacion,'') autorizacion," + Environment.NewLine; sAyuda = sAyuda + conexion.GFun_St_esnulo() + "(CONVERT (nvarchar(19), fecha_autorizacion, 120),'') fecha_autorizacion," + Environment.NewLine; sAyuda = sAyuda + "id_tipo_emision,id_tipo_ambiente" + Environment.NewLine; sAyuda = sAyuda + "from" + Environment.NewLine; sAyuda = sAyuda + "cv403_notas_credito N, tp_localidades L," + Environment.NewLine; sAyuda = sAyuda + "tp_codigos LOCALIDAD," + Environment.NewLine; sAyuda = sAyuda + "tp_personas P," + Environment.NewLine; sAyuda = sAyuda + "cv403_numeros_notas_creditos NNC" + Environment.NewLine; sAyuda = sAyuda + "where" + Environment.NewLine; sAyuda = sAyuda + "N.estado = 'A'" + Environment.NewLine; sAyuda = sAyuda + "and N.id_persona = P.id_persona" + Environment.NewLine; sAyuda = sAyuda + "and NNC.Id_Nota_Credito = N.Id_Nota_Credito" + Environment.NewLine; //If G_Ln_Id_Servidor > 1 Then // T_St_Sql = T_St_Sql & "and l.id_servidor = " & G_Ln_Id_Servidor & " " //End If sAyuda = sAyuda + "and N.id_localidad = L.id_localidad" + Environment.NewLine; sAyuda = sAyuda + "and L.cg_localidad = LOCALIDAD.correlativo" + Environment.NewLine; // Generadas if (P_Ln_Orden == 1) { sAyuda = sAyuda + "and N.clave_acceso is not null" + Environment.NewLine; } // Firmadas else if (P_Ln_Orden == 2) { sAyuda = sAyuda + "and N.clave_acceso is not null" + Environment.NewLine; } // Autorizadas else if (P_Ln_Orden == 3) { sAyuda = sAyuda + "and N.autorizacion is not null" + Environment.NewLine; } sAyuda = sAyuda + "and NNC.estado = 'A'" + Environment.NewLine; sAyuda = sAyuda + "Order by N.Id_nota_credito desc"; } //GUIA DE REMISION if (P_St_CodDoc == "06") { sAyuda = ""; sAyuda = sAyuda + "select" + Environment.NewLine; sAyuda = sAyuda + "NGR.Numero_Guia_Remision," + Environment.NewLine; if (conexion.GFun_St_Conexion() == "MYSQL") { sAyuda = sAyuda + "concat(P.apellidos,' '," + conexion.GFun_St_esnulo() + "(P.nombres,'')) Cliente," + Environment.NewLine; } else { sAyuda = sAyuda + "P.apellidos + ' ' + " + conexion.GFun_St_esnulo() + "(P.nombres,'') Cliente," + Environment.NewLine; } sAyuda = sAyuda + "SubString(LOCALIDAD.valor_texto, 1, 25) Localidad," + Environment.NewLine; sAyuda = sAyuda + "G.fecha_emision," + Environment.NewLine; sAyuda = sAyuda + "G.Id_Guia_Remision,G.clave_acceso," + Environment.NewLine; sAyuda = sAyuda + "L.establecimiento estab,"; sAyuda = sAyuda + conexion.GFun_St_esnulo() + "(L.punto_emision,'009') ptoEmi," + Environment.NewLine; sAyuda = sAyuda + conexion.GFun_St_esnulo() + "(G.autorizacion,'') autorizacion," + Environment.NewLine; sAyuda = sAyuda + conexion.GFun_St_esnulo() + "(CONVERT (nvarchar(19), G.fecha_autorizacion, 120),'') fecha_autorizacion," + Environment.NewLine; sAyuda = sAyuda + "G.id_tipo_emision,G.id_tipo_ambiente" + Environment.NewLine; sAyuda = sAyuda + "from" + Environment.NewLine; sAyuda = sAyuda + "cv403_guias_remision G, tp_localidades L," + Environment.NewLine; sAyuda = sAyuda + "tp_codigos LOCALIDAD," + Environment.NewLine; sAyuda = sAyuda + "tp_personas P," + Environment.NewLine; sAyuda = sAyuda + "cv403_numeros_guias_remision NGR" + Environment.NewLine; sAyuda = sAyuda + "where" + Environment.NewLine; sAyuda = sAyuda + "G.estado = 'A'" + Environment.NewLine; sAyuda = sAyuda + "and G.id_destinatario = P.id_persona" + Environment.NewLine; sAyuda = sAyuda + "and NGR.Id_Guia_Remision = G.Id_Guia_Remision" + Environment.NewLine; //If G_Ln_Id_Servidor > 1 Then // T_St_Sql = T_St_Sql & "and L.id_servidor = " & G_Ln_Id_Servidor & " " //End If sAyuda = sAyuda + "and G.id_localidad = L.id_localidad" + Environment.NewLine; sAyuda = sAyuda + "and L.cg_localidad = LOCALIDAD.correlativo" + Environment.NewLine; // Generadas if (P_Ln_Orden == 1) { sAyuda = sAyuda + "and G.clave_acceso is not null" + Environment.NewLine; } // Firmadas else if (P_Ln_Orden == 2) { sAyuda = sAyuda + "and G.clave_acceso is not null" + Environment.NewLine; } // Autorizadas else if (P_Ln_Orden == 3) { sAyuda = sAyuda + "and G.autorizacion is not null" + Environment.NewLine; } sAyuda = sAyuda + "and NGR.estado = 'A'" + Environment.NewLine; sAyuda = sAyuda + "Order by G.Id_Guia_Remision desc"; } return(sAyuda); }
//Función para crear el reporte public void crearReporte() { try { sSql = ""; sSql += "Select m.Fecha, m.Cg_Empresa, m.ID_BODEGA, m.CG_TIPO_MOVIMIENTO," + Environment.NewLine; sSql += "m.ID_LOCALIDAD, m.Cg_Moneda_Base, m.Referencia_Externa, m.Nota_pedido," + Environment.NewLine; sSql += "m.FACTURA, m.Nota_entrega, m.Observacion, m.cg_motivo_movimiento_bodega," + Environment.NewLine; sSql += "m.Id_Auxiliar, m.Id_Persona, m.Porcentaje_IVA,m.Porcentaje_descuento," + Environment.NewLine; sSql += "m.id_c_movimiento, m.estado_replica, m.estado" + Environment.NewLine; sSql += "from cv402_cabecera_movimientos m left outer join" + Environment.NewLine; sSql += "cv404_auxiliares_contables a on m.id_auxiliar = a.id_auxiliar" + Environment.NewLine; sSql += "where m.Id_Movimiento_Bodega=" + iIdMovimientoBodega; dtConsulta = new DataTable(); dtConsulta.Clear(); brespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (brespuesta == true) { if (dtConsulta.Rows.Count > 0) { ds = new dsReporte(); //Creo una variable de tipo dsReporte dt = ds.Tables["dtIngresos"]; // intancio el dataset dtIngresos dt.Clear(); // limpio el datatable DataRow dr; //creo una varible de tipo datarow para aumentar lineas a mi reporte for (int i = 0; i < dtConsulta.Rows.Count; i++) // recorro todo el datatable de la consulta sql { dr = dt.NewRow(); // instancio una nuevo fila a mi datatable dr["nombreEmpresa"] = "RIVAS PAOLA"; // se llena el nombre de la empresa (por el momento se ingresa manualmente) dr["numeroIngreso"] = sNumeroMovimiento; // se llena con el numero de movimiento dr["fechaIngreso"] = dtConsulta.Rows[i].ItemArray[0].ToString(); // se llena con la fecha int iIdBodega = Convert.ToInt32(dtConsulta.Rows[i].ItemArray[2].ToString()); dr["nombreBodega"] = buscarBodega(iIdBodega); // me manda a una función que me retorna el nombre de la bodega dr["referencia"] = dtConsulta.Rows[i].ItemArray[6].ToString(); // me devuelve el número de referencia dr["proveedor"] = buscarNombreProveedor(Convert.ToInt32(dtConsulta.Rows[i].ItemArray[12].ToString())); // función que me retorna el nombre del proovedor dr["Iva"] = dtConsulta.Rows[i].ItemArray[14].ToString(); // Me devuelve el porcentaje del iva dr["numeroFactura"] = dtConsulta.Rows[i].ItemArray[8].ToString(); //Me devuelve el número de factura que está almacenado en la base de datos dr["horaIngreso"] = "10:49"; //la hora está puesta manualmente hasta el momento dr["motivo"] = buscarMotivo(Convert.ToInt32(dtConsulta.Rows[i].ItemArray[11].ToString())); //Función que me devuelve el nombre del motivo dr["descuento"] = dtConsulta.Rows[i].ItemArray[15].ToString(); // me devuelve el porcentaje de descuento dr["observacion"] = dtConsulta.Rows[i].ItemArray[10].ToString(); // me devuelve la observación dr["notaEntrega"] = dtConsulta.Rows[i].ItemArray[9].ToString(); dt.Rows.Add(dr); } sSql = ""; sSql += "SELECT MB.CORRELATIVO, P.codigo codigo_producto, N.nombre producto, MB.Id_Producto," + Environment.NewLine; sSql += "MB.especificacion, U.codigo unidad, MB.cg_unidad_compra cg_unidad_compra, MB.CANTIDAD," + Environment.NewLine; sSql += conexion.GFun_St_esnulo() + "(MB.Valor_Unitario, 0) Valor_unitario," + Environment.NewLine; sSql += conexion.GFun_St_esnulo() + "(round(100*MB.Valor_Dscto/MB.valor_Unitario,2), 0) Pct_Dscto," + Environment.NewLine; sSql += conexion.GFun_St_esnulo() + "(MB.Valor_Iva, 0) Valor_Iva, " + conexion.GFun_St_esnulo() + "(MB.VALOR_DSCTO, 0) valor_dscto," + Environment.NewLine; sSql += "Case when P.Paga_Iva = 1 Then 1 Else 0 End Paga_Iva" + Environment.NewLine; sSql += "from cv402_movimientos_bodega MB, cv401_productos P," + Environment.NewLine; sSql += "tp_codigos U, cv401_nombre_productos N" + Environment.NewLine; sSql += "where MB.Id_Producto = P.Id_Producto" + Environment.NewLine; sSql += "and P.Id_Producto = N.Id_Producto" + Environment.NewLine; sSql += "and N.Nombre_Interno = 1" + Environment.NewLine; sSql += "and N.Estado = 'A'" + Environment.NewLine; sSql += "and MB.CG_UNIDAD_COMPRA = U.Correlativo " + Environment.NewLine; sSql += "and MB.Id_Movimiento_Bodega = " + iIdMovimientoBodega + Environment.NewLine; sSql += "and MB.Estado = 'A'" + Environment.NewLine; sSql += "order By MB.Correlativo"; DataTable dtConsulta1 = new DataTable(); dtDetalle = ds.Tables["dtDetalleIngresos"]; dtConsulta1.Clear(); DataRow drDetalle; brespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta1, sSql); if (brespuesta == true) { if (dtConsulta1.Rows.Count > 0) { for (int i = 0; i < dtConsulta1.Rows.Count; i++) { drDetalle = dtDetalle.NewRow(); drDetalle["item"] = i + 1; drDetalle["codigo"] = dtConsulta1.Rows[i].ItemArray[1].ToString(); drDetalle["producto"] = dtConsulta1.Rows[i].ItemArray[2].ToString(); drDetalle["cantidad"] = dtConsulta1.Rows[i].ItemArray[7].ToString(); drDetalle["precio"] = dtConsulta1.Rows[i].ItemArray[8].ToString(); drDetalle["descuentoProducto"] = dtConsulta1.Rows[i].ItemArray[11].ToString(); double dbCantidad = Convert.ToDouble(dtConsulta1.Rows[i].ItemArray[7].ToString()); double dbDescuento = Convert.ToDouble(dtConsulta1.Rows[i].ItemArray[11].ToString()); double dbPrecio = Convert.ToDouble(dtConsulta1.Rows[i].ItemArray[8].ToString()); double dbIva = Convert.ToDouble(dtConsulta1.Rows[i].ItemArray[10].ToString()); double dbTotal = (dbCantidad * (dbPrecio + dbIva - dbDescuento)); drDetalle["total"] = dbTotal; dtDetalle.Rows.Add(drDetalle); } } } // llenarDetalle(); Reportes.reporteIngresoBodega reporte = new Reportes.reporteIngresoBodega(); reporte.SetDataSource(dt); reporte.Subreports[0].SetDataSource(dtDetalle); //ESTA LINEA PERMITE VISUALIZAR EL REPORTE ANTES DE IMPRIMIR this.crystalReportViewer1.ReportSource = reporte; crystalReportViewer1.Refresh(); } } else { MessageBox.Show("Ocurrió un problema al crear el reporte", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception) { MessageBox.Show("Ocurrió un problema al crear el reporte", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void datosCliente() { try { //INSTRUCCION SQL PARA CONSULTAR LOS DATOS DEL CLIENTE sSql = ""; sSql += "select identificacion, apellidos, nombres, correo_electronico," + Environment.NewLine; sSql += "codigo_alterno, id_persona" + Environment.NewLine; sSql += "from tp_personas" + Environment.NewLine; sSql += "where id_persona = " + Convert.ToInt32(Program.sIDPERSONA); dtDomicilio = new DataTable(); dtDomicilio.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtDomicilio, sSql); if (bRespuesta == true) { if (dtDomicilio.Rows.Count > 0) { sTexto += "----------------------------------------" + Environment.NewLine; sNombreCliente = (dtDomicilio.Rows[0][2].ToString() + " " + dtDomicilio.Rows[0][1].ToString()).Trim(); sTexto += "CLIENTE:".PadRight(11, ' '); if (sNombreCliente.Length > 29) { sTexto += caracteres.saltoLinea(sNombreCliente, 11); } else { sTexto += sNombreCliente + Environment.NewLine; } //sTexto += "CLIENTE:".PadRight(11, ' ') + (dtDomicilio.Rows[0][2].ToString() + " " + dtDomicilio.Rows[0][1].ToString()).Trim() + Environment.NewLine; sTexto += "CI/RUC:".PadRight(11, ' ') + dtDomicilio.Rows[0][0].ToString() + Environment.NewLine; sTexto += "TELEFONO:".PadRight(11, ' ') + dtDomicilio.Rows[0][4].ToString() + Environment.NewLine; } } else { catchMensaje.LblMensaje.Text = sSql; catchMensaje.ShowDialog(); goto fin; } //INSTRUCCION SQL PARA EXTRAER LA DIRECCIÓN DEL CLIENTE sDireccionPrecuenta = ""; sSql = ""; sSql += "select direccion, calle_principal, calle_interseccion," + Environment.NewLine; sSql += "numero_vivienda, referencia" + Environment.NewLine; sSql += "from tp_direcciones" + Environment.NewLine; sSql += "where id_persona = " + Program.sIDPERSONA + Environment.NewLine; sSql += "and estado = 'A'"; dtDomicilio = new DataTable(); dtDomicilio.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtDomicilio, sSql); if (bRespuesta == true) { if (dtDomicilio.Rows.Count > 0) { sDireccionPrecuenta = "DIRECCION: " + dtDomicilio.Rows[0][0].ToString().ToUpper() + " " + dtDomicilio.Rows[0][1].ToString().ToUpper() + " " + dtDomicilio.Rows[0][3].ToString().ToUpper(); if (dtDomicilio.Rows[0]["calle_interseccion"].ToString() != "") { sDireccionPrecuenta = sDireccionPrecuenta + " Y " + dtDomicilio.Rows[0][2].ToString().ToUpper(); } } } else { catchMensaje.LblMensaje.Text = sSql; catchMensaje.ShowDialog(); goto fin; } //FUNCION PARA EXTRAER LA REFERENCIA DEL DOMICILIO sSql = ""; sSql += "select top 1 " + conexion.GFun_St_esnulo() + "(referencia, '') referencia" + Environment.NewLine; sSql += "from tp_vw_direcciones" + Environment.NewLine; sSql += "where id_persona = " + Program.sIDPERSONA + Environment.NewLine; sSql += "and estado = 'A'"; dtDomicilio = new DataTable(); dtDomicilio.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtDomicilio, sSql); if (bRespuesta == true) { if (dtDomicilio.Rows.Count > 0) { if (dtDomicilio.Rows[0][0].ToString() != "") { sDireccionPrecuenta = sDireccionPrecuenta + ", " + dtDomicilio.Rows[0][0].ToString(); } } } else { catchMensaje.LblMensaje.Text = sSql; catchMensaje.ShowDialog(); goto fin; } if (sDireccionPrecuenta.Length > 40) { sTexto += caracteres.saltoLinea(sDireccionPrecuenta.Trim(), 0); } else { sTexto += sDireccionPrecuenta.Trim() + Environment.NewLine; } goto fin; } catch (Exception ex) { catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } fin : { } }
//Función para cargar los datos private void cargarDatos() { try { bNuevo = false; sSql = ""; sSql += "Select m.Fecha, m.Cg_Empresa, m.ID_BODEGA," + conexion.GFun_St_esnulo() + "(m.CG_TIPO_MOVIMIENTO, '')cg_tipo_movimiento," + Environment.NewLine; sSql += conexion.GFun_St_esnulo() + "(m.Referencia_Externa, '') referencia_externa, " + conexion.GFun_St_esnulo() + "(m.ORDEN_TRABAJO, '') orden_trabajo," + Environment.NewLine; sSql += conexion.GFun_St_esnulo() + "(m.Orden_Diseno, '') orden_diseno, " + conexion.GFun_St_esnulo() + "(m.Nota_Entrega, '') nota_entrega," + Environment.NewLine; sSql += conexion.GFun_St_esnulo() + "(m.Observacion, '') observacion, " + conexion.GFun_St_esnulo() + "(m.cg_motivo_movimiento_bodega, 6166)cg_motivo_movimiento_bodega," + Environment.NewLine; sSql += "Codigo_Proveedor = a.codigo, m.id_pedido, m.id_auxiliar, " + conexion.GFun_St_esnulo() + "(m.id_persona, 64935) id_persona," + Environment.NewLine; sSql += "m.id_c_movimiento, m.estado_replica" + Environment.NewLine; sSql += "from cv402_cabecera_movimientos m left outer join" + Environment.NewLine; sSql += "cv404_auxiliares_contables a on m.id_auxiliar = a.id_auxiliar" + Environment.NewLine; sSql += "Where m.Id_Movimiento_Bodega= " + dBAyudaIngresoNumeros.iId; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (bRespuesta == true) { if (dtConsulta.Rows.Count > 0) { string sFecha = dtConsulta.Rows[0][0].ToString(); txtFechaAplicacion.Text = Convert.ToDateTime(sFecha).ToString("dd/MM/yyy"); if (dtConsulta.Rows[0][9] != null || dtConsulta.Rows[0][9].ToString() != " ") { cmbMotivo.SelectedValue = dtConsulta.Rows[0][9].ToString(); } if (dtConsulta.Rows[0][4].ToString() != null || dtConsulta.Rows[0][4].ToString() != "") { txtComentarios.Text = dtConsulta.Rows[0][4].ToString(); } if (dtConsulta.Rows[0][5].ToString() != null || dtConsulta.Rows[0][5].ToString() != "") { txtOrdenFabricacion.Text = dtConsulta.Rows[0][5].ToString(); } if (dtConsulta.Rows[0][6].ToString() != null || dtConsulta.Rows[0][6].ToString() != "") { txtOrdenDisenio.Text = dtConsulta.Rows[0][6].ToString(); } if (dtConsulta.Rows[0][7].ToString() != null || dtConsulta.Rows[0][7].ToString() != "") { txtNotaEntrega.Text = dtConsulta.Rows[0][7].ToString(); } if (dtConsulta.Rows[0][12].ToString() != null || dtConsulta.Rows[0][12].ToString() != "") { sCorrelativoProveedor = dtConsulta.Rows[0][12].ToString(); } if (dtConsulta.Rows[0][13].ToString() != null || dtConsulta.Rows[0][13].ToString() != "") { iIdPersona = Convert.ToInt32(dtConsulta.Rows[0][13].ToString()); } if (dtConsulta.Rows[0][8].ToString() != "") { txtComentarios.Text = dtConsulta.Rows[0][8].ToString(); } else { txtComentarios.Text = dtConsulta.Rows[0][4].ToString(); } string sSql1; sSql1 = ""; sSql1 += "select codigo, descripcion, id_auxiliar" + Environment.NewLine; sSql1 += "from cv404_auxiliares_contables" + Environment.NewLine; sSql1 += "where id_auxiliar = " + sCorrelativoProveedor; DataTable dtAyuda = new DataTable(); dtAyuda.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtAyuda, sSql1); if (bRespuesta == true) { if (dtAyuda.Rows.Count > 0) { dBAyudaProveedor.txtIdentificacion.Text = dtAyuda.Rows[0][0].ToString(); dBAyudaProveedor.txtDatos.Text = dtAyuda.Rows[0][1].ToString(); dBAyudaProveedor.iId = Convert.ToInt32(dtAyuda.Rows[0][2].ToString()); } } sSql1 = ""; sSql1 += "select identificacion, apellidos +' '+ isnull(nombres, '') nombre, id_persona" + Environment.NewLine; sSql1 += "from tp_personas" + Environment.NewLine; sSql1 += "where id_persona = " + iIdPersona; dtAyuda = new DataTable(); dtAyuda.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtAyuda, sSql1); if (bRespuesta == true) { if (dtAyuda.Rows.Count > 0) { dBAyudaPersona.txtIdentificacion.Text = dtAyuda.Rows[0][0].ToString(); dBAyudaPersona.txtDatos.Text = dtAyuda.Rows[0][1].ToString(); dBAyudaPersona.iId = Convert.ToInt32(dtAyuda.Rows[0][2].ToString()); } } else { catchMensaje.lblMensaje.Text = sSql; catchMensaje.ShowDialog(); return; } cargarGrid(); } } else { catchMensaje.lblMensaje.Text = sSql; catchMensaje.ShowDialog(); return; } } catch (Exception ex) { catchMensaje.lblMensaje.Text = ex.ToString(); catchMensaje.ShowDialog(); } }
//FUNCION PARA VERIFICAR SI YA ESTÁ EMITIDA UNA FACTURA EN UNA ORDEN private int validarPedido() { try { sSql = ""; sSql += "select NCP.id_pedido, F.id_persona, TP.identificacion," + Environment.NewLine; sSql += conexion.GFun_St_esnulo() + "(F.autorizacion, 0) autorizacion, F.id_factura," + Environment.NewLine; sSql += "F.idtipocomprobante, F.direccion_factura, F.telefono_factura, F.correo_electronico," + Environment.NewLine; sSql += "TP.apellidos, isnull(TP.nombres, '') nombres" + Environment.NewLine; sSql += "from cv403_numero_cab_pedido NCP, cv403_facturas_pedidos FP," + Environment.NewLine; sSql += "cv403_facturas F, tp_personas TP" + Environment.NewLine; sSql += "where FP.id_pedido = NCP.id_pedido" + Environment.NewLine; sSql += "and FP.id_factura = F.id_factura" + Environment.NewLine; sSql += "and F.id_persona = TP.id_persona" + Environment.NewLine; sSql += "and FP.estado = 'A'" + Environment.NewLine; sSql += "and NCP.estado = 'A'" + Environment.NewLine; sSql += "and TP.estado = 'A'" + Environment.NewLine; sSql += "and F.estado = 'A'" + Environment.NewLine; sSql += "and F.facturaelectronica = 1" + Environment.NewLine; sSql += "and NCP.numero_pedido = " + Convert.ToInt32(txtBuscar.Text.Trim()) + Environment.NewLine; sSql += "order by NCP.id_numero_cab_pedido desc"; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (bRespuesta == true) { if (dtConsulta.Rows.Count > 0) { iIdOrden = Convert.ToInt32(dtConsulta.Rows[0]["id_pedido"].ToString()); iIdPersona = Convert.ToInt32(dtConsulta.Rows[0]["id_persona"].ToString()); txtIdentificacion.Text = dtConsulta.Rows[0]["identificacion"].ToString(); sAutorizacion = dtConsulta.Rows[0]["autorizacion"].ToString(); iIdFactura = Convert.ToInt32(dtConsulta.Rows[0]["id_factura"].ToString()); iIdTipoComprobante = Convert.ToInt32(dtConsulta.Rows[0]["idtipocomprobante"].ToString()); txtDireccion.Text = dtConsulta.Rows[0]["direccion_factura"].ToString(); txtTelefono.Text = dtConsulta.Rows[0]["telefono_factura"].ToString(); txtMail.Text = dtConsulta.Rows[0]["correo_electronico"].ToString(); txtApellidos.Text = dtConsulta.Rows[0]["apellidos"].ToString(); txtNombres.Text = dtConsulta.Rows[0]["nombres"].ToString(); return(1); } else { return(0); } } else { return(0); } } catch (Exception ex) { catchMensaje.LblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); return(0); } }
//FUNCION PARA CONSULTAR DATOS DEL CLIENTE private void consultarRegistro() { try { sSql = ""; sSql += "SELECT TP.correo_electronico," + Environment.NewLine; sSql += "TD.direccion + ', ' + TD.calle_principal + ' ' + TD.numero_vivienda + ' ' + TD.calle_interseccion direccion_cliente," + Environment.NewLine; sSql += conexion.GFun_St_esnulo() + "(TT.domicilio, TT.oficina) telefono_domicilio, TT.celular, TD.direccion" + Environment.NewLine; sSql += "FROM tp_personas TP" + Environment.NewLine; sSql += "LEFT OUTER JOIN tp_direcciones TD ON TP.id_persona = TD.id_persona" + Environment.NewLine; sSql += "and TP.estado = 'A'" + Environment.NewLine; sSql += "and TD.estado = 'A'" + Environment.NewLine; sSql += "LEFT OUTER JOIN tp_telefonos TT ON TP.id_persona = TT.id_persona" + Environment.NewLine; sSql += "and TT.estado = 'A'" + Environment.NewLine; sSql += "WHERE TP.id_persona = @id_persona"; parametro = new SqlParameter[1]; parametro[0] = new SqlParameter(); parametro[0].ParameterName = "@id_persona"; parametro[0].SqlDbType = SqlDbType.Int; parametro[0].Value = iIdPersona; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro_Parametros(dtConsulta, sSql, parametro); if (bRespuesta == false) { catchMensaje = new VentanasMensajes.frmMensajeNuevoCatch(); catchMensaje.lblMensaje.Text = conexion.sMensajeError; catchMensaje.ShowDialog(); return; } if (dtConsulta.Rows.Count > 0) { sMail = dtConsulta.Rows[0]["correo_electronico"].ToString(); sDireccion = dtConsulta.Rows[0]["direccion_cliente"].ToString(); sCiudad = dtConsulta.Rows[0]["direccion"].ToString(); if (dtConsulta.Rows[0]["telefono_domicilio"].ToString() != "") { sTelefono = dtConsulta.Rows[0]["telefono_domicilio"].ToString(); } else if (dtConsulta.Rows[0]["celular"].ToString() != "") { sTelefono = dtConsulta.Rows[0]["celular"].ToString(); } else { sTelefono = ""; } } else { ok = new VentanasMensajes.frmMensajeNuevoOk(); ok.lblMensaje.Text = "No se encuentra el registro del cliente. Comuníquese con el administrador."; ok.ShowDialog(); } } catch (Exception ex) { catchMensaje = new VentanasMensajes.frmMensajeNuevoCatch(); catchMensaje.lblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); } }
//FUNCION PARA INSERTAR LA FACTURA private bool insertarFactura() { try { //SELECCIONAR LOS DATOS DE LA LOCALIDAD //---------------------------------------------------------------------------------------------------- sSql = ""; sSql += "select L.establecimiento, L.punto_emision, " + Environment.NewLine; sSql += "P.numero_factura, P.numero_pago, P.id_localidad_impresora" + Environment.NewLine; sSql += "from tp_localidades L, tp_localidades_impresoras P " + Environment.NewLine; sSql += "where L.id_localidad = P.id_localidad" + Environment.NewLine; sSql += "and L.id_localidad = " + Program.iIdLocalidad + Environment.NewLine; sSql += "and L.estado = 'A'" + Environment.NewLine; sSql += "and P.estado = 'A'"; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (bRespuesta == false) { catchMensaje.lblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); return(false); } sEstablecimiento = dtConsulta.Rows[0]["establecimiento"].ToString(); sPuntoEmision = dtConsulta.Rows[0]["punto_emision"].ToString(); sNumeroFactura = dtConsulta.Rows[0]["numero_factura"].ToString(); sNumeroPago = dtConsulta.Rows[0]["numero_pago"].ToString(); iIdLocalidadImpresora = Convert.ToInt32(dtConsulta.Rows[0]["id_localidad_impresora"].ToString()); //SELECCIONAR LOS DATOS DEL CLIENTE //---------------------------------------------------------------------------------------------------- sSql = ""; sSql += "SELECT TP.identificacion, isnull(TP.nombres, '') nombres, TP.apellidos, TP.correo_electronico," + Environment.NewLine; sSql += "TD.direccion + ', ' + TD.calle_principal + ' ' + TD.numero_vivienda + ' ' + TD.calle_interseccion direccion_cliente," + Environment.NewLine; sSql += conexion.GFun_St_esnulo() + "(TT.domicilio, TT.oficina) telefono_domicilio, TT.celular, TD.direccion" + Environment.NewLine; sSql += "FROM tp_personas TP" + Environment.NewLine; sSql += "LEFT OUTER JOIN tp_direcciones TD ON TP.id_persona = TD.id_persona" + Environment.NewLine; sSql += "and TP.estado = 'A'" + Environment.NewLine; sSql += "and TD.estado = 'A'" + Environment.NewLine; sSql += "LEFT OUTER JOIN tp_telefonos TT ON TP.id_persona = TT.id_persona" + Environment.NewLine; sSql += "and TT.estado = 'A'" + Environment.NewLine; sSql += "WHERE TP.id_persona = " + iIdPersona; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (bRespuesta == false) { catchMensaje.lblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); return(false); } sIdentificacion = dtConsulta.Rows[0]["identificacion"].ToString(); sCliente = (dtConsulta.Rows[0]["nombres"].ToString().Trim().ToUpper() + " " + dtConsulta.Rows[0]["apellidos"].ToString().Trim().ToUpper()).Trim(); sCorreoElectronico = dtConsulta.Rows[0]["correo_electronico"].ToString().Trim().ToLower(); sDireccion = dtConsulta.Rows[0]["direccion_cliente"].ToString().Trim().ToUpper(); sCiudadFactura = dtConsulta.Rows[0]["direccion"].ToString().Trim().ToUpper(); if (dtConsulta.Rows[0]["telefono_domicilio"].ToString().Trim() != "") { sTelefono = dtConsulta.Rows[0]["telefono_domicilio"].ToString().Trim(); } else { dtConsulta.Rows[0]["celular"].ToString().Trim(); } //SELECCIONAR LOS DATOS DEL METODO PAGO //---------------------------------------------------------------------------------------------------- sSql = ""; sSql += "select FC.id_pos_metodo_pago, FPA.id_forma_pago, FC.cg_tipo_documento" + Environment.NewLine; sSql += "from pos_tipo_forma_cobro FC INNER JOIN" + Environment.NewLine; sSql += "pos_metodo_pago MP ON MP.id_pos_metodo_pago = FC.id_pos_metodo_pago" + Environment.NewLine; sSql += "and MP.estado = 'A'" + Environment.NewLine; sSql += "and FC.estado = 'A' INNER JOIN" + Environment.NewLine; sSql += "sri_forma_pago SFP ON SFP.id_sri_forma_pago = MP.id_sri_forma_pago" + Environment.NewLine; sSql += "and SFP.estado = 'A' INNER JOIN" + Environment.NewLine; sSql += "cv403_formas_pagos FPA ON SFP.id_sri_forma_pago = FPA.id_sri_forma_pago" + Environment.NewLine; sSql += "and FPA.estado = 'A'" + Environment.NewLine; sSql += "where MP.codigo = 'CR'" + Environment.NewLine; sSql += "and FPA.id_localidad = " + Program.iIdLocalidad; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (bRespuesta == false) { catchMensaje.lblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); return(false); } if (dtConsulta.Rows.Count == 0) { ok.lblMensaje.Text = "No se encuentra configurado el registro para cobros. Comuníquese con el administrador."; ok.ShowDialog(); return(false); } iIdTipoFormaCobro = Convert.ToInt32(dtConsulta.Rows[0]["id_pos_metodo_pago"].ToString()); iIdFormaPago = Convert.ToInt32(dtConsulta.Rows[0]["id_forma_pago"].ToString()); iCgTipoDocumento = Convert.ToInt32(dtConsulta.Rows[0]["cg_tipo_documento"].ToString()); sFecha = Program.sFechaSistema.ToString("yyyy/MM/dd"); iFacturaElectronica_P = 0; if (Program.iFacturacionElectronica == 1) { iFacturaElectronica_P = 1; if (configuracionFacturacion() == false) { return(false); } sClaveAcceso = sGenerarClaveAcceso(); } //INICIAMOS UNA NUEVA TRANSACCION //------------------------------------------------------------------------------------------------------------------ if (!conexion.GFun_Lo_Maneja_Transaccion(Program.G_INICIA_TRANSACCION)) { ok.lblMensaje.Text = "Error al abrir transacción"; ok.ShowDialog(); return(false); } //INSERTAR EN LA TABLA CV403_FACTURAS //------------------------------------------------------------------------------------------------------------------ sSql = ""; sSql += "insert into cv403_facturas (idempresa, id_persona, cg_empresa, idtipocomprobante," + Environment.NewLine; sSql += "id_localidad, idformulariossri, id_vendedor, id_forma_pago, id_forma_pago2, id_forma_pago3," + Environment.NewLine; sSql += "fecha_factura, fecha_vcto, cg_moneda, valor, cg_estado_factura, editable, fecha_ingreso, " + Environment.NewLine; sSql += "usuario_ingreso, terminal_ingreso, estado, numero_replica_trigger, numero_control_replica, " + Environment.NewLine; sSql += "Direccion_Factura,Telefono_Factura,Ciudad_Factura, correo_electronico, servicio," + Environment.NewLine; sSql += "facturaelectronica, id_tipo_emision, id_tipo_ambiente, clave_acceso)" + Environment.NewLine; sSql += "values(" + Environment.NewLine; sSql += Program.iIdEmpresa + ", " + iIdPersona + ", " + Program.iCgEmpresa + "," + Environment.NewLine; sSql += "1," + Program.iIdLocalidad + ", " + Program.iIdFormularioSri + ", " + Program.iIdVendedor + ", " + iIdFormaPago + ", " + Environment.NewLine; sSql += "null, null, '" + sFecha + "', '" + sFecha + "', " + Program.iMoneda + ", " + dbTotal + ", 0, 0, GETDATE()," + Environment.NewLine; sSql += "'" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "', 'A', 1, 0," + Environment.NewLine; sSql += "'" + sDireccion + "', '" + sTelefono + "', '" + sCiudadFactura + "'," + Environment.NewLine; sSql += "'" + sCorreoElectronico + "', 0, " + iFacturaElectronica_P + ", " + iIdTipoEmision + ", " + iIdTipoAmbiente + "," + Environment.NewLine; if (iFacturaElectronica_P == 1) { sSql += "'" + sClaveAcceso + "')"; } else { sSql += "null)"; } if (!conexion.GFun_Lo_Ejecuta_SQL(sSql)) { catchMensaje.lblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); return(false); } sTabla = "cv403_facturas"; sCampo = "id_factura"; iMaximo = conexion.GFun_Ln_Saca_Maximo_ID(sTabla, sCampo, "", Program.sDatosMaximo); if (iMaximo == -1) { ok.lblMensaje.Text = "No se pudo obtener el codigo de la tabla " + sTabla; ok.ShowDialog(); return(false); } iIdFactura = Convert.ToInt32(iMaximo); //INSERTAR EN LA TABLA CV403_NUMEROS_FACTURAS //----------------------------------------------------------------------------------------------------- sSql = ""; sSql += "insert into cv403_numeros_facturas (id_factura, idtipocomprobante, numero_factura," + Environment.NewLine; sSql += "fecha_ingreso, usuario_ingreso, terminal_ingreso, estado, numero_replica_trigger," + Environment.NewLine; sSql += "numero_control_replica) " + Environment.NewLine; sSql += "values (" + Environment.NewLine; sSql += iIdFactura + ", 1, " + sNumeroFactura + ", GETDATE()," + Environment.NewLine; sSql += "'" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "', 'A', 1, 0 )"; if (!conexion.GFun_Lo_Ejecuta_SQL(sSql)) { catchMensaje.lblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); return(false); } //ACTUALIZAR LOS NUMEROS EN TP_LOCALIDADES_IMPRESORAS //----------------------------------------------------------------------------------------------------- sSql = ""; sSql += "update tp_localidades_impresoras set" + Environment.NewLine; sSql += "numero_factura = numero_factura + 1," + Environment.NewLine; sSql += "numero_pago = numero_pago + 1" + Environment.NewLine; sSql += "where id_localidad = " + Program.iIdLocalidad; if (!conexion.GFun_Lo_Ejecuta_SQL(sSql)) { catchMensaje.lblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); return(false); } //INSERTAR EN LA TABLA CV403_PAGOS //------------------------------------------------------------------------------------ sSql = ""; sSql += "insert into cv403_pagos (" + Environment.NewLine; sSql += "idempresa, id_persona, fecha_pago, cg_moneda, valor," + Environment.NewLine; sSql += "propina, cg_empresa, id_localidad, cg_cajero, fecha_ingreso," + Environment.NewLine; sSql += "usuario_ingreso, terminal_ingreso, estado, " + Environment.NewLine; sSql += "numero_replica_trigger, numero_control_replica,cambio) " + Environment.NewLine; sSql += "values(" + Environment.NewLine; sSql += Program.iIdEmpresa + ", " + iIdPersona + ", '" + sFecha + "', " + Program.iMoneda + "," + Environment.NewLine; sSql += dbTotal + ", 0, " + Program.iCgEmpresa + ", " + Program.iIdLocalidad + ", 7799, GETDATE()," + Environment.NewLine; sSql += "'" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "', 'A' , 1, 0, 0)"; if (!conexion.GFun_Lo_Ejecuta_SQL(sSql)) { catchMensaje.lblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); return(false); } sTabla = "cv403_pagos"; sCampo = "id_pago"; iMaximo = conexion.GFun_Ln_Saca_Maximo_ID(sTabla, sCampo, "", Program.sDatosMaximo); if (iMaximo == -1) { ok.lblMensaje.Text = "No se pudo obtener el codigo de la tabla " + sTabla; ok.ShowDialog(); return(false); } iIdPago = Convert.ToInt32(iMaximo); //INSERTAR EN LA TABLA CV403_NUMEROS_PAGOS //----------------------------------------------------------------------------------------------------- sSql = ""; sSql += "insert into cv403_numeros_pagos (" + Environment.NewLine; sSql += "id_pago, serie, numero_pago, fecha_ingreso, usuario_ingreso," + Environment.NewLine; sSql += "terminal_ingreso, estado, numero_replica_trigger, numero_control_replica)" + Environment.NewLine; sSql += "values(" + Environment.NewLine; sSql += iIdPago + ", 'A', " + sNumeroPago + ", GETDATE(), '" + Program.sDatosMaximo[0] + "'," + Environment.NewLine; sSql += "'" + Program.sDatosMaximo[1] + "', 'A', 1, 0)"; if (!conexion.GFun_Lo_Ejecuta_SQL(sSql)) { catchMensaje.lblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); return(false); } //INSERTAR EN LA TABLA CV403_DOCUMENTOS_PAGOS //----------------------------------------------------------------------------------------------------- sSql = ""; sSql += "insert into cv403_documentos_pagos (" + Environment.NewLine; sSql += "id_pago, cg_tipo_documento, numero_documento, fecha_vcto, " + Environment.NewLine; sSql += "cg_moneda, cotizacion, valor, id_pos_tipo_forma_cobro," + Environment.NewLine; sSql += "estado, fecha_ingreso, usuario_ingreso, terminal_ingreso," + Environment.NewLine; sSql += "numero_replica_trigger, numero_control_replica, valor_recibido)" + Environment.NewLine; sSql += "values(" + Environment.NewLine; sSql += iIdPago + ", " + iCgTipoDocumento + ", 9999, '" + sFecha + "', " + Environment.NewLine; sSql += Program.iMoneda + ", 1, " + dbTotal + ", " + iIdTipoFormaCobro + ", " + Environment.NewLine; sSql += "'A', GETDATE(), '" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "', 0, 0, " + dbTotal + ")"; if (!conexion.GFun_Lo_Ejecuta_SQL(sSql)) { catchMensaje.lblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); return(false); } for (int i = 0; i < dtPedidos.Rows.Count; i++) { iIdPedido = Convert.ToInt32(dtPedidos.Rows[i]["id_pedido"].ToString()); iIdDocumentoCobrar = Convert.ToInt32(dtPedidos.Rows[i]["id_documento_cobrar"].ToString()); dbTotalPorCuenta = Convert.ToDecimal(dtPedidos.Rows[i]["valor"].ToString()); //INSERTAR EN LA TABLA CV403_DOCUMENTOS_PAGADOS //----------------------------------------------------------------------------------------------------- sSql = ""; sSql += "insert into cv403_documentos_pagados (" + Environment.NewLine; sSql += "id_documento_cobrar, id_pago, valor," + Environment.NewLine; sSql += "estado, numero_replica_trigger,numero_control_replica," + Environment.NewLine; sSql += "fecha_ingreso, usuario_ingreso, terminal_ingreso)" + Environment.NewLine; sSql += "values (" + Environment.NewLine; sSql += iIdDocumentoCobrar + ", " + iIdPago + ", " + dbTotalPorCuenta + ", 'A', 1, 0, " + Environment.NewLine; sSql += "GETDATE(), '" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "')"; if (!conexion.GFun_Lo_Ejecuta_SQL(sSql)) { catchMensaje.lblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); return(false); } //INSERTAR EN LA TABLA CV403_FACTURAS_PEDIDOS //----------------------------------------------------------------------------------------------------- sSql = ""; sSql += "insert into cv403_facturas_pedidos (" + Environment.NewLine; sSql += "id_factura, id_pedido, fecha_ingreso, usuario_ingreso, terminal_ingreso," + Environment.NewLine; sSql += "estado, numero_replica_trigger, numero_control_replica) " + Environment.NewLine; sSql += "values (" + Environment.NewLine; sSql += iIdFactura + ", " + iIdPedido + ", GETDATE()," + Environment.NewLine; sSql += "'" + Program.sDatosMaximo[0] + "', '" + Program.sDatosMaximo[1] + "', 'A', 0, 0)"; if (!conexion.GFun_Lo_Ejecuta_SQL(sSql)) { catchMensaje.lblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); return(false); } //ACTUALIZAR EN LA TABLA CV403_DCTOS_POR_COBRAR //----------------------------------------------------------------------------------------------------- sSql = ""; sSql += "update cv403_dctos_por_cobrar set" + Environment.NewLine; sSql += "id_factura = " + iIdFactura + "," + Environment.NewLine; sSql += "cg_estado_dcto = 7461," + Environment.NewLine; sSql += "numero_documento = " + sNumeroFactura + Environment.NewLine; sSql += "where id_documento_cobrar = " + iIdDocumentoCobrar; if (!conexion.GFun_Lo_Ejecuta_SQL(sSql)) { catchMensaje.lblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); return(false); } //ACTUALIZAR EN LA TABLA CV403_CAB_PEDIDOS //----------------------------------------------------------------------------------------------------- sSql = ""; sSql += "update cv403_cab_pedidos set" + Environment.NewLine; sSql += "estado_orden = 'Pagada'," + Environment.NewLine; sSql += "fecha_cierre_orden = GETDATE()" + Environment.NewLine; sSql += "where id_pedido = " + iIdPedido; if (!conexion.GFun_Lo_Ejecuta_SQL(sSql)) { catchMensaje.lblMensaje.Text = "ERROR EN LA SIGUIENTE INSTRUCCIÓN:" + Environment.NewLine + sSql; catchMensaje.ShowDialog(); return(false); } } return(true); } catch (Exception ex) { catchMensaje.lblMensaje.Text = ex.Message; catchMensaje.ShowDialog(); return(false); } }
private void frmVerReporteRevisar_Load(object sender, EventArgs e) { try { dbTotal = 0; sSql = ""; sSql += "select CP.estado_orden, CP.id_pos_origen_orden, CP.porcentaje_dscto," + Environment.NewLine; sSql += "CP.id_pos_modo_delivery, CP.id_persona, CP.fecha_orden," + Environment.NewLine; sSql += "CP.fecha_cierre_orden, CP.id_pos_jornada, OO.descripcion," + Environment.NewLine; sSql += conexion.GFun_St_esnulo() + "(CP.numero_personas, 0) numero_personas," + Environment.NewLine; sSql += conexion.GFun_St_esnulo() + "(CP.id_pos_mesa, 0) id_pos_mesa, CP.id_pos_cajero," + Environment.NewLine; sSql += "CP.id_pos_mesero, MS.descripcion, " + conexion.GFun_St_esnulo() + "(PM.descripcion, '') descripcion_mesa" + Environment.NewLine; sSql += "from cv403_cab_pedidos CP INNER JOIN" + Environment.NewLine; sSql += "pos_origen_orden OO ON CP.id_pos_origen_orden = OO.id_pos_origen_orden" + Environment.NewLine; sSql += "and CP.estado in ('A', 'N')" + Environment.NewLine; sSql += "and OO.estado = 'A' LEFT OUTER JOIN" + Environment.NewLine; sSql += "pos_mesa PM ON PM.id_pos_mesa = CP.id_pos_mesa" + Environment.NewLine; sSql += "and PM.estado = 'A' INNER JOIN" + Environment.NewLine; sSql += "pos_mesero MS ON MS.id_pos_mesero = CP.id_pos_mesero" + Environment.NewLine; sSql += "and MS.estado = 'A'" + Environment.NewLine; sSql += "where CP.id_pedido = " + Convert.ToInt32(sIdOrden); dtEstado = new DataTable(); dtEstado.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtEstado, sSql); if (bRespuesta == true) { if (dtEstado.Rows.Count > 0) { sEstado = dtEstado.Rows[0][0].ToString(); sFechaOrden = (Convert.ToDateTime(dtEstado.Rows[0][5].ToString())).ToString("yyyy/MM/dd"); Program.dbValorPorcentaje = Convert.ToDouble(dtEstado.Rows[0][2].ToString()); iIdOrigenOrden = Convert.ToInt32(dtEstado.Rows[0][1].ToString()); iIdPersona = Convert.ToInt32(dtEstado.Rows[0][4].ToString()); sDescripcionOrigen = dtEstado.Rows[0][8].ToString(); iNumeroPersonas = Convert.ToInt32(dtEstado.Rows[0][9].ToString()); iIdMesa = Convert.ToInt32(dtEstado.Rows[0][10].ToString()); iIdCajero = Convert.ToInt32(dtEstado.Rows[0][11].ToString()); iIdMesero = Convert.ToInt32(dtEstado.Rows[0][12].ToString()); sNombreMesero = dtEstado.Rows[0][13].ToString(); Program.sNombreMesa = dtEstado.Rows[0][14].ToString(); if ((dtEstado.Rows[0][6].ToString() == null) || (dtEstado.Rows[0][6].ToString() == "")) { } else { sFechaCierreOrden = (Convert.ToDateTime(dtEstado.Rows[0][6].ToString())).ToString("yyyy/MM/dd HH:mm:ss"); } iJornadaOrdenRegistrada = Convert.ToInt32(dtEstado.Rows[0][7].ToString()); if ((dtEstado.Rows[0][3].ToString() == null) || (dtEstado.Rows[0][3].ToString()) == "") { Program.iDomicilioEspeciales = 0; } else { Program.iDomicilioEspeciales = 1; } if ((dtEstado.Rows[0][0].ToString() == "Pagada") || (dtEstado.Rows[0][0].ToString() == "Cerrada")) { btnEditar.Visible = false; btnReabrir.Visible = true; rbdVerFactura.Enabled = true; verPrecuentaTextBox(); } else if (dtEstado.Rows[0][0].ToString() == "Cancelada") { btnEditar.Visible = false; btnReabrir.Visible = true; rbdVerFactura.Enabled = false; //abrirPrecuentaCancelada(); verPrecuentaTextBox(); } else { btnEditar.Visible = true; btnReabrir.Visible = false; rbdVerFactura.Enabled = false; //abrirPrecuentaAbierta(); verPrecuentaTextBox(); } sSql = ""; sSql = sSql + "select descripcion, genera_factura, id_persona," + Environment.NewLine; sSql = sSql + "id_pos_modo_delivery, presenta_opcion_delivery, codigo " + Environment.NewLine; sSql = sSql + "from pos_origen_orden" + Environment.NewLine; sSql = sSql + "where id_pos_origen_orden = " + iIdOrigenOrden + Environment.NewLine; sSql = sSql + "and estado = 'A'"; dtEstado = new DataTable(); dtEstado.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtEstado, sSql); if (bRespuesta == true) { Program.sDescripcionOrigenOrden = dtEstado.Rows[0][0].ToString(); Program.iGeneraFactura = Convert.ToInt32(dtEstado.Rows[0][1].ToString()); if ((dtEstado.Rows[0][2].ToString() == null) || (dtEstado.Rows[0][2].ToString() == "")) { Program.iIdPersonaOrigenOrden = 0; } else { Program.iIdPersonaOrigenOrden = Convert.ToInt32(dtEstado.Rows[0][2].ToString()); } if ((Program.iGeneraFactura == 1) && (sEstado == "Pagada")) { rbdVerFactura.Enabled = true; } else { rbdVerFactura.Enabled = false; } Program.iIdPosModoDelivery = Convert.ToInt32(dtEstado.Rows[0][3].ToString()); Program.iPresentaOpcionDelivery = Convert.ToInt32(dtEstado.Rows[0][4].ToString()); Program.sCodigoAsignadoOrigenOrden = dtEstado.Rows[0][5].ToString(); } else { catchMensaje.LblMensaje.Text = sSecuencial; catchMensaje.Show(); } } } else { catchMensaje.LblMensaje.Text = sSql; catchMensaje.Show(); } } catch (Exception ex) { catchMensaje.LblMensaje.Text = ex.ToString(); catchMensaje.ShowDialog(); } }
//FUNCION PARA CONSULTAR DATOS DEL CLIENTE private void consultarRegistro() { try { sSql = ""; sSql += "SELECT TP.id_persona, TP.identificacion, TP.nombres, TP.apellidos, TP.correo_electronico," + Environment.NewLine; sSql += "TD.direccion + ', ' + TD.calle_principal + ' ' + TD.numero_vivienda + ' ' + TD.calle_interseccion," + Environment.NewLine; sSql += conexion.GFun_St_esnulo() + "(TT.domicilio, TT.oficina) telefono_domicilio, TT.celular, TD.direccion" + Environment.NewLine; sSql += "FROM tp_personas TP" + Environment.NewLine; sSql += "LEFT OUTER JOIN tp_direcciones TD ON TP.id_persona = TD.id_persona" + Environment.NewLine; sSql += "and TP.estado = 'A'" + Environment.NewLine; sSql += "and TD.estado = 'A'" + Environment.NewLine; sSql += "LEFT OUTER JOIN tp_telefonos TT ON TP.id_persona = TT.id_persona" + Environment.NewLine; sSql += "and TT.estado = 'A'" + Environment.NewLine; sSql += "WHERE TP.identificacion = '" + txtIdentificacion.Text.Trim() + "'"; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (bRespuesta) { if (dtConsulta.Rows.Count > 0) { iIdPersona = Convert.ToInt32(dtConsulta.Rows[0][0].ToString()); txtApellidos.Text = (dtConsulta.Rows[0][2].ToString() + " " + dtConsulta.Rows[0][3].ToString()).Trim().ToUpper(); txtMail.Text = dtConsulta.Rows[0][4].ToString(); txtDireccion.Text = dtConsulta.Rows[0][5].ToString(); sCiudad = dtConsulta.Rows[0][8].ToString(); if (dtConsulta.Rows[0][6].ToString() != "") { txtTelefono.Text = dtConsulta.Rows[0][6].ToString(); } else if (dtConsulta.Rows[0][7].ToString() != "") { txtTelefono.Text = dtConsulta.Rows[0][7].ToString(); } else { txtTelefono.Text = ""; } btnRegistrar.Focus(); } else { Facturador.frmNuevoCliente frmNuevoCliente = new Facturador.frmNuevoCliente(txtIdentificacion.Text.Trim(), chkPasaporte.Checked); frmNuevoCliente.ShowDialog(); if (frmNuevoCliente.DialogResult == DialogResult.OK) { iIdPersona = frmNuevoCliente.iCodigo; txtIdentificacion.Text = frmNuevoCliente.sIdentificacion; txtApellidos.Text = (frmNuevoCliente.sNombre + " " + frmNuevoCliente.sApellido).Trim().ToUpper(); txtTelefono.Text = frmNuevoCliente.sTelefono; txtDireccion.Text = frmNuevoCliente.sDireccion; txtMail.Text = frmNuevoCliente.sMail; sCiudad = frmNuevoCliente.sCiudad; frmNuevoCliente.Close(); btnRegistrar.Focus(); } } btnEditar.Visible = true; return; } } catch (Exception ex) { ok = new VentanasMensajes.frmMensajeOK(); ok.LblMensaje.Text = "Ocurrió un problema al realizar la consulta."; ok.ShowDialog(); txtIdentificacion.Clear(); txtIdentificacion.Focus(); } }
public string extraerOtrosValores(string sCodigo) { try { sTextoDesglose = ""; dTotalPagadoP = 0; sSql = ""; sSql += "select " + conexion.GFun_St_esnulo() + "(sum(DP.cantidad * (DP.precio_unitario + DP.valor_iva - DP.valor_dscto)), 0) total" + Environment.NewLine; sSql += "from cv403_cab_pedidos CP, cv403_det_pedidos DP," + Environment.NewLine; sSql += "pos_origen_orden OO" + Environment.NewLine; sSql += "where OO.id_pos_origen_orden = CP.id_pos_origen_orden" + Environment.NewLine; sSql += "and DP.id_pedido = CP.id_pedido" + Environment.NewLine; sSql += "and OO.codigo = '" + sCodigo + "'" + Environment.NewLine; sSql += "and CP.estado = 'A'" + Environment.NewLine; sSql += "and DP.estado = 'A'" + Environment.NewLine; sSql += "and OO.estado = 'A'" + Environment.NewLine; sSql += "and CP.fecha_pedido = '" + sFecha + "'" + Environment.NewLine; sSql += "and CP.id_pos_jornada = " + Program.iJornadaRecuperada; dtConsulta = new DataTable(); dtConsulta.Clear(); bRespuesta = conexion.GFun_Lo_Busca_Registro(dtConsulta, sSql); if (bRespuesta == true) { if (dtConsulta.Rows.Count > 0) { dTotalPagadoP = Convert.ToDouble(dtConsulta.Rows[0][0].ToString()); dbTotalOrdenes = dbTotalOrdenes + dTotalPagadoP; if (dTotalPagadoP != 0) { sTextoDesglose = dTotalPagadoP.ToString("N2"); } } else { return(""); } } else { return(""); } return(sTextoDesglose); } catch (Exception ex) { catchMensaje.LblMensaje.Text = ex.ToString(); catchMensaje.ShowInTaskbar = false; catchMensaje.ShowDialog(); return(""); } }