protected void btnAnular_Click(object sender, EventArgs e) { string idlogin = Session["rpta"].ToString().ToUpper(); //actualizar guiacabecera GuiaCabeceraN objEstadoGuia = new GuiaCabeceraN(); GuiaCabeceraEn objGuiaEn = new GuiaCabeceraEn(); objGuiaEn.IdGuia = xidGuia; objGuiaEn.IdLoginAnulado = int.Parse(idlogin); objGuiaEn.FechaAnulacion = DateTime.Parse(txtFecha.Text); objGuiaEn.IdEstado = int.Parse(txtEstado.Text); objGuiaEn.ip = Request.UserHostAddress; string cod = objEstadoGuia.ActualizarEstadoGuia(objGuiaEn); //string mensaje = ("<script language ='JavaScript'>window.confirm('Va a salir de la aplicación ¿Desea salir realmente?'); </script>"); //if (mensaje == "Ok") //{ // this.Page.Response.Write("<script language ='JavaScript'>window.alert('Gracias por visitarnos'); </script>"); //} //var mensaj = (this.Page.Response.Write("<script language ='JavaScript'>window.confirm('Va a salir de la aplicación ¿Desea salir realmente?'); </script>")); this.Page.Response.Write("<script language ='JavaScript'>window.alert('Se Anulo la Guia del Activo'); </script>"); btnRecepcion.Enabled = false; btnReparacion.Enabled = false; btnImprimir.Enabled = false; btnAnular.Enabled = false; }
protected void btnGuardar_Click(object sender, EventArgs e) { if (gvDetalle.Rows.Count == 0) { this.Page.Response.Write("<script language ='JavaScript'>window.alert('No existen activos agregados en la lista de la guía. Verifique por favor.');</script>"); return; } if (String.IsNullOrEmpty(Transportista.Text)) { this.Page.Response.Write("<script language ='JavaScript'>window.alert('Ingrese Transportista.');</script>"); Transportista.Focus(); return; } if (ddlMotivoTrasldo.SelectedIndex == 0) { this.Page.Response.Write("<script language ='JavaScript'>window.alert('Seleccione Motivo de Traslado.');</script>"); ddlMotivoTrasldo.Focus(); return; } if (ddlPuntoPartida.SelectedIndex == 0) { this.Page.Response.Write("<script language ='JavaScript'>window.alert('Seleccione Punto de Partida.');</script>"); ddlPuntoPartida.Focus(); return; } if (ddlPuntoLlegada.SelectedIndex == 0) { this.Page.Response.Write("<script language ='JavaScript'>window.alert('Seleccione Punto de Llegada.');</script>"); ddlPuntoLlegada.Focus(); return; } if (ddlPuntoLlegada.SelectedItem.ToString() == "Otros") { if (txtllegada.Text == "") { this.Page.Response.Write("<script language ='JavaScript'>window.alert('Especifique Punto de Llegada.');</script>"); txtllegada.Focus(); return; } } GuiaCabeceraEn ObjInsertGuia = new GuiaCabeceraEn(); GuiaDetalleActivosEn ObjInsertDet = new GuiaDetalleActivosEn(); ObjInsertGuia.IdLogin = int.Parse(Session["rpta"].ToString().ToUpper()); ObjInsertGuia.SedePartida = ddlPuntoPartida.SelectedValue; ObjInsertGuia.SedeLlegada = ddlPuntoLlegada.SelectedValue; ObjInsertGuia.OrigenDestinoExterno = txtllegada.Text; ObjInsertGuia.Fecha = DateTime.Now; //DateTime.Parse(TxtFecha.Text); ObjInsertGuia.Transportista = Transportista.Text; ObjInsertGuia.IdMotivoTraslado = int.Parse(ddlMotivoTrasldo.SelectedValue); ObjInsertGuia.Activos = 1; ObjInsertGuia.IdEstado = int.Parse(txtEstado.Text); ObjInsertGuia.observ = txtObserv.Text.Trim(); ObjInsertGuia.ip = Request.UserHostAddress; GuiaCabeceraN objGC = new GuiaCabeceraN(); string rpta = ""; rpta = objGC.InsertarGuiaCabecera(ObjInsertGuia); hdnIdGuia.Value = rpta; //Session["rpta"]=rpta; GuiaDetalleActivoN objDetalle = new GuiaDetalleActivoN(); FacturaEn ObjInsertFactura = new FacturaEn();//**// FacturaN ObjFacGuia = new FacturaN(); //adicionar temporal activos ObjInsertDet.IdGuia = int.Parse(rpta); // ObjInsertDet.IdUnidadMedida = int.Parse(ddlUnidadMedida.SelectedValue); int cant = 0; cant = gvDetalle.Rows.Count; for (int i = 0; i < cant; i += 1) { ObjInsertFactura.IdLogistica = int.Parse(gvDetalle.Rows[i].Cells[0].Text);//**// ObjInsertFactura.Ruc = txtRuc.Text.Trim(); ObjInsertFactura.Proveedor = Transportista.Text.Trim(); ObjInsertFactura.Direccion = txtDireccion.Text.Trim(); ObjFacGuia.pr_registrar_factura_guia(ObjInsertFactura);//**// ObjInsertDet.IdLogistica = int.Parse(gvDetalle.Rows[i].Cells[0].Text); //gvEmpleados.DataKeys[e.NewSelectedIndex].Values // int id = Convertir .ToInt32 (GridView1.DataKeys [e.Row.RowIndex] .values [0]); // int id = Convert.ToInt32(gvDetalle.DataKeys[i].Values[0]); ObjInsertDet.IdUnidadMedida = Convert.ToInt32(gvDetalle.DataKeys[i].Values[0]); objDetalle.InsertarGuiaDetalleActivos(ObjInsertDet); } ObjInsertGuia.IdGuia = int.Parse(rpta); objGC.pr_registrar_auditoria_guia(ObjInsertGuia); this.Page.Response.Write("<script language ='JavaScript'>window.alert('Guia registrada correctamente.');</script>"); //vaciar tabla temporal // GuiaTemporalN guia = new GuiaTemporalN(); // gvDetalle.DataSource = guia.EliminarGuiaTemporal(); // limpiar(); //rpta captura el id de la guia //prueba de consulta hdIdGuia.Value = rpta; gvconsulta.DataSource = objDetalle.BuscarGuiaActivos(rpta); //string login = gvconsulta.Rows[0].Cells[2].Text; hdusuario.Value = Session["Usuario"].ToString().ToUpper(); gvconsulta.DataBind(); btnNuevo.Enabled = true; btnGuardar.Enabled = false; btnImprimir.Enabled = true; Bloquear(); }
protected void btnImprimir_Click(object sender, EventArgs e) { string nomfile = "GUIARECEPCION" + DateTime.Now.ToShortDateString() + ".pdf"; Response.Clear(); Response.Buffer = true; Response.Charset = ""; Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=" + nomfile); //Document doc = new Document(PageSize.A4, 0.0F, 0.0F, 20.0F, 0.0F); Document doc = new Document(PageSize.A4.Rotate(), 10, 20, 20, 10); PdfWriter.GetInstance(doc, Response.OutputStream); doc.Open(); BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false); iTextSharp.text.Font Negrita = new iTextSharp.text.Font(bfTimes, 16, iTextSharp.text.Font.BOLD, BaseColor.BLACK); iTextSharp.text.Font Negrita2 = new iTextSharp.text.Font(bfTimes, 12, iTextSharp.text.Font.BOLD, BaseColor.BLACK); iTextSharp.text.Font Negrita10 = new iTextSharp.text.Font(bfTimes, 10, iTextSharp.text.Font.BOLD, BaseColor.BLACK); iTextSharp.text.Font Formato = new iTextSharp.text.Font(bfTimes, 10, iTextSharp.text.Font.NORMAL, BaseColor.BLACK); //iTextSharp.text.Font font = new iTextSharp.text.Font(BaseFont.TIMES_ROMAN, 6, font.BaseFont ); BaseColor colorh = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#A9D0F5")); // Escribimos el encabezamiento en el documento // doc.Add(Chunk.NEWLINE); PdfPTable tblcabecera_1 = new PdfPTable(1); //imagen Paragraph paragraph = new Paragraph("Getting Started ITextSharp."); //////string imageURL = Server.MapPath(".") + "/logo.jpg"; //////iTextSharp.text.Image imagen = iTextSharp.text.Image.GetInstance(imageURL); //////imagen.ScalePercent(50f); //////imagen.Alignment = Element.ALIGN_LEFT; //////doc.Add(imagen); //cabecera PdfPTable tblcabecera = new PdfPTable(3); tblcabecera.WidthPercentage = 100; float[] medidaCabecera = { 10f, 10f, 10f }; tblcabecera.SetWidths(medidaCabecera); //fila1 y 2 string imageURL = Server.MapPath(".") + "/Iconos/logo.jpg"; iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(imageURL); jpg.ScalePercent(35f); PdfPCell imageCell = new PdfPCell(jpg); imageCell.Colspan = 2; // either 1 if you need to insert one cell imageCell.Border = 0; imageCell.Rowspan = 2; // imageCell.Padding=(10f); imageCell.HorizontalAlignment = (Element.ALIGN_CENTER); tblcabecera.AddCell(imageCell); // tblcabecera.AddCell(cllogo); PdfPCell clruc = new PdfPCell(new Phrase("R.U.C. 20504653570", Negrita)); clruc.BorderWidth = 1; clruc.Rowspan = 2; clruc.HorizontalAlignment = Element.ALIGN_CENTER; tblcabecera.AddCell(clruc); //FILA3 PdfPCell clasoc = new PdfPCell(new Phrase("ASOCIACION CULTURAL SUDAMERICANA", Negrita10)); clasoc.BorderWidth = 0; clasoc.Colspan = 2; clasoc.HorizontalAlignment = Element.ALIGN_CENTER; tblcabecera.AddCell(clasoc); PdfPCell clguia = new PdfPCell(new Phrase("GUIA DE REMISION", Negrita)); clguia.BorderWidth = 1; clguia.Rowspan = 2; clguia.HorizontalAlignment = Element.ALIGN_CENTER; tblcabecera.AddCell(clguia); //FILA4 PdfPCell clSede1 = new PdfPCell(new Phrase("Sede San Miguel: Av. La Marina 1429-San Miguel - Lima - Lima / Telefonos: 263-0269 / 500-4600", Formato)); clSede1.BorderWidth = 0; clSede1.Colspan = 2; clSede1.HorizontalAlignment = Element.ALIGN_CENTER; tblcabecera.AddCell(clSede1); //FILA5 PdfPCell clSede2 = new PdfPCell(new Phrase("Sede Comas: Av. Universitaria 1250-Comas - Lima - Lima / Telefonos: 537-6090", Formato)); clSede2.BorderWidth = 0; clSede2.Colspan = 2; clSede2.HorizontalAlignment = Element.ALIGN_CENTER; tblcabecera.AddCell(clSede2); PdfPCell clnum = new PdfPCell(new Phrase("Nª" + " " + xidGuia, Negrita)); clnum.BorderWidth = 1; clnum.Rowspan = 2; clnum.HorizontalAlignment = Element.ALIGN_CENTER; tblcabecera.AddCell(clnum); //FILA6 PdfPCell clSede3 = new PdfPCell(new Phrase("Sede Puente Piedra: Calle La Victoria 509 - Puente Piedra - Lima - Lima / Telefonos: 586-7283", Formato)); clSede3.BorderWidth = 0; clSede3.Colspan = 2; clSede3.HorizontalAlignment = Element.ALIGN_CENTER; tblcabecera.AddCell(clSede3); PdfPCell clespacio = new PdfPCell(new Phrase(" ", Formato)); clespacio.BorderWidth = 0; clespacio.Colspan = 3; clespacio.HorizontalAlignment = Element.ALIGN_CENTER; tblcabecera.AddCell(clespacio); doc.Add(tblcabecera); PdfPTable tblFecha = new PdfPTable(2); tblFecha.WidthPercentage = 100; //dar tamaño a la celda float[] medidaCeldasx = { 10f, 10f }; tblFecha.SetWidths(medidaCeldasx); //capturar valores de Guia Cabecera GuiaCabeceraN objBuscar = new GuiaCabeceraN(); DataTable DTILogistica = objBuscar.BuscarGuiaCabecera(xidGuia); DataRow row = DTILogistica.Rows[0]; string usu = row["Usuario que Envia"].ToString(); string trans = row["Transportista"].ToString(); string traslado = row["Motivo Traslado"].ToString(); string PPARTIDA = row["SedePartida"].ToString(); string PLLEGADA = row["SedeLlegada"].ToString(); string UsuRecepciona = row["Usuario que Recepciona"].ToString(); string FecRecepciona = row["Fecha Recepcion"].ToString(); DateTime fecenvio = DateTime.Parse(row["Fecha de Envio"].ToString()); int estado = int.Parse(row["Activo"].ToString()); ////Feha DateTime fecRecibido = Convert.ToDateTime(DateTime.Now.ToString()); PdfPCell clfecha = new PdfPCell(new Phrase("Fecha Envío:" + " " + fecenvio, Negrita2)); clfecha.BorderWidth = 0; clfecha.HorizontalAlignment = Element.ALIGN_LEFT; tblFecha.AddCell(clfecha); string usuario = Session["Usuario"].ToString().ToUpper(); PdfPCell clUsuario = new PdfPCell(new Phrase("Usuario:" + " " + usu, Negrita2)); clUsuario.BorderWidth = 0; clUsuario.HorizontalAlignment = Element.ALIGN_RIGHT; tblFecha.AddCell(clUsuario); doc.Add(tblFecha); doc.Add(Chunk.NEWLINE); /////// PdfPTable tblTabla1 = new PdfPTable(4); tblTabla1.WidthPercentage = 100; //dar tamaño a la celda float[] medidaCeldas = { 1.7f, 4.2f, 4f, 4.2f }; tblTabla1.SetWidths(medidaCeldas); //FILA1 PdfPCell clespacio2 = new PdfPCell(new Phrase(" ", Negrita2)); clespacio2.BorderWidth = 0; clespacio2.Colspan = 4; clespacio2.HorizontalAlignment = Element.ALIGN_CENTER; PdfPCell clTrasportista = new PdfPCell(new Phrase("Transportista:", Negrita2)); clTrasportista.BorderWidth = 0; clTrasportista.HorizontalAlignment = Element.ALIGN_CENTER; PdfPCell clTrasportista1 = new PdfPCell(new Phrase(trans.ToUpper(), Formato)); clTrasportista1.BorderWidth = 0; clTrasportista1.HorizontalAlignment = Element.ALIGN_CENTER; PdfPCell clMotivo = new PdfPCell(new Phrase("Motivo de Traslado:", Negrita2)); clMotivo.BorderWidth = 0; clMotivo.HorizontalAlignment = Element.ALIGN_CENTER; PdfPCell clMotivo1 = new PdfPCell(new Phrase(traslado.ToString(), Formato)); clMotivo1.BorderWidth = 0; clMotivo1.HorizontalAlignment = Element.ALIGN_CENTER; PdfPCell clPuntoPartida = new PdfPCell(new Phrase("Punto de Partida:", Negrita2)); //clS1.BorderWidth = 1; clPuntoPartida.HorizontalAlignment = Element.ALIGN_CENTER; clPuntoPartida.BorderWidth = 0; PdfPCell clPuntoPartida1 = new PdfPCell(new Phrase(PPARTIDA, Formato)); //clS1.BorderWidth = 1; clPuntoPartida1.HorizontalAlignment = Element.ALIGN_CENTER; clPuntoPartida1.BorderWidth = 0; PdfPCell clPuntoLlegada = new PdfPCell(new Phrase("Punto de Llegada:", Negrita2)); //clS1.BorderWidth = 1; clPuntoLlegada.HorizontalAlignment = Element.ALIGN_CENTER; clPuntoLlegada.BorderWidth = 0; PdfPCell clPuntoLlegada1 = new PdfPCell(new Phrase(PLLEGADA, Formato)); //clS1.BorderWidth = 1; clPuntoLlegada1.HorizontalAlignment = Element.ALIGN_CENTER; clPuntoLlegada1.BorderWidth = 0; PdfPCell clUsuRecepciona = new PdfPCell(new Phrase("Usuario que Recepciona:", Negrita2)); //clS1.BorderWidth = 1; clUsuRecepciona.HorizontalAlignment = Element.ALIGN_CENTER; clUsuRecepciona.BorderWidth = 0; PdfPCell clUsuRecepciona1 = new PdfPCell(new Phrase(UsuRecepciona, Formato)); //clS1.BorderWidth = 1; clUsuRecepciona1.HorizontalAlignment = Element.ALIGN_CENTER; clUsuRecepciona1.BorderWidth = 0; PdfPCell clFecRecepciona = new PdfPCell(new Phrase("Fecha de Recepción:", Negrita2)); //clS1.BorderWidth = 1; clFecRecepciona.HorizontalAlignment = Element.ALIGN_CENTER; clFecRecepciona.BorderWidth = 0; PdfPCell clFecRecepciona1 = new PdfPCell(new Phrase(FecRecepciona, Formato)); //clS1.BorderWidth = 1; clFecRecepciona1.HorizontalAlignment = Element.ALIGN_CENTER; clFecRecepciona1.BorderWidth = 0; PdfPCell clvacio = new PdfPCell(new Phrase(" ", Formato)); //clS1.BorderWidth = 1; clvacio.HorizontalAlignment = Element.ALIGN_CENTER; clvacio.BorderWidth = 0; clvacio.Colspan = 4; //FILA1 tblTabla1.AddCell(clespacio2); tblTabla1.AddCell(clTrasportista); tblTabla1.AddCell(clTrasportista1); tblTabla1.AddCell(clMotivo); tblTabla1.AddCell(clMotivo1); tblTabla1.AddCell(clPuntoPartida); tblTabla1.AddCell(clPuntoPartida1); tblTabla1.AddCell(clPuntoLlegada); tblTabla1.AddCell(clPuntoLlegada1); tblTabla1.AddCell(clUsuRecepciona); tblTabla1.AddCell(clUsuRecepciona1); tblTabla1.AddCell(clFecRecepciona); tblTabla1.AddCell(clFecRecepciona1); tblTabla1.AddCell(clvacio); doc.Add(tblTabla1); doc.Add(Chunk.NEWLINE); if (estado == 1) // si es detalle activo { ///tabla PdfPTable tblTabla = new PdfPTable(6); tblTabla.WidthPercentage = 100; //dar tamaño a la celda float[] medidaCeldas1 = { 2f, 4.2f, 6f, 6f, 2f, 2f }; tblTabla.SetWidths(medidaCeldas1); //////////////////////////////////////////////////////////////////////////////////////// //FILA1 PdfPCell clCodigo = new PdfPCell(new Phrase("Código", Negrita2)); clCodigo.BorderWidth = 1; clCodigo.HorizontalAlignment = Element.ALIGN_CENTER; PdfPCell clDescripcion = new PdfPCell(new Phrase("Descripción", Negrita2)); clDescripcion.BorderWidth = 1; clDescripcion.HorizontalAlignment = Element.ALIGN_CENTER; PdfPCell clOrigen = new PdfPCell(new Phrase("Origen", Negrita2)); clOrigen.BorderWidth = 1; clOrigen.HorizontalAlignment = Element.ALIGN_CENTER; PdfPCell clDetalle = new PdfPCell(new Phrase("Detalle", Negrita2)); clDetalle.BorderWidth = 1; clDetalle.HorizontalAlignment = Element.ALIGN_CENTER; PdfPCell clCondicion = new PdfPCell(new Phrase("Condición", Negrita2)); //clS1.BorderWidth = 1; clCondicion.HorizontalAlignment = Element.ALIGN_CENTER; clCondicion.BorderWidth = 1; PdfPCell clUnidadMedida = new PdfPCell(new Phrase("Unidad Medida", Negrita2)); //clS1.BorderWidth = 1; clUnidadMedida.HorizontalAlignment = Element.ALIGN_CENTER; clUnidadMedida.BorderWidth = 1; //FILA1 tblTabla.AddCell(clCodigo); tblTabla.AddCell(clDescripcion); tblTabla.AddCell(clOrigen); tblTabla.AddCell(clDetalle); tblTabla.AddCell(clCondicion); tblTabla.AddCell(clUnidadMedida); for (int i = 0; i < gvDetalleGuia.Rows.Count; i++) { ////clNro = new PdfPCell(new Phrase(Convert.ToString(i + 1), Formato)); ////clNro.HorizontalAlignment = Element.ALIGN_CENTER; ////clNro.BorderWidth = 1; clCodigo = new PdfPCell(new Phrase(gvDetalleGuia.Rows[i].Cells[1].Text, Formato)); clCodigo.BorderWidth = 1; clCodigo.HorizontalAlignment = Element.ALIGN_CENTER; clDescripcion = new PdfPCell(new Phrase(gvDetalleGuia.Rows[i].Cells[2].Text, Formato)); clDescripcion.BorderWidth = 1; clDescripcion.HorizontalAlignment = Element.ALIGN_CENTER; clOrigen = new PdfPCell(new Phrase(gvDetalleGuia.Rows[i].Cells[3].Text, Formato)); clOrigen.BorderWidth = 1; clOrigen.HorizontalAlignment = Element.ALIGN_CENTER; clDetalle = new PdfPCell(new Phrase(gvDetalleGuia.Rows[i].Cells[4].Text, Formato)); clDetalle.BorderWidth = 1; clDetalle.HorizontalAlignment = Element.ALIGN_CENTER; clCondicion = new PdfPCell(new Phrase(gvDetalleGuia.Rows[i].Cells[5].Text, Formato)); clCondicion.BorderWidth = 1; clCondicion.HorizontalAlignment = Element.ALIGN_CENTER; clUnidadMedida = new PdfPCell(new Phrase(gvDetalleGuia.Rows[i].Cells[6].Text, Formato)); clUnidadMedida.BorderWidth = 1; clUnidadMedida.HorizontalAlignment = Element.ALIGN_CENTER; tblTabla.AddCell(clCodigo); tblTabla.AddCell(clDescripcion); tblTabla.AddCell(clOrigen); tblTabla.AddCell(clDetalle); tblTabla.AddCell(clCondicion); tblTabla.AddCell(clUnidadMedida); } doc.Add(tblTabla); } if (estado == 0) { ///tabla PdfPTable tblTablaBi = new PdfPTable(3); tblTablaBi.WidthPercentage = 100; //dar tamaño a la celda float[] medidaCeldas2 = { 1.7f, 4.2f, 4.2f }; tblTablaBi.SetWidths(medidaCeldas2); //////////////////////////////////////////////////////////////////////////////////////// //FILA1 PdfPCell clCant = new PdfPCell(new Phrase("Cantidad", Negrita2)); clCant.BorderWidth = 1; clCant.HorizontalAlignment = Element.ALIGN_CENTER; PdfPCell clDescrip = new PdfPCell(new Phrase("Descripción", Negrita2)); clDescrip.BorderWidth = 1; clDescrip.HorizontalAlignment = Element.ALIGN_CENTER; PdfPCell clUnidadMe = new PdfPCell(new Phrase("Unidad de Medida:", Negrita2)); //clS1.BorderWidth = 1; clUnidadMe.HorizontalAlignment = Element.ALIGN_CENTER; clUnidadMe.BorderWidth = 1; //FILA1 tblTablaBi.AddCell(clCant); tblTablaBi.AddCell(clDescrip); tblTablaBi.AddCell(clUnidadMe); for (int i = 0; i < gvDetalleGuia.Rows.Count; i++) { ////clNro = new PdfPCell(new Phrase(Convert.ToString(i + 1), Formato)); ////clNro.HorizontalAlignment = Element.ALIGN_CENTER; ////clNro.BorderWidth = 1; clCant = new PdfPCell(new Phrase(gvDetalleGuia.Rows[i].Cells[0].Text.ToString(), Formato)); clCant.BorderWidth = 1; clCant.HorizontalAlignment = Element.ALIGN_CENTER; clDescrip = new PdfPCell(new Phrase(gvDetalleGuia.Rows[i].Cells[1].Text, Formato)); clDescrip.BorderWidth = 1; clDescrip.HorizontalAlignment = Element.ALIGN_CENTER; clUnidadMe = new PdfPCell(new Phrase(gvDetalleGuia.Rows[i].Cells[2].Text, Formato)); clUnidadMe.BorderWidth = 1; clUnidadMe.HorizontalAlignment = Element.ALIGN_CENTER; tblTablaBi.AddCell(clCant); tblTablaBi.AddCell(clDescrip); tblTablaBi.AddCell(clUnidadMe); // doc.Add(tblTablaBi); } doc.Add(tblTablaBi); } /////////////////////////////////////////////////////// doc.Close(); }
protected void btnGuardar_Click(object sender, EventArgs e) { if (gvBienes.Rows.Count == 0) { this.Page.Response.Write("<script language ='JavaScript'>window.alert('No existen registros agregados en la lista de la guía. Verifique por favor.');</script>"); return; } if (String.IsNullOrEmpty(txtTransportista.Text)) { this.Page.Response.Write("<script language ='JavaScript'>window.alert('Ingrese Transportista.');</script>"); txtTransportista.Focus(); return; } if (ddlMotivoTrasldo.SelectedIndex == 0) { this.Page.Response.Write("<script language ='JavaScript'>window.alert('Seleccione Motivo de Traslado.');</script>"); ddlMotivoTrasldo.Focus(); return; } if (ddlPuntoPartida.SelectedIndex == 0) { this.Page.Response.Write("<script language ='JavaScript'>window.alert('Seleccione Punto de Partida.');</script>"); ddlPuntoPartida.Focus(); return; } if (ddlPuntoLlegada.SelectedIndex == 0) { this.Page.Response.Write("<script language ='JavaScript'>window.alert('Seleccione Punto de Llegada.');</script>"); ddlPuntoLlegada.Focus(); return; } if (ddlPuntoLlegada.SelectedItem.ToString() == "Otros") { if (txtllegada.Text == "") { this.Page.Response.Write("<script language ='JavaScript'>window.alert('Especifique Punto de Llegada.');</script>"); txtllegada.Focus(); return; } } GuiaCabeceraEn ObjInsertGuia = new GuiaCabeceraEn(); GuiaDetalleActivosEn ObjInsertDet = new GuiaDetalleActivosEn(); ObjInsertGuia.IdLogin = int.Parse(Session["rpta"].ToString().ToUpper()); ObjInsertGuia.SedePartida = ddlPuntoPartida.SelectedValue; ObjInsertGuia.SedeLlegada = ddlPuntoLlegada.SelectedValue; ObjInsertGuia.OrigenDestinoExterno = txtllegada.Text; ObjInsertGuia.Fecha = DateTime.Now; //DateTime.Parse(TxtFecha.Text); ObjInsertGuia.Transportista = txtTransportista.Text; ObjInsertGuia.IdMotivoTraslado = int.Parse(ddlMotivoTrasldo.SelectedValue); ObjInsertGuia.Activos = 0; ObjInsertGuia.IdEstado = int.Parse(txtEstado.Text); ObjInsertGuia.observ = txtObserv.Text.Trim(); ObjInsertGuia.ip = Request.UserHostAddress; GuiaCabeceraN objGC = new GuiaCabeceraN(); string rpta = ""; rpta = objGC.InsertarGuiaCabecera(ObjInsertGuia); hdnIdGuia.Value = rpta; //Session["rpta"]=rpta; GuiaDetalleActivoN objDetalle = new GuiaDetalleActivoN(); //adicionar detalle bienes GuiaDetalleBienesEn objInsertarBienes = new GuiaDetalleBienesEn(); GuiaDetalleBienesN objBienes = new GuiaDetalleBienesN(); objInsertarBienes.IdGuia = int.Parse(rpta); int tot = 0; tot = gvBienes.Rows.Count; for (int i = 0; i < tot; i += 1) { objInsertarBienes.Cant = int.Parse(gvBienes.Rows[i].Cells[0].Text); objInsertarBienes.Descripcion = gvBienes.Rows[i].Cells[1].Text; // objInsertarBienes.IdUnidadMedida = int.Parse(gvBienes.Rows[i].Cells[2].Text); objInsertarBienes.IdUnidadMedida = Convert.ToInt32(gvBienes.DataKeys[i].Values[0]); objBienes.InsertarGuiaDetalleBienes(objInsertarBienes); } ObjInsertGuia.IdGuia = int.Parse(rpta); objGC.pr_registrar_auditoria_guia(ObjInsertGuia); this.Page.Response.Write("<script language ='JavaScript'>window.alert('Guia registrada correctamente.');</script>"); // limpiar(); hdusuario.Value = Session["Usuario"].ToString().ToUpper(); btnNuevo.Enabled = true; btnGuardar.Enabled = false; btnImprimir.Enabled = true; hdIdGuia.Value = rpta; Bloquear(); }