// validaciones dinamicas para Servicios y Tramos registro de id Reserva y Detalle Reserva protected void Button5_Click(object sender, EventArgs e) { try { string fecha = String.Format("{0:dd'/'MM'/'yyyy}", Calendar1.SelectedDate); ServiceReference1.Service1Client servicio = new ServiceReference1.Service1Client(); string rutResidente = txt_rutReserva.Text; string rutFuncionario = System.Web.HttpContext.Current.User.Identity.Name; int capacidad1 = servicio.M_Capacidad_Servicio_porID(1); int capacidad2 = servicio.M_Capacidad_Servicio_porID(2); int capacidad3 = servicio.M_Capacidad_Servicio_porID(3); int capacidad4 = servicio.M_Capacidad_Servicio_porID(4); int valor_S1_T1 = Convert.ToInt32(txt_Quincho_T1.Text); int valor_S1_T2 = Convert.ToInt32(txt_Quincho_T2.Text); int valor_S1_T3 = Convert.ToInt32(txt_Quincho_T3.Text); int valor_S2_T1 = Convert.ToInt32(txt_Multicancha_T1.Text); int valor_S2_T2 = Convert.ToInt32(txt_Multicancha_T2.Text); int valor_S2_T3 = Convert.ToInt32(txt_Multicancha_T3.Text); int valor_S3_T1 = Convert.ToInt32(txt_SalonEventos_T1.Text); int valor_S3_T2 = Convert.ToInt32(txt_SalonEventos_T2.Text); int valor_S3_T3 = Convert.ToInt32(txt_SalonEventos_T3.Text); int valor_S4_T1 = Convert.ToInt32(txt_Estacionamientos_T1.Text); int valor_S4_T2 = Convert.ToInt32(txt_Estacionamientos_T2.Text); int valor_S4_T3 = Convert.ToInt32(txt_Estacionamientos_T3.Text); int UsoDeTramo_S1_T1 = Convert.ToInt32(servicio.UsoDeTramoSegunFechayServicio(fecha, 1, 1)); int UsoDeTramo_S1_T2 = Convert.ToInt32(servicio.UsoDeTramoSegunFechayServicio(fecha, 2, 1)); int UsoDeTramo_S1_T3 = Convert.ToInt32(servicio.UsoDeTramoSegunFechayServicio(fecha, 3, 1)); int UsoDeTramo_S2_T1 = Convert.ToInt32(servicio.UsoDeTramoSegunFechayServicio(fecha, 1, 2)); int UsoDeTramo_S2_T2 = Convert.ToInt32(servicio.UsoDeTramoSegunFechayServicio(fecha, 2, 2)); int UsoDeTramo_S2_T3 = Convert.ToInt32(servicio.UsoDeTramoSegunFechayServicio(fecha, 3, 2)); int UsoDeTramo_S3_T1 = Convert.ToInt32(servicio.UsoDeTramoSegunFechayServicio(fecha, 1, 3)); int UsoDeTramo_S3_T2 = Convert.ToInt32(servicio.UsoDeTramoSegunFechayServicio(fecha, 2, 3)); int UsoDeTramo_S3_T3 = Convert.ToInt32(servicio.UsoDeTramoSegunFechayServicio(fecha, 3, 3)); int UsoDeTramo_S4_T1 = Convert.ToInt32(servicio.UsoDeTramoSegunFechayServicio(fecha, 1, 4)); int UsoDeTramo_S4_T2 = Convert.ToInt32(servicio.UsoDeTramoSegunFechayServicio(fecha, 2, 4)); int UsoDeTramo_S4_T3 = Convert.ToInt32(servicio.UsoDeTramoSegunFechayServicio(fecha, 3, 4)); int calculo_S1 = (valor_S1_T1 + valor_S1_T2 + valor_S1_T3); int calculo_S2 = (valor_S2_T1 + valor_S2_T2 + valor_S2_T3); int calculo_S3 = (valor_S3_T1 + valor_S3_T2 + valor_S3_T3); int calculo_S4 = (valor_S4_T1 + valor_S4_T2 + valor_S4_T3); if (valor_S1_T1 <= (capacidad1 - UsoDeTramo_S1_T1) && valor_S1_T2 <= (capacidad1 - UsoDeTramo_S1_T2) && valor_S1_T3 <= (capacidad1 - UsoDeTramo_S1_T3) && valor_S2_T1 <= (capacidad2 - UsoDeTramo_S2_T1) && valor_S2_T2 <= (capacidad2 - UsoDeTramo_S2_T2) && valor_S2_T3 <= (capacidad2 - UsoDeTramo_S2_T3) && valor_S3_T1 <= (capacidad3 - UsoDeTramo_S3_T1) && valor_S3_T2 <= (capacidad3 - UsoDeTramo_S3_T2) && valor_S3_T3 <= (capacidad3 - UsoDeTramo_S3_T3) && valor_S4_T1 <= (capacidad4 - UsoDeTramo_S1_T1) && valor_S4_T2 <= (capacidad4 - UsoDeTramo_S1_T2) && valor_S4_T3 <= (capacidad4 - UsoDeTramo_S1_T3) ) { if (servicio.ValidarRut(rutResidente) == true) { servicio.SP_Crear_Reserva_Residente_Desde_Funcionario(rutResidente, rutFuncionario); if (calculo_S1 > 0) { servicio.SP_Crear_Detalle_Reserva(1, valor_S1_T1, valor_S1_T2, valor_S1_T3, fecha, rutResidente); } if (calculo_S2 > 0) { servicio.SP_Crear_Detalle_Reserva(2, valor_S2_T1, valor_S2_T2, valor_S2_T3, fecha, rutResidente); } if (calculo_S3 > 0) { servicio.SP_Crear_Detalle_Reserva(3, valor_S3_T1, valor_S3_T2, valor_S3_T3, fecha, rutResidente); } if (calculo_S4 > 0) { servicio.SP_Crear_Detalle_Reserva(4, valor_S4_T1, valor_S4_T2, valor_S4_T3, fecha, rutResidente); } if ((calculo_S1) >= 1 || (calculo_S2) >= 1 || (calculo_S3) >= 1 || (calculo_S4) >= 1) { int s1 = (calculo_S1 * servicio.M_Precio_Servicio_porID(1)); int s2 = (calculo_S2 * servicio.M_Precio_Servicio_porID(2)); int s3 = (calculo_S3 * servicio.M_Precio_Servicio_porID(3)); int s4 = (calculo_S4 * servicio.M_Precio_Servicio_porID(4)); int s5 = s1 + s2 + s3 + s4; Session["Id_Pago"] = "1234"; Session["Tipo_Pago"] = "Reserva"; Session["Total_Pago"] = s5.ToString(); Session["Descripion"] = s5.ToString(); Session["RutResidente"] = txt_rutReserva.Text; Server.Transfer("~/ReservarAreasComunes_Pago.aspx?"); // dentro del mismo servidor works ok } } } lbl_RutValidar.Text = "Rut No Existe en los registros del Condominio, No se pueden registrar las reservas "; servicio.Close(); } catch (Exception) { throw; } }
protected void btn_guardar_cupon_pago_Click(object sender, EventArgs e) { ServiceReference1.Service1Client servicio = new ServiceReference1.Service1Client(); string tipoPago = Session["Tipo_Pago"].ToString(); string total_Pago = Session["Total_Pago"].ToString(); string id_Pago = Session["Id_Pago"].ToString(); string descripion = Session["Descripion"].ToString(); string RutResidente = Session["RutResidente"].ToString(); string Nombre = servicio.Nombre_desde_LogUser(RutResidente).ToString(); string select1 = "DETALLE_RESERVA.ID_D_R"; // Los string select2 = "SERVICIO.NOMBRE_SERVICIO"; // est string select3 = "DETALLE_RESERVA.COSTO_RESERVA"; string select1Id = servicio.Met_Ver_Detalle_Reservas(select1, RutResidente); string select2Dc = servicio.Met_Ver_Detalle_Reservas(select2, RutResidente); string select3Mt = servicio.Met_Ver_Detalle_Reservas(select3, RutResidente); string[] select1Ids = select1Id.Split(new string[] { "<br>" }, StringSplitOptions.None); string[] select2Dcs = select2Dc.Split(new string[] { "<br>" }, StringSplitOptions.None); string[] select3Mts = select3Mt.Split(new string[] { "<br>" }, StringSplitOptions.None); Document doc = new Document(PageSize.LETTER); // Creamos el documento con el tamaño de página: carta PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(@"C:\Users\Sergio\Desktop\Cupon " + tipoPago + ".pdf", FileMode.Create)); // Indicamos donde vamos a guardar el documento // Le colocamos el título y el autor // **Nota: Esto no será visible en el documento doc.AddTitle("Cupon de Pago"); doc.AddCreator("Sergio Zapata"); // Abrimos el archivo doc.Open(); // Estilos para los textos var Color_Verde = new BaseColor(33, 138, 94); var Color_Blanco = new BaseColor(255, 255, 255); var Color_VerdeAgua = new BaseColor(235, 241, 241); iTextSharp.text.Font _estilo_Titulo = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 16, iTextSharp.text.Font.BOLD, BaseColor.BLACK); iTextSharp.text.Font _estilo_Titulo_Italic = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 15, iTextSharp.text.Font.ITALIC, Color_Verde); iTextSharp.text.Font _estilo_Sub_Titulo = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 11, iTextSharp.text.Font.NORMAL, BaseColor.BLACK); iTextSharp.text.Font _estilo_Sub_Titulo_der = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 11, iTextSharp.text.Font.NORMAL, BaseColor.DARK_GRAY); iTextSharp.text.Font _standardFont10 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10, iTextSharp.text.Font.NORMAL, BaseColor.DARK_GRAY); iTextSharp.text.Font _standardFont12 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 12, iTextSharp.text.Font.BOLD, BaseColor.BLACK); // Escribimos el encabezamiento en el documento doc.Add(new Paragraph("Cupon de Pago de " + tipoPago, _estilo_Titulo)); doc.Add(new Paragraph("Residente " + Nombre, _estilo_Titulo_Italic)); doc.Add(Chunk.NEWLINE); doc.Add(new Paragraph("RUT Comercial: 17.355.434-2", _estilo_Sub_Titulo)); doc.Add(new Paragraph("GIROS DE ACTIVIDADES EN ASESORAMIENTO COMUNITARIO,", _estilo_Sub_Titulo)); doc.Add(new Paragraph("GESTION COMERCIAL, SERVICIOS SOCIALES Y PROFESIONALES", _estilo_Sub_Titulo)); doc.Add(new Paragraph("Sociedad de Condomios S.A.", _estilo_Sub_Titulo)); doc.Add(new Paragraph("Oficinas Central Alamenda n° 12354", _estilo_Sub_Titulo)); doc.Add(Chunk.NEWLINE); Paragraph p1 = new Paragraph("Detalle de pago emitido", _standardFont10); p1.SpacingAfter = Element.CHUNK; doc.Add(p1); PdfPTable tblPrueba = new PdfPTable(3); // numero de columnas tblPrueba.WidthPercentage = 100; float[] widths = new float[] { 15, 65, 20 }; tblPrueba.SetWidths(widths); // Configurar el título de las columnas de la tabla PdfPCell clLEFT = new PdfPCell(new Phrase("Id", _standardFont12)); clLEFT.BorderColor = Color_Blanco; clLEFT.BorderWidth = 1.5f; PdfPCell clCENTER = new PdfPCell(new Phrase("Descripcion", _standardFont12)); clCENTER.BorderColor = Color_Blanco; clCENTER.BorderWidth = 1.5f; PdfPCell clRIGHT = new PdfPCell(new Phrase("Monto", _standardFont12)); clRIGHT.BorderColor = Color_Blanco; clRIGHT.BorderWidth = 1.5f; //clRIGHT.BorderWidth = 0.5f; clRIGHT.BorderColor = Color_Verde; // Añadimos las celdas a la tabla tblPrueba.AddCell(clLEFT).BackgroundColor = Color_VerdeAgua; tblPrueba.AddCell(clCENTER).BackgroundColor = Color_VerdeAgua; tblPrueba.AddCell(clRIGHT).BackgroundColor = Color_VerdeAgua; // Llenamos la tabla con información // Añadimos las celdas a la tabla for (int i = 0; i < select1Ids.Length; i++) { tblPrueba.AddCell(new PdfPCell(new Phrase(select1Ids[i], _standardFont10))).BorderWidth = 0; tblPrueba.AddCell(new PdfPCell(new Phrase(select2Dcs[i], _standardFont10))).BorderWidth = 0; tblPrueba.AddCell(new PdfPCell(new Phrase(select3Mts[i], _standardFont10))).BorderWidth = 0; } doc.Add(tblPrueba); doc.Add(Chunk.NEWLINE); // salto de linea Paragraph p = new Paragraph("Total a Pagar $" + total_Pago, _standardFont12); p.Alignment = Element.ALIGN_RIGHT; doc.Add(p); doc.Add(Chunk.NEWLINE); // salto de linea doc.Add(Chunk.NEWLINE); // salto de linea doc.Add(new Paragraph("Fecha / Hora de Emision: " + DateTime.Now.ToString())); iTextSharp.text.Image imageQR = iTextSharp.text.Image.GetInstance(Server.MapPath("~/img/qrcode.jpeg")); imageQR.Alignment = iTextSharp.text.Image.ALIGN_LEFT; doc.Add(imageQR); doc.Add(new Paragraph("Codigo de Seguridad:")); doc.Add(new Paragraph("CA-237867828797080754035877420")); doc.Close(); writer.Close(); }