protected void grvDetallesAfiliado_RowCommand(object sender, GridViewCommandEventArgs e) { GridViewRow grv = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer); if (e.CommandName == "BtnPlan") { ImageButton imgBtn = (ImageButton)e.CommandSource; GridView myGrid = (GridView)sender; GridViewRow myRow = (GridViewRow)imgBtn.Parent.Parent; int CodAsociacion = Convert.ToInt32(myGrid.DataKeys[myRow.RowIndex].Values["CodAsociacion"]); String identificador = grv.Cells[4].Text.Trim() + ".pdf"; //byte[] Archivo = (byte[])ViewState["PlanPDF"]; AsociacionDAO db = new AsociacionDAO(); byte[] data = (byte[])db.ObtenerPlanAsociacion(CodAsociacion); if (data != null) { try { Response.Clear(); MemoryStream ms = new MemoryStream(data); Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=" + identificador); Response.Buffer = true; ms.WriteTo(Response.OutputStream); HttpContext.Current.ApplicationInstance.CompleteRequest(); //string sFile = identificador; //FileStream fs = new FileStream(Server.MapPath("~/rptTemp\\") + sFile, FileMode.Create); //fs.Write(Archivo, 0, Convert.ToInt32(Archivo.Length)); //fs.Close(); //Response.AddHeader("content-disposition", "attachment;filename=" + sFile); //Response.ContentType = "application/pdf"; //Response.BinaryWrite(Archivo); //Response.End(); } catch (Exception ex) { Response.Write(ex.Message); } } } }
protected void btnPlan_Click(object sender, ImageClickEventArgs e) { ImageButton img = (ImageButton)sender; GridViewRow gvr = (GridViewRow)img.NamingContainer; string nomArch = gvr.Cells[45].Text; int identificador = Convert.ToInt32(gvr.Cells[31].Text); AsociacionDAO db = new AsociacionDAO(); byte[] data = (byte[])db.ObtenerPlanAsociacion(identificador); if (data != null) { try { //string sFile = grvAsociaciones.Rows[gvr.RowIndex].Cells[45].Text ; //FileStream fs = new FileStream(Server.MapPath("~//Files//") + sFile, FileMode.Create); //fs.Write(data, 0, Convert.ToInt32(data.Length)); //fs.Close(); //Response.AddHeader("content-disposition", "attachment;filename=" + sFile); //Response.ContentType = "application/pdf"; //Response.BinaryWrite(data); //Response.End(); Response.Clear(); MemoryStream ms = new MemoryStream(data); Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=" + nomArch); Response.Buffer = true; ms.WriteTo(Response.OutputStream); HttpContext.Current.ApplicationInstance.CompleteRequest(); } catch (Exception ex) { //Response.Write(ex.Message); } } }
protected void grvAsociaciones_RowCommand(object sender, GridViewCommandEventArgs e) { try { int fila = Convert.ToInt32(e.CommandArgument); string TipoCargaCodigos = ""; //string jss = ""; if (e.CommandName == "EditaAsociacion") { ddlTipoInstEduca.SelectedValue = grvAsociaciones.Rows[fila].Cells[48].Text; ddlTipoInstEduca.Attributes.Add("disabled", "disabled"); // La institución educativa no podra modificar debido al id ...!! txtSearch.Enabled = false; //ddlinstitucionIE.SelectedValue = grvAsociaciones.Rows[fila].Cells[14].Text; hdnID.Value = grvAsociaciones.Rows[fila].Cells[31].Text; hdnIDCliente1.Value = grvAsociaciones.Rows[fila].Cells[14].Text; txtSearch.Text = HttpUtility.HtmlDecode(grvAsociaciones.Rows[fila].Cells[1].Text); ddlCiaSeguros.SelectedValue = grvAsociaciones.Rows[fila].Cells[15].Text; ddlCiaSeguros_SelectedIndexChanged(null, null); ddlEmpresaRecaudadora.SelectedValue = grvAsociaciones.Rows[fila].Cells[16].Text; ddlTipoSeguro.SelectedValue = grvAsociaciones.Rows[fila].Cells[17].Text; if (ddlTipoSeguro.SelectedValue == "1" || ddlTipoSeguro.SelectedValue == "2") { txtFechaVigenciaInicio.Text = Convert.ToDateTime(grvAsociaciones.Rows[fila].Cells[18].Text).ToString("yyyy-MM-dd"); txtFFVigenciaBanco.Text = Convert.ToDateTime(grvAsociaciones.Rows[fila].Cells[19].Text).ToString("yyyy-MM-dd"); txtFIVigenciaPoliza.Text = Convert.ToDateTime(grvAsociaciones.Rows[fila].Cells[20].Text).ToString("yyyy-MM-dd"); txtFFVigenciaPoliza.Text = Convert.ToDateTime(grvAsociaciones.Rows[fila].Cells[21].Text).ToString("yyyy-MM-dd"); } int monedaId = Convert.ToInt32(grvAsociaciones.Rows[fila].Cells[22].Text); if (monedaId == 1) { rbtMoneda.SelectedIndex = 0; } else { rbtMoneda.SelectedIndex = 1; } txtPrima.Text = grvAsociaciones.Rows[fila].Cells[23].Text; txtInvalidezPT.Text = grvAsociaciones.Rows[fila].Cells[24].Text; txtInvalidezParcial.Text = grvAsociaciones.Rows[fila].Cells[25].Text; txtGastosCuracion.Text = grvAsociaciones.Rows[fila].Cells[26].Text; txtMuerteAccidental.Text = grvAsociaciones.Rows[fila].Cells[27].Text; txtGastosSepelio.Text = grvAsociaciones.Rows[fila].Cells[28].Text; txtMuerteAccidental.Text = grvAsociaciones.Rows[fila].Cells[29].Text; lblFilex.Text = HttpUtility.HtmlDecode(grvAsociaciones.Rows[fila].Cells[36].Text); txtPensionMensual.Text = grvAsociaciones.Rows[fila].Cells[41].Text; txtMesesPension.Text = grvAsociaciones.Rows[fila].Cells[42].Text; txtAñosPension.Text = grvAsociaciones.Rows[fila].Cells[43].Text; txtdeducible.Text = grvAsociaciones.Rows[fila].Cells[47].Text; rbtTipoCarga.SelectedIndex = Convert.ToInt32(grvAsociaciones.Rows[fila].Cells[40].Text) - 1; formula1.Text = "=" + txtPensionMensual.Text + " x " + txtPensionMensual.Text; formula2.Text = "=(" + txtPensionMensual.Text + " x " + txtPensionMensual.Text + ")"; rbtTipoAsociacion.SelectedIndex = Convert.ToInt32(grvAsociaciones.Rows[fila].Cells[46].Text) - 1; ddlTipoSeguro_SelectedIndexChanged(null, null); using (AsociacionDAO db = new AsociacionDAO()) { byte[] data = (byte[])db.ObtenerPlanAsociacion(Convert.ToInt32(grvAsociaciones.Rows[fila].Cells[31].Text)); if (data != null) { lblFilex.Text = HttpUtility.HtmlDecode(grvAsociaciones.Rows[fila].Cells[37].Text); } else { lblFilex.Text = "SIN-PLAN-ASIGNADO"; } Label lbl = (Label)grvAsociaciones.Rows[fila].FindControl("lblids"); if (lbl.Text.Trim() != "") { string lblids = lbl.Text.Substring(0, lbl.Text.Length - 1); string[] Abancos = lblids.Split(','); using (BancoDAO dbBanco = new BancoDAO()) { grvBancos.DataSource = dbBanco.ListarBanco(); grvBancos.DataBind(); foreach (string ele in Abancos) { foreach (GridViewRow fila_i in grvBancos.Rows) { if (fila_i.Cells[0].Text == ele) { CheckBox chk = (CheckBox)fila_i.FindControl("chkActivo"); chk.Checked = true; break; } } } } } else { using (BancoDAO dbBanco = new BancoDAO()) { grvBancos.DataSource = dbBanco.ListarBanco(); grvBancos.DataBind(); } hdnID.Value = grvAsociaciones.Rows[fila].Cells[31].Text; //pnlEditaAsociacion.Visible = true; } MVTipoBancos.ActiveViewIndex = 1; } } if (e.CommandName == "AsignarPoliza") { int id = Convert.ToInt32(grvAsociaciones.Rows[fila].Cells[31].Text); hdnID.Value = id.ToString().Trim(); TxtNroPoliza.Text = grvAsociaciones.Rows[fila].Cells[32].Text.Replace(" ", ""); TxtCodigoContratante.Text = grvAsociaciones.Rows[fila].Cells[33].Text.Replace(" ", ""); txtNombreContrante.Text = grvAsociaciones.Rows[fila].Cells[34].Text.Replace(" ", ""); string jssa = "openAsignarPoliza();"; ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", jssa, true); } if (e.CommandName == "AnulaAsociacion") { hdnID.Value = grvAsociaciones.Rows[fila].Cells[31].Text; lblMensaje.Text = "¿Está seguro que desea anular la asociación para: " + grvAsociaciones.Rows[fila].Cells[1].Text + " ?"; string jsss = "openAnularAsociacion();"; ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", jsss, true); } if (e.CommandName == "EliminaAsociacion") { hdnID.Value = grvAsociaciones.Rows[fila].Cells[31].Text; lblMensaje.Text = "¿Está seguro que desea Eliminar la asociación para: " + grvAsociaciones.Rows[fila].Cells[1].Text + " ?"; string jsss = "openAnularAsociacion();"; ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", jsss, true); } if (e.CommandName == "CargarDatos") { string IE = HttpUtility.HtmlDecode(grvAsociaciones.Rows[fila].Cells[1].Text); string TS = grvAsociaciones.Rows[fila].Cells[3].Text; string SE = HttpUtility.HtmlDecode(grvAsociaciones.Rows[fila].Cells[2].Text); string IEID = grvAsociaciones.Rows[fila].Cells[14].Text; string SEID = grvAsociaciones.Rows[fila].Cells[15].Text; string RZST = grvAsociaciones.Rows[fila].Cells[35].Text; string IDproduct = grvAsociaciones.Rows[fila].Cells[17].Text; string IDASO = grvAsociaciones.Rows[fila].Cells[31].Text; string CANT = grvAsociaciones.Rows[fila].Cells[38].Text; string codgen = grvAsociaciones.Rows[fila].Cells[44].Text == " " ? "0" : grvAsociaciones.Rows[fila].Cells[44].Text; TipoCargaCodigos = grvAsociaciones.Rows[fila].Cells[40].Text; Response.Redirect("CargarCodigos.aspx?IE=" + IE + "&TS=" + TS + "&SE=" + SE + "&IEID=" + IEID + "&SEID=" + SEID + "&IDASO=" + IDASO + "&IDproduct=" + IDproduct + "&CANT=" + CANT + "&TipoCargaCodigos=" + TipoCargaCodigos + "&codgen=" + codgen); //Response.Redirect("GenerarCodigos.aspx?IEID=" + IEID + "&SEID=" + SEID+ "&IDASO=" + IDASO + "&IDproduct=" + IDproduct); } if (e.CommandName == "GenerarCodigos") { string IEID = grvAsociaciones.Rows[fila].Cells[14].Text; //hdnIDCliente1.Value = IEID; string SEID = HttpUtility.HtmlDecode(grvAsociaciones.Rows[fila].Cells[17].Text); string IEST = HttpUtility.HtmlDecode(grvAsociaciones.Rows[fila].Cells[1].Text); string TSST = HttpUtility.HtmlDecode(grvAsociaciones.Rows[fila].Cells[3].Text); string SEST = HttpUtility.HtmlDecode(grvAsociaciones.Rows[fila].Cells[2].Text); string RZST = HttpUtility.HtmlDecode(grvAsociaciones.Rows[fila].Cells[35].Text); string IDASO = grvAsociaciones.Rows[fila].Cells[31].Text; string CANT = grvAsociaciones.Rows[fila].Cells[38].Text; //TipoCargaCodigos = grvAsociaciones.Rows[fila].Cells[40].Text; string IDproduct = grvAsociaciones.Rows[fila].Cells[17].Text; Label lblPrima = (Label)(grvAsociaciones.Rows[fila].FindControl("lblPrima")); string Prima = lblPrima.Text; TipoCargaCodigos = grvAsociaciones.Rows[fila].Cells[39].Text; Response.Redirect("GenerarCodigos.aspx?IEID=" + IEID + "&SEID=" + SEID + "&IEST=" + IEST + "&TSST=" + TSST + "&SEST=" + SEST + "&RZST=" + RZST + "&Prima=" + Prima + "&IDASO=" + IDASO + "&IDproduct=" + IDproduct + "&CANT=" + CANT + "&TipoCargaCodigos=" + TipoCargaCodigos); } } catch (Exception Ex) { } }