protected void Avanzar(object sender, EventArgs e) { if (GridView2.Rows.Count > 0) { if ((txtpatente.Value != "") && (txtdni.Value != "") && (StockError.Visible != true)) { Buscadores bus = new Buscadores(); cliente ocliente = bus.oclientedni(txtdni.Value); vehiculo ovehiculo = bus.buscarvehiculo(txtpatente.Value); cliente oclientes = bus.ocliente(ovehiculo); if ((ovehiculo != null) && (ovehiculo.id_cliente != null) && (ocliente != null) && (ovehiculo.id_cliente == ocliente.id) && (LSAC.Count <= 5) && (LSAC.Count >= 1)) { CargarOrden(); PDFESTADOCERO(); btnpasartaller.Visible = true; btnAgregarcliente.Visible = false; btnGuardar.Visible = false; btnServicios.Visible = false; btnfinalizar.Visible = false; GridView2.Columns[4].Visible = false; } else { Server.Transfer("AltaDetalle.aspx"); } } else { Server.Transfer("AltaDetalle.aspx"); } } }
protected void CargaryAvanzar(object sender, EventArgs e) { Buscadores bus = new Buscadores(); cliente ocliente = bus.oclientedni(txtdni.Value); vehiculo ovehiculo = bus.buscarvehiculo(txtpatente.Value); if (ovehiculo == null) { GuardarVehiculo(); } ovehiculo = bus.buscarvehiculo(txtpatente.Value); cliente oclientes = bus.ocliente(ovehiculo); if ((ovehiculo.id_cliente == null) || (ocliente == null) || (ocliente.dni != oclientes.dni)) { GuardarCambiodecliente(); } EstadoOriginal(); btnAgregarcliente.Visible = false; DropTipoServicio.Enabled = true; DropServicio.Enabled = true; txtprecioporcantidad.Visible = true; txtcantidad.Enabled = true; btnServicios.Visible = true; txtcantidad.Visible = true; lblpreciototal.Visible = true; btnfinalizar.Visible = true; Calculaelprimero(); }
private void GuardarCambiodecliente() { Buscadores bus = new Buscadores(); vehiculo ovehiculo = bus.buscarvehiculo(txtpatente.Value); cliente ocliente = bus.ocliente(ovehiculo); cliente oclientes = bus.oclientedni(txtdni.Value); btnGuardar.Visible = false; if ((ocliente != null) && (oclientes != null)) { ocliente = bus.oclientedni(txtdni.Value); using (aplicadaBDEntities2 DBF = new aplicadaBDEntities2()) { vehiculo oVehiculo = (from q in DBF.vehiculo where q.id_vehiculo == ovehiculo.id_vehiculo select q).First(); oVehiculo.id_cliente = ocliente.id; DBF.SaveChanges(); } } else { using (aplicadaBDEntities2 DBF = new aplicadaBDEntities2()) { cliente ncliente = new cliente { dni = txtdni.Value, nombre = txtapellido.Value + " " + txtnombre.Value, telefono = txttelefono.Value, email = txtemail.Value, }; DBF.cliente.Add(ncliente); DBF.SaveChanges(); } ocliente = bus.oclientedni(txtdni.Value); using (aplicadaBDEntities2 DBF = new aplicadaBDEntities2()) { vehiculo oVehiculo = (from q in DBF.vehiculo where q.id_vehiculo == ovehiculo.id_vehiculo select q).First(); oVehiculo.id_cliente = ocliente.id; DBF.SaveChanges(); } } }
protected void BuscarCliente(object sender, EventArgs e) { Buscadores bus = new Buscadores(); cliente ocliente = bus.oclientedni(txtdni.Value); vehiculo ovehiculo = bus.buscarvehiculo(txtpatente.Value); cliente oclientes = new cliente(); if (ovehiculo != null) { oclientes = bus.ocliente(ovehiculo); } else { oclientes.id = 0; } if ((ocliente == null) || (ocliente.dni != oclientes.dni)) { using (aplicadaBDEntities2 DBF = new aplicadaBDEntities2()) { if (ocliente != null) { string[] separadas; separadas = ocliente.nombre.Split(' '); txtdni.Value = ocliente.dni; txtapellido.Value = separadas[0]; txtnombre.Value = separadas[1]; txttelefono.Value = ocliente.telefono; txtemail.Value = ocliente.email; txtapellido.Disabled = true; txtnombre.Disabled = true; txttelefono.Disabled = true; txtemail.Disabled = true; btnGuardar.Visible = true; } else { txtapellido.Disabled = false; txtnombre.Disabled = false; txttelefono.Disabled = false; txtemail.Disabled = false; txtapellido.Value = ""; txtnombre.Value = ""; txttelefono.Value = ""; txtemail.Value = ""; txtpatente.Disabled = true; btnGuardar.Visible = true; } } } }
protected void Avanzar(object sender, EventArgs e) { if ((txtpatente.Value != "") && (txtdni.Value != "") && (StockError.Visible == false)) { Buscadores bus = new Buscadores(); cliente ocliente = bus.oclientedni(txtdni.Value); vehiculo ovehiculo = bus.buscarvehiculo(txtpatente.Value); cliente oclientes = bus.ocliente(ovehiculo); if ((ovehiculo != null) && (ovehiculo.id_cliente != null) && (ocliente != null) && (ovehiculo.id_cliente == ocliente.id)) { Server.Transfer("DetalleTaller.aspx"); } else { } } }
protected void PDFPP(object sender, EventArgs e) { if ((txtdni.Value != "") && (txtfechafin.Value != "") && (txtfechainicio.Value != "")) { Buscadores bus = new Buscadores(); DateTime oDateinicio = Convert.ToDateTime(txtfechainicio.Value); DateTime oDatefin = Convert.ToDateTime(txtfechafin.Value); cliente ocliente = bus.oclientedni(txtdni.Value); if (ocliente.dni != null) { List <vehiculo> Lvehiculo = bus.buscarclientevehiculo(ocliente.id); Lvehiculo.Count(); if (Lvehiculo.Count != 0) { var doc = new iTextSharp.text.Document(PageSize.A4); string path = Server.MapPath("~"); PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(path + "/Taller.pdf", FileMode.Create)); doc.Open(); //Cabecera BaseFont bfntHead = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); iTextSharp.text.Font fntHead = new iTextSharp.text.Font(bfntHead, 16, 1, iTextSharp.text.BaseColor.GREEN.Darker()); Paragraph prgHeading = new Paragraph(); prgHeading.Alignment = 1; prgHeading.Add(new Chunk("Taller de Reparaciones".ToUpper(), fntHead)); doc.Add(prgHeading); doc.Add(Chunk.NEWLINE); //Generado By Paragraph prgGeneratedBY = new Paragraph(); BaseFont btnAuthor = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); iTextSharp.text.Font fntAuthor = new iTextSharp.text.Font(btnAuthor, 12, 2, iTextSharp.text.BaseColor.BLACK); prgGeneratedBY.Alignment = Element.ALIGN_RIGHT; prgGeneratedBY.Add(new Chunk("Generado por: " + LogEmpleado.nombreyapellido, fntAuthor)); //Agregar LOG Empleado prgGeneratedBY.Add(new Chunk("\nFecha : " + DateTime.Now.ToShortDateString(), fntAuthor)); doc.Add(prgGeneratedBY); Paragraph p = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, iTextSharp.text.BaseColor.BLACK, Element.ALIGN_LEFT, 1))); doc.Add(p); //Espacio doc.Add(new Chunk("\n", fntHead)); //Datos Paragraph Datos = new Paragraph(); BaseFont bfntDatos = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); iTextSharp.text.Font fntDatos = new iTextSharp.text.Font(bfntDatos, 12, 0, iTextSharp.text.BaseColor.BLACK); Datos.Alignment = Element.ALIGN_CENTER; Datos.Add(new Chunk("\nApellido y Nombre: " + ocliente.nombre + " DNI:" + ocliente.dni + " Telefono: " + ocliente.telefono + " \nEmail: " + ocliente.email, fntDatos)); doc.Add(Datos); //Espacio doc.Add(new Chunk("\n", fntHead)); int controlprecio; foreach (vehiculo o in Lvehiculo) { controlprecio = 0; o.modelo = bus.buscarmodelo(o); o.modelo.marca = bus.buscarmarca(o.modelo); //Creo una tabla DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[3] { new DataColumn("N°Orden"), new DataColumn("Fecha"), new DataColumn("PrecioTotal") }); //nombre de las columnas List <orden> Lorden = bus.buscarListaordenporvehiculo(o.id_vehiculo); foreach (orden OrdenActual in Lorden) { int preciototal = 0; ordenestado oestado = bus.buscarvestadoorden(OrdenActual.id_orden); if ((oestado.fecha_entregado >= oDateinicio) && (oestado.fecha_entregado <= oDatefin)) { List <ordenservicio> Lidservidcios = new List <ordenservicio>(); Lidservidcios = bus.buscarlistaid(OrdenActual.id_orden); List <servicio> Lservicio = bus.ObtenerServicios(Lidservidcios); foreach (ordenservicio ordenservi in Lidservidcios) { servicio oservicio = Lservicio.Find(x => x.id_servicios == ordenservi.id_servicio); int cantidad = ordenservi.cantidad ?? default(int); string total = (double.Parse(oservicio.precio) * Convert.ToDouble(cantidad)).ToString(); preciototal = preciototal + int.Parse(total); } string fecha = oestado.fecha_entregado.ToString(); string[] fechasinhora; fechasinhora = fecha.Split(' '); dt.Rows.Add(OrdenActual.id_orden, fechasinhora[0], preciototal); controlprecio = preciototal; } } //aqui if (dt.Rows.Count != 0) { doc.Add(p); Paragraph Dato = new Paragraph(); Dato.Alignment = Element.ALIGN_LEFT; Dato.Add(new Chunk("\npatente: " + o.patente + " Modelo: " + o.modelo.nombre + " Marca: " + o.modelo.marca.nombre, fntDatos)); doc.Add(Dato); //Espacio doc.Add(new Chunk("\n", fntHead)); //Tabla PdfPTable table = new PdfPTable(dt.Columns.Count); for (int i = 0; i < dt.Columns.Count; i++) { string cellText = Server.HtmlDecode(dt.Columns[i].ColumnName); PdfPCell cell = new PdfPCell(); cell.Phrase = new Phrase(cellText, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 10, 1, new BaseColor(System.Drawing.ColorTranslator.FromHtml("#000000")))); cell.BackgroundColor = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#C8C8C8")); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.PaddingBottom = 5; table.AddCell(cell); } for (int i = 0; i < dt.Rows.Count; i++) { for (int j = 0; j < dt.Columns.Count; j++) { table.AddCell(dt.Rows[i][j].ToString()); } } table.HorizontalAlignment = Element.ALIGN_CENTER; doc.Add(table); //Espacio doc.Add(new Chunk("\n", fntHead)); } } doc.Close(); Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", "window.open('Taller.pdf','_newtab');", true); } } } }