示例#1
0
        protected void ibExportDoc_Click(object sender, ImageClickEventArgs e)
        {
            try {
                DateTime _fecStart = Convert.ToDateTime((txtDateStart.Text.Equals(string.Empty)) ? "01/01/1900" : txtDateStart.Text);
                DateTime _fecEnd   = Convert.ToDateTime((txtDateEnd.Text.Equals(string.Empty)) ? "01/01/1900" : txtDateEnd.Text);

                DataSet   _interf = Adonis.Get_Comercial_Interface(_fecStart, _fecEnd);
                DataTable dt      = _interf.Tables[0];

                DataRow[] foundRows = dt.Select("", "");

                System.Text.StringBuilder str = new System.Text.StringBuilder();

                for (int i = 0; i <= foundRows.GetUpperBound(0); i++)
                {
                    str.Append(foundRows[i][0].ToString() + "\r\n");
                }

                Response.Clear();
                Response.Buffer      = true;
                Response.ContentType = "text/plain";
                Response.AddHeader("Content-Disposition", "attachment;filename=InterComerAdonis.txt");
                Response.Charset         = "UTF-8";
                Response.ContentEncoding = System.Text.Encoding.Default;

                System.IO.StringWriter       tw = new System.IO.StringWriter();
                System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);

                Response.Write(str.ToString());
                Response.End();

                //DataSet _interf = Adonis.Get_Comercial_Interface(_user._usv_co, DateTime.Parse(txtDateStart.Text), DateTime.Parse(txtDateEnd.Text));
                //DataTable dt = _interf.Tables[0];

                ////DataRow[] foundRows = dt.Select("", "orde ASC");
                //DataRow[] foundRows = dt.Select("","");

                //System.Text.StringBuilder str = new System.Text.StringBuilder();

                //for (int i = 0; i <= foundRows.GetUpperBound(0); i++)
                //{
                //    str.Append(foundRows[i][0].ToString() + "\r\n");
                //}

                //Response.Clear();
                //Response.Buffer = true;
                //Response.ContentType = "text/plain";
                //Response.AddHeader("Content-Disposition", "attachment;filename=InterComerAdonis.txt");
                //Response.Charset = "UTF-8";
                //Response.ContentEncoding = System.Text.Encoding.Default;

                //System.IO.StringWriter tw = new System.IO.StringWriter();
                //System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);

                //Response.Write(str.ToString());
                //Response.End();
            }
            catch { }
        }
示例#2
0
        protected void ibExportDoc_Click(object sender, ImageClickEventArgs e)
        {
            DataTable dt = null;

            try
            {
                DateTime fechaini = Convert.ToDateTime(txtDateStart.Text);
                DateTime fechafin = Convert.ToDateTime(txtDateEnd.Text);
                dt = Documents_Trans.get_Docn_TransAdonis(fechaini, fechafin, "-1", "2").Tables[0];
                if (dt.Rows.Count > 0)
                {
                    DateTime _fecStart = Convert.ToDateTime((txtDateStart.Text.Equals(string.Empty)) ? "01/01/1900" : txtDateStart.Text);
                    DateTime _fecEnd   = Convert.ToDateTime((txtDateEnd.Text.Equals(string.Empty)) ? "01/01/1900" : txtDateEnd.Text);

                    DataSet   _interf = Adonis.Get_Comercial_Interface(_fecStart, _fecEnd);
                    DataTable dtinter = _interf.Tables[0];

                    DataRow[] foundRows = dtinter.Select("", "");

                    System.Text.StringBuilder str = new System.Text.StringBuilder();

                    for (int i = 0; i <= foundRows.GetUpperBound(0); i++)
                    {
                        str.Append(foundRows[i][0].ToString() + "\r\n");
                    }

                    Response.Clear();
                    Response.Buffer      = true;
                    Response.ContentType = "text/plain";
                    Response.AddHeader("Content-Disposition", "attachment;filename=InterComerAdonis.txt");
                    Response.Charset         = "UTF-8";
                    Response.ContentEncoding = System.Text.Encoding.Default;

                    System.IO.StringWriter       tw = new System.IO.StringWriter();
                    System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);

                    Response.Write(str.ToString());
                    Response.End();
                }
                else
                {
                    msnMessage.LoadMessage("No hay datos para exportar", UserControl.ucMessage.MessageType.Error);
                }
            }
            catch (Exception exc)
            {
                msnMessage.LoadMessage(exc.Message, UserControl.ucMessage.MessageType.Error);
                dt = null;
            }
        }