protected void btnEncabezado_Click(object sender, EventArgs e) { Boolean check = false; Document_Controller docControl = new Document_Controller(); string listFolio = ""; for (int i = 0; i < RadGrid1.Items.Count; i++) { GridDataItem row = RadGrid1.Items[i]; bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked; if (isChecked) { int Foli = Convert.ToInt32(row["FolioFactura"].Text); listFolio = listFolio + Foli + ","; check = true; } } if (check != false) { listFolio = listFolio.Substring(0, listFolio.Length - 1); List <Cabecera> lista = docControl.ExportacionExcel(listFolio, txtFechaInicio.Text, txtFechaTermino.Text); //GridView gv = new GridView(); //gv.DataSource = lista; //gv.DataBind(); //ExportToExcel("LcoCab", gv); btnExportCSV_Click(lista); } else { } }
protected void Button1_Click(object sender, EventArgs e) { try { Controller_Facturacion controlFact = new Controller_Facturacion(); string OC = txtNOrdenCompra.Text.ToString(); string fechaOC = txtFechaOC.Text; string evento = ""; int TipoDoc = Convert.ToInt32(Request.QueryString["TipoDoc"].ToString()); if (TipoDoc >= 4 && TipoDoc <= 9) { if (ddlRazon.SelectedValue.ToString() != "0") { evento = controlFact.SincronizadorFacturas(Convert.ToInt32(Request.QueryString["Fac"].ToString()), Convert.ToInt32(Request.QueryString["TipoDoc"].ToString()), ddlRazon.SelectedValue.ToString(), Session["Usuario"].ToString(), OC, fechaOC); } else { evento = "Debe seleccionar una razón. Intentelo nuevamente"; } } else { evento = controlFact.SincronizadorFacturas(Convert.ToInt32(Request.QueryString["Fac"].ToString()), Convert.ToInt32(Request.QueryString["TipoDoc"].ToString()), ddlRazon.SelectedValue.ToString(), Session["Usuario"].ToString(), OC, fechaOC); } if (evento == "OK") { Document_Controller dcc = new Document_Controller(); if (dcc.UpdateEstado7(Request.QueryString["Fac"].ToString()) == true) { string popupScript = "<script language='JavaScript'> alert(' Actualizacion de Factura Electronicas Realizada Correctamente');opener.location.reload();window.close();</script>"; Page.RegisterStartupScript("PopupScript", popupScript); } else { string popupScript = "<script language='JavaScript'> alert(' Ha ocurrido un error, vuelva a intentarlo');</script>"; Page.RegisterStartupScript("PopupScript", popupScript); } } else { string popupScript = "<script language='JavaScript'> alert('" + evento + "');</script>"; Page.RegisterStartupScript("PopupScript", popupScript); } } catch (Exception exx) { string popupScript = "<script language='JavaScript'> alert('" + exx.Message.ToString() + "');</script>"; Page.RegisterStartupScript("PopupScript", popupScript); } }
//private void ExportToExcel(string nameReport, GridView wControl) //{ // string style = @"<style> TD { mso-number-format:\@; } </style>"; // //string styl = @"<style> .text { mso-number-format:\@; } </style> "; // HttpResponse response = Response; // StringWriter sw = new StringWriter(); // HtmlTextWriter htw = new HtmlTextWriter(sw); // Page pageToRender = new Page(); // HtmlForm form = new HtmlForm(); // form.Controls.Add(wControl); // pageToRender.Controls.Add(form); // response.Clear(); // response.Buffer = true; // response.ContentType = "application/vnd.ms-excel"; // response.AddHeader("Content-Disposition", "attachment;filename=" + nameReport + ".xls"); // Response.Write(style); // response.Charset = "UTF-8"; // response.ContentEncoding = Encoding.Default; // pageToRender.RenderControl(htw); // response.Write(sw.ToString()); // response.End(); //} protected void btnDetalle_Click(object sender, EventArgs e) { string factura = ""; try { Boolean check = false; Document_Controller docControl = new Document_Controller(); string listFolio = ""; for (int i = 0; i < RadGrid1.Items.Count; i++) { GridDataItem row = RadGrid1.Items[i]; bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked; if (isChecked) { int Foli = Convert.ToInt32(row["IDDocMercantil"].Text); factura = Foli.ToString(); listFolio = listFolio + Foli + ","; check = true; } } if (check != false) { listFolio = listFolio.Substring(0, listFolio.Length - 1); List <Detalle> lista = docControl.ListarExpExcelDet(listFolio); //ExportToExcel("LcoDet", view); btnExportCSV2_Click(lista, listFolio, txtFechaInicio.Text, txtFechaTermino.Text); //GridView gv = new GridView(); //gv.DataSource = lista; //gv.DataBind(); //ExportToExcel("LcoDet", gv); } else { } }catch (ThreadAbortException ex) { string a = factura; } }