Exemplo n.º 1
0
 public static void Convert(System.Data.DataSet ds, string TableName, System.Web.HttpResponse response, string ExcelName)
 {
     //let's make sure the table name exists
     //if it does not then call the default method
     if (ds.Tables[TableName] == null)
     {
         Convert(ds, response, ExcelName);
     }
     //we've got a good table so
     //let's clean up the response.object
     response.Clear();
     response.Charset = "";
     //set the response mime type for excel
     response.ContentType = "application/vnd.ms-excel";
     //create a string writer
     System.IO.StringWriter stringWrite = new System.IO.StringWriter();
     //create an htmltextwriter which uses the stringwriter
     System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
     //instantiate a datagrid
     System.Web.UI.WebControls.DataGrid dg = new System.Web.UI.WebControls.DataGrid();
     //set the datagrid datasource to the dataset passed in
     dg.DataSource = ds.Tables[TableName];
     //bind the datagrid
     dg.DataBind();
     //tell the datagrid to render itself to our htmltextwriter
     dg.RenderControl(htmlWrite);
     //all that's left is to output the html
     response.Write(stringWrite.ToString());
     response.End();
 }
Exemplo n.º 2
0
 public static void Convert(System.Data.DataSet ds, int TableIndex, System.Web.HttpResponse response, string ExcelName)
 {
     //lets make sure a table actually exists at the passed in value
     //if it is not call the base method
     if (TableIndex > ds.Tables.Count - 1)
     {
         Convert(ds, response, ExcelName);
     }
     //we've got a good table so
     //let's clean up the response.object
     response.Clear();
     response.Charset = "";
     response.AddHeader("Content-Disposition", "attachment;filename=Shilpa.xls");
     //set the response mime type for excel
     response.ContentType = "application/vnd.ms-excel";
     //create a string writer
     System.IO.StringWriter stringWrite = new System.IO.StringWriter();
     //create an htmltextwriter which uses the stringwriter
     System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
     //instantiate a datagrid
     System.Web.UI.WebControls.DataGrid dg = new System.Web.UI.WebControls.DataGrid();
     //set the datagrid datasource to the dataset passed in
     dg.DataSource = ds.Tables[TableIndex];
     //bind the datagrid
     dg.DataBind();
     //tell the datagrid to render itself to our htmltextwriter
     dg.RenderControl(htmlWrite);
     //all that's left is to output the html
     response.Write(stringWrite.ToString());
     response.End();
 }
Exemplo n.º 3
0
    public void ToExcel(object sender, System.EventArgs e)
    {
        try
        {
            DataTable dtData = GetDTList();
            System.Web.UI.WebControls.DataGrid dgExport = null;
            System.Web.HttpContext curContext = System.Web.HttpContext.Current;

            System.IO.StringWriter strWriter = null;
            System.Web.UI.HtmlTextWriter htmlWriter = null;

            if (dtData != null && dtData.Rows.Count > 0)
            {
                curContext.Response.ContentType = "application/vnd.ms-excel";
                curContext.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
                curContext.Response.Charset = "UTF-8";
                curContext.Response.Write("<meta http-equiv=Content-Type content=text/html;charset=gb2312 >");

                strWriter = new System.IO.StringWriter();
                htmlWriter = new System.Web.UI.HtmlTextWriter(strWriter);
                dgExport = new System.Web.UI.WebControls.DataGrid();
                dgExport.DataSource = dtData.DefaultView;
                dgExport.AllowPaging = false;
                dgExport.DataBind();

                for (int i = 0; i < dgExport.Items.Count; i++)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        dgExport.Items[i].Cells[j].Attributes.Add("style", "vnd.ms-excel.numberformat:@");
                    }
                }

                dgExport.RenderControl(htmlWriter);
                curContext.Response.Write(strWriter.ToString());
                curContext.Response.End();
                WriteAlertInfo(AlertSuccess);
            }
            else
            {
                WriteAlertInfo(AlertNoData);
            }
        }
        catch (FisException fe)
        {
            this.GridViewExt1.DataSource = GetTable();
            this.GridViewExt1.DataBind();
            writeToAlertMessage(fe.mErrmsg);
        }
        catch (Exception ex)
        {
            this.GridViewExt1.DataSource = GetTable();
            this.GridViewExt1.DataBind();
            writeToAlertMessage(ex.Message);
        }
        finally
        {
            endWaitingCoverDiv();
        }
    }
Exemplo n.º 4
0
        public void ExportToExcel(DataTable dt)
        {
            if (dt.Rows.Count > 0)
            {
                string filename = "Test1234.xls";
                string excelHeader = "Quiz Report";

                System.IO.StringWriter tw = new System.IO.StringWriter();
                System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
                DataGrid dgGrid = new DataGrid();
                dgGrid.DataSource = dt;
                dgGrid.DataBind();

                // Report Header
                hw.WriteLine("<b><u><font size=’3′> " + excelHeader + " </font></u></b>");

                //Get the HTML for the control.
                dgGrid.RenderControl(hw);

                //Write the HTML back to the browser.
                Response.ContentType = "application/vnd.ms-excel";
                Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename + "");
                this.EnableViewState = false;
                Response.Write(tw.ToString());
                Response.End();
            }
        }
Exemplo n.º 5
0
        private void save(DataTable dt,string filename)
        {
            DataGrid excel = new DataGrid();
            System.Web.UI.WebControls.TableItemStyle AlternatingStyle = new TableItemStyle();
            System.Web.UI.WebControls.TableItemStyle headerStyle = new TableItemStyle();
            System.Web.UI.WebControls.TableItemStyle itemStyle = new TableItemStyle();
            AlternatingStyle.BackColor = System.Drawing.Color.LightGray;
            headerStyle.BackColor = System.Drawing.Color.LightGray;
            headerStyle.Font.Bold = true;
            headerStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
            itemStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center; ;

            excel.AlternatingItemStyle.MergeWith(AlternatingStyle);
            excel.HeaderStyle.MergeWith(headerStyle);
            excel.ItemStyle.MergeWith(itemStyle);
            excel.GridLines = GridLines.Both;
            excel.HeaderStyle.Font.Bold = true;
            DataSet ds = new DataSet();
            ds.Tables.Add(dt);
            excel.DataSource = ds;   //输出DataTable的内容
            excel.DataBind();

            System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
            excel.RenderControl(oHtmlTextWriter);

            Response.AddHeader("Content-Disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8) + ".xls");
            Response.ContentType = "application/ms-excel";
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
            Response.Write(oHtmlTextWriter.InnerWriter.ToString());
            Response.End();
        }
Exemplo n.º 6
0
 private void UploadDataTableToExcel(DataTable feedBacks)
 {
     HttpResponse response = HttpContext.Current.Response;
     try
     {
         response.Clear();
         response.Charset = string.Empty;
         response.ContentType = "application/vnd.ms-excel";
         response.AddHeader("Content-Disposition", "attachment;filename=\"FeedBack.xls\"");
         using (StringWriter stringWriter = new StringWriter())
         {
             using (HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter))
             {
                 DataGrid dataGrid = new DataGrid();
                 dataGrid.DataSource = feedBacks;
                 dataGrid.DataBind();
                 dataGrid.RenderControl(htmlTextWriter);
                 response.Write(stringWriter.ToString());
             }
         }
         response.End();
     }
     catch (ThreadAbortException ex)
     {
         Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Exporta la información a Excel.
        /// </summary>
        /// <param name="response">HttpResponse actual.</param>
        /// <param name="data">Datos a exportar.</param>
        /// <param name="nombreArchivo">Nombre del archivo Excel</param>
        public static void ExportToExcelFile(HttpResponse response, DataView data, string nombreArchivo)
        {
            var dg = new DataGrid { DataSource = data };
            dg.DataBind();

            response.Clear();
            response.Buffer = true;

            //application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
            response.AddHeader("Content-Disposition", "filename=" + nombreArchivo);
            response.ContentType = "application/vnd.ms-excel";
            response.Charset = "UTF-8";
            response.ContentEncoding = System.Text.Encoding.Default;

            var stringWriter = new StringWriter();
            var htmlWriter = new HtmlTextWriter(stringWriter);
            dg.RenderControl(htmlWriter);

            response.Write(stringWriter.ToString());
            //resp.Flush();
            try
            {
                response.End();
            }
            catch (Exception ex)
            {
                ISException.RegisterExcepcion(ex);
                throw ex;
            }
        }
Exemplo n.º 8
0
    public static void Convert(System.Data.DataSet ds, System.Web.HttpResponse response, string ExcelName)
    {
        try
        {
            //first let's clean up the response.object
            response.Clear();
            response.Charset = "";
            //set the response mime type for excel

            response.ContentType = "application/vnd.ms-excel";
            //create a string writer
            //response.AddHeader("Content-Disposition", "attachment;filename=Shilpa.xls");

            response.AddHeader("Content-Disposition", "attachment;filename=" + ExcelName + ".xls");

            System.IO.StringWriter stringWrite = new System.IO.StringWriter();
            //create an htmltextwriter which uses the stringwriter
            System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
            //instantiate a datagrid
            System.Web.UI.WebControls.DataGrid dg = new System.Web.UI.WebControls.DataGrid();
            //set the datagrid datasource to the dataset passed in
            dg.DataSource = ds.Tables[0];
            //bind the datagrid
            dg.DataBind();
            //tell the datagrid to render itself to our htmltextwriter
            dg.RenderControl(htmlWrite);
            //all that's left is to output the html
            response.Write(stringWrite.ToString());
            response.End();
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Exemplo n.º 9
0
 public override void ExecuteResult(ControllerContext context)
 {
     var Response = context.HttpContext.Response;
     Response.Buffer = true;
     Response.ContentType = "application/vnd.ms-excel";
     Response.Charset = "";
     var dg = new DataGrid();
     string filename = null;
     switch (type)
     {
         case "donorfundtotals":
             filename = "DonorFundTotals";
             dg.DataSource = ExportPeople.ExcelDonorFundTotals(Dt1, Dt2, fundid, campusid, pledges, nontaxdeductible, IncUnclosedBundles);
             break;
         case "donortotals":
             filename = "DonorTotals";
             dg.DataSource = ExportPeople.ExcelDonorTotals(Dt1, Dt2, campusid, pledges, nontaxdeductible, IncUnclosedBundles);
             break;
         case "donordetails":
             filename = "DonorDetails";
             dg.DataSource = ExportPeople.DonorDetails(Dt1, Dt2, fundid, campusid, pledges, nontaxdeductible, IncUnclosedBundles);
             break;
     }
     dg.DataBind();
     Response.AddHeader("Content-Disposition", "attachment;filename={0}.xls".Fmt(filename));
     dg.RenderControl(new HtmlTextWriter(Response.Output));
 }
 protected void AssociarDadosGrid(DataGrid dgview, DataTable dtdados, Label lblresultado)
 {
     if (dtdados.Rows.Count > 0)
     {
         lblresultado.Visible = false;
         dgview.DataSource = dtdados;
         dgview.DataBind();
     }
     else
     {
         lblresultado.Visible = true;
         lblresultado.Text = "Nenhum registro encontrado";
         dgview.DataSource = null;
         dgview.DataBind();
     }
 }
Exemplo n.º 11
0
    //protected override void OnPreInit(EventArgs e)
    //{
    //    //if (Request.Url.AbsoluteUri.IndexOf("Login") == -1)
    //    //{
    //    //    if (CurrentUserInfo == null)
    //    //    {
    //    //        Response.Redirect(ResolveUrl("~/Login.aspx"));
    //    //    }
    //    //}
    //    //base.OnPreInit(e);
    //}



    /// <summary>
    /// 导出excel
    /// </summary>
    /// <param name="ds"></param>
    /// <param name="FileName"></param>
    public void CreateExcel(DataSet ds, string FileName)
    {
        System.Web.UI.WebControls.DataGrid dgExport   = null;
        System.Web.HttpContext             curContext = System.Web.HttpContext.Current;
        System.IO.StringWriter             strWriter  = null;
        System.Web.UI.HtmlTextWriter       htmlWriter = null;

        if (ds != null)
        {
            curContext.Response.ContentType     = "application/vnd.ms-excel";
            curContext.Response.ContentEncoding = System.Text.Encoding.UTF8;
            curContext.Response.Charset         = "UTF-8";
            curContext.Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(FileName)) + ".xls");

            strWriter  = new System.IO.StringWriter();
            htmlWriter = new System.Web.UI.HtmlTextWriter(strWriter);

            dgExport             = new System.Web.UI.WebControls.DataGrid();
            dgExport.DataSource  = ds.Tables[0].DefaultView;
            dgExport.AllowPaging = false;
            dgExport.DataBind();

            dgExport.RenderControl(htmlWriter);
            curContext.Response.Write(strWriter.ToString());
            curContext.Response.End();
        }
    }
Exemplo n.º 12
0
 public static void Convert(System.Data.DataSet ds, int TableIndex, System.Web.HttpResponse response, string ExcelName)
 {
     //lets make sure a table actually exists at the passed in value
     //if it is not call the base method
     if (TableIndex > ds.Tables.Count - 1)
     {
         Convert(ds, response, ExcelName);
     }
     //we've got a good table so
     //let's clean up the response.object
     response.Clear();
     response.Charset = "";
     response.AddHeader("Content-Disposition", "attachment;filename=Shilpa.xls");
     //set the response mime type for excel
     response.ContentType = "application/vnd.ms-excel";
     //create a string writer
     System.IO.StringWriter stringWrite = new System.IO.StringWriter();
     //create an htmltextwriter which uses the stringwriter
     System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
     //instantiate a datagrid
     System.Web.UI.WebControls.DataGrid dg = new System.Web.UI.WebControls.DataGrid();
     //set the datagrid datasource to the dataset passed in
     dg.DataSource = ds.Tables[TableIndex];
     //bind the datagrid
     dg.DataBind();
     //tell the datagrid to render itself to our htmltextwriter
     dg.RenderControl(htmlWrite);
     //all that's left is to output the html
     response.Write(stringWrite.ToString());
     response.End();
 }
Exemplo n.º 13
0
    public static void DataTable2Excel(System.Data.DataTable dtData)
    {
        System.Web.UI.WebControls.DataGrid dgExport = null;
        // 当前对话

        System.Web.HttpContext curContext = System.Web.HttpContext.Current;
        // IO用于导出并返回excel文件
        System.IO.StringWriter       strWriter  = null;
        System.Web.UI.HtmlTextWriter htmlWriter = null;

        if (dtData != null)
        {
            // 设置编码和附件格式
            curContext.Response.ContentType     = "application/vnd.ms-excel";
            curContext.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
            curContext.Response.Charset         = "gb2312";
            curContext.Response.AppendHeader("Content-Disposition", "attachment;filename=111111111111111.xls");

            // 导出excel文件
            strWriter  = new System.IO.StringWriter();
            htmlWriter = new System.Web.UI.HtmlTextWriter(strWriter);

            // 为了解决dgData中可能进行了分页的情况,需要重新定义一个无分页的DataGrid
            dgExport             = new System.Web.UI.WebControls.DataGrid();
            dgExport.DataSource  = dtData.DefaultView;
            dgExport.AllowPaging = false;
            dgExport.DataBind();

            // 返回客户端
            dgExport.RenderControl(htmlWriter);
            curContext.Response.Write("<meta http-equiv=\"content-type\" content=\"application/ms-excel; charset=gb2312\"/>" + strWriter.ToString());
            curContext.Response.End();
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     //if (Session["Type"].ToString() == "Excel")
     //{
     DataSet ds = Session["ExcelDs"] as DataSet;
     Response.Clear();
     Response.Charset = "";
     Response.ContentType = "application/vnd.ms-excel";
     Response.AddHeader("Content-Disposition", "attachment;filename=ExcelName.xls");
     System.IO.StringWriter stringWrite = new System.IO.StringWriter();
     System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
     System.Web.UI.WebControls.DataGrid dg = new System.Web.UI.WebControls.DataGrid();
     dg.DataSource = ds.Tables[0];
     dg.DataBind();
     dg.RenderControl(htmlWrite);
     Response.Write(stringWrite.ToString());
     Response.End();
     //}
     //else
     //{
     //    Response.ContentType = "application/pdf";
     //    string path = Server.MapPath("~/PDFS/TestM10.pdf");
     //    byte[] bts = System.IO.File.ReadAllBytes(path);
     //    Response.Clear();
     //    Response.ClearHeaders();
     //    Response.AddHeader("Content-Type", "Application/octet-stream");//octet-stream
     //    Response.AddHeader("Content-Length", bts.Length.ToString());
     //    Response.AddHeader("Content-Disposition", "attachment;   filename=1.pdf");
     //    Response.BinaryWrite(bts);
     //    Response.Flush();
     //    Response.TransmitFile(path);
     //    Response.End();
     //}
 }
Exemplo n.º 15
0
        public override void ExecuteResult(ControllerContext context)
        {
            var r = context.HttpContext.Response;
            r.Clear();
            r.ContentType = "application/vnd.ms-excel";
            if (!string.IsNullOrEmpty(FileName))
                r.AddHeader("content-disposition",
                    "attachment;filename=" + FileName);
            const string header =
@"<html xmlns:x=""urn:schemas-microsoft-com:office:excel"">
<head>
    <meta http-equiv=Content-Type content=""text/html; charset=utf-8"">
    <style>
    <!--table
    br {mso-data-placement:same-cell;}
    tr {vertical-align:top;}
    -->
    </style>
</head>
<body>";
            r.Write(header);
            r.Charset = "";

            var dg = new DataGrid();
            dg.EnableViewState = false;
            dg.DataSource = Data;
            dg.DataBind();
            dg.RenderControl(new HtmlTextWriter(r.Output));
            r.Write("</body></HTML>");
        }
Exemplo n.º 16
0
        public override void ExecuteResult(ControllerContext context)
        {
            var Response = context.HttpContext.Response;

            Response.Buffer = true;
            Response.ContentType = "application/vnd.ms-excel";
            Response.AddHeader("Content-Disposition", "attachment;filename=CMSPeople.xls");
            Response.Charset = "";

            var name = "ExtraExcelResult " + DateTime.Now;
            var tag = DbUtil.Db.PopulateSpecialTag(qid, DbUtil.TagTypeId_ExtraValues);

            var roles = CMSRoleProvider.provider.GetRolesForUser(Util.UserName);
            var xml = XDocument.Parse(DbUtil.Db.Content("StandardExtraValues.xml", "<Fields/>"));
            var fields = (from ff in xml.Root.Elements("Field")
                          let vroles = ff.Attribute("VisibilityRoles")
                          where vroles != null && (vroles.Value.Split(',').All(rr => !roles.Contains(rr)))
                          select ff.Attribute("name").Value);
            var nodisplaycols = string.Join("|", fields);

            var cmd = new SqlCommand("dbo.ExtraValues @p1, @p2, @p3");
            cmd.Parameters.AddWithValue("@p1", tag.Id);
            cmd.Parameters.AddWithValue("@p2", "");
            cmd.Parameters.AddWithValue("@p3", nodisplaycols);
            cmd.Connection = new SqlConnection(Util.ConnectionString);
            cmd.Connection.Open();

            var dg = new DataGrid();
            dg.DataSource = cmd.ExecuteReader();
            dg.DataBind();
            dg.RenderControl(new HtmlTextWriter(Response.Output));
        }
Exemplo n.º 17
0
        /// <summary>
        /// 导出Excel文件,转换为可读模式
        /// </summary>
        public static void DataTable2Excel(System.Data.DataTable dtData)
        {
            DataGrid dgExport = null;
            HttpContext curContext = HttpContext.Current;
            StringWriter strWriter = null;
            HtmlTextWriter htmlWriter = null;

            if (dtData != null)
            {
                curContext.Response.ContentType = "application/vnd.ms-excel";
                curContext.Response.ContentEncoding = System.Text.Encoding.UTF8;
                curContext.Response.Charset = "";
                strWriter = new StringWriter();
                htmlWriter = new HtmlTextWriter(strWriter);
                dgExport = new DataGrid();
                dgExport.DataSource = dtData.DefaultView;
                dgExport.AllowPaging = false;
                dgExport.DataBind();
                try
                {
                    dgExport.RenderControl(htmlWriter);
                }
                catch (Exception e)
                {
                    Log4Net.LogWrite("err", e.Message);
                }
                curContext.Response.Write(strWriter.ToString());
                curContext.Response.End();
            }
        }
Exemplo n.º 18
0
 /// <summary>
 /// Bind datagrid with sorting dataview.
 /// </summary>
 /// <param name="dv">DataView</param>
 /// <param name="dataGrid">DataGrid</param>
 /// <param name="sortField">Sorting Field</param>
 /// <param name="keyField">DataGrid's Key Field</param>
 public static void BindAndSort(DataView dv,DataGrid dataGrid,string sortField,string keyField)
 {
     if(dv != null)
         dv.Sort = sortField;
     dataGrid.DataSource = dv;
     dataGrid.DataKeyField=keyField;
     dataGrid.DataBind();
 }
Exemplo n.º 19
0
 public static void Bind(DataTable dt, DataGrid dg)
 {
     if (dt != null)
     {
         dg.DataSource = dt;
         dg.DataBind();
     }
 }
Exemplo n.º 20
0
 /// <summary>
 /// Bind datagrid with sorting dataview.
 /// </summary>
 /// <param name="ds">DataSet</param>
 /// <param name="dataGrid">DataGrid</param>
 /// <param name="sortField">Sorting Field</param>
 /// <param name="keyField">DataGrid's Key Field</param>
 public static void BindAndSort(DataSet ds,DataGrid dataGrid,string sortField,string keyField)
 {
     DataView dataView	= ds.Tables[0].DefaultView;
     dataView.Sort = sortField;
     dataGrid.DataSource = dataView;
     dataGrid.DataKeyField=keyField;
     dataGrid.DataBind();
 }
Exemplo n.º 21
0
 public void DataGridWebControlSupport()
 {
     var command = new NpgsqlCommand("select * from data;", Conn);
     var dr = command.ExecuteReader();
     //Console.WriteLine(dr.FieldCount);
     var dg = new DataGrid();
     dg.DataSource = dr;
     dg.DataBind();
 }
 private static System.IO.StringWriter GetHtmlTagsfromDatagrid(DataTable datatable)
 {
     System.IO.StringWriter stringWriter = new System.IO.StringWriter();
     HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWriter);
     DataGrid dg = new DataGrid();
     dg.DataSource = datatable;
     dg.DataBind();
     dg.RenderControl(htmlWrite);
     return stringWriter;
 }
Exemplo n.º 23
0
        private void BindGrid(int iNoofRow)
        {
            DataSet ds;

            if (ViewState["data"] == null)
            {
                CreateDataSet(iNoofRow);
            }
            ds = ((DataSet)(ViewState["data"]));
            grdList.DataSource = ds.Tables[0];
            grdList.DataBind();
        }
        private void BindGridPuntosRecepcion()
        {
            SisPackController.AdministrarGrillas.Configurar(this.dtgPuntosRecepcion, "PuntoRecepcionID", this.CantidadOpciones);
            try
            {
                IPuntoRecepcion   puntoRecepcion = PuntoRecepcionFactory.GetPuntoRecepcion();
                DsPuntosRecepcion ds             = null;

                ds = puntoRecepcion.GetPuntosRecepcionDataSet();

                string sucursal = this.txtSucursal.Text;
                string razon    = this.txtRazonSocial.Text;
                string filtro   = "Codigo LIKE '" + sucursal + "%' AND RazonSocial LIKE '" + razon + "%'";

                DsPuntosRecepcion.DatosRow[] drPuntoRecepcion = (DsPuntosRecepcion.DatosRow[])ds.Datos.Select(filtro);

                dtgPuntosRecepcion.DataSource = drPuntoRecepcion;
                dtgPuntosRecepcion.DataBind();

                if (Session["dsPuntosRecepcion"] != null)
                {
                    DsPuntosRecepcion dsPuntosRecepcion = (DsPuntosRecepcion)Session["dsPuntosRecepcion"];
                    foreach (DataGridItem item in this.dtgPuntosRecepcion.Items)
                    {
                        if (dsPuntosRecepcion.Datos.Select("PuntoRecepcionID = " + Convert.ToInt32(item.Cells[0].Text.Trim())).Length > 0)
                        {
                            ((CheckBox)this.dtgPuntosRecepcion.Items[item.ItemIndex].Cells[3].FindControl("ckSeleccionarP")).Checked = true;
                        }
                    }
                    dsPuntosRecepcion = null;
                }

                ds             = null;
                puntoRecepcion = null;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void BindGridAgenciasRedespacho()
        {
            SisPackController.AdministrarGrillas.Configurar(this.dtgAgencias, "AgenciaID", this.CantidadOpciones);
            try
            {
                IAgencia   agencia = AgenciaFactory.GetAgencia();
                DsAgencias ds      = null;

                ds = agencia.GetAgenciasRedespacho();

                string sucursal = this.txtSucursal.Text;
                string razon    = this.txtRazonSocial.Text;
                string filtro   = "SucursalDGI LIKE '" + sucursal + "%' AND RazonSocial LIKE '" + razon + "%'";

                DsAgencias.DatosRow[] drLista = (DsAgencias.DatosRow[])ds.Datos.Select(filtro);

                dtgAgencias.DataSource = drLista;
                dtgAgencias.DataBind();

                if (Session["dsAgenciasRedespacho"] != null)
                {
                    DsAgencias dsAgencias = (DsAgencias)Session["dsAgenciasRedespacho"];
                    foreach (DataGridItem item in this.dtgAgencias.Items)
                    {
                        if (dsAgencias.Datos.Select("AgenciaID = " + Convert.ToInt32(item.Cells[0].Text.Trim())).Length > 0)
                        {
                            ((CheckBox)this.dtgAgencias.Items[item.ItemIndex].Cells[3].FindControl("ckSeleccionarA")).Checked = true;
                        }
                    }
                    dsAgencias = null;
                }

                ds      = null;
                agencia = null;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 26
0
        private void BindGrid()
        {
            string archivo = "";

            try
            {
                AdministrarGrillas.Configurar(dtgCaja, "CajaID", CantidadOpciones, true, false);
                ICaja caja = CajaFactory.GetCajaFactory();
                caja.CajaDescrip  = txtDescripcion.Text;
                archivo           = txtDescPlanilla.Text;
                caja.TipoCajaID   = Utiles.Validaciones.obtieneEntero(ddlTipoCaja.SelectedValue);
                caja.EstadoCajaID = EstadoCaja();
                string tipoGuia    = "";
                string nroSucursal = "";
                int    nGuia       = 0;

                if ((Convert.ToInt32(this.ddlTipoCaja.SelectedValue.Equals("TODAS") ? "0" : this.ddlTipoCaja.SelectedValue) != (int)NegociosSisPackInterface.SisPack.TipoCaja.AR) &&
                    (Convert.ToInt32(this.ddlTipoCaja.SelectedValue.Equals("TODAS") ? "0" : this.ddlTipoCaja.SelectedValue) != (int)NegociosSisPackInterface.SisPack.TipoCaja.EM))
                {
                    this.txtCodigoBarra.Text = "";
                }

                if (!this.txtCodigoBarra.Text.Trim().Equals(""))
                {
                    if (this.txtCodigoBarra.Text.Length > (int)NegociosSisPackInterface.SisPack.CodigoBarrasGuia.Longitud)
                    {
                        throw new Exception("Errores.Invalidos.CodigoBarrasLongitud");
                    }
                    //Diego 03/05/2013 agregado para que tome el tipo de caja
                    caja.TipoCajaID = Convert.ToInt32(this.ddlTipoCaja.SelectedValue);


                    tipoGuia = NegociosSisPackInterface.SisPack.TipoGuia(this.txtCodigoBarra.Text.Substring(0, 1).Trim()).Trim();

                    if (tipoGuia.Equals(""))
                    {
                        throw new Exception("Errores.Invalidos.CodigoBarrasLongitud");
                    }

                    nroSucursal = this.txtCodigoBarra.Text.Substring(1, 4);
                    nGuia       = Convert.ToInt32(this.txtCodigoBarra.Text.Substring(5));
                }

                dtgCaja.CurrentPageIndex = Utiles.Validaciones.obtieneEntero(txtPagina.Text);
                dtgCaja.DataSource       = caja.GetCajaDataSet(archivo, tipoGuia, nroSucursal, nGuia).Datos;
                dtgCaja.DataBind();
            }
            catch (Exception ex)
            {
                ((ErrorWeb)phErrores.Controls[0]).setMensaje(ex.Message);
            }
        }
Exemplo n.º 27
0
        private void btn_OK_Click(object sender, System.EventArgs e)
        {
            tbl_Search.Visible  = false;
            dgrd_Result.Visible = true;

            SqlDataReader dr_result = null;

            UDS.Components.BBSClass bbs    = new UDS.Components.BBSClass();
            BBSSearchOption         option = new BBSSearchOption();

            option.searchtype = (rbtn_author.Checked)?BBSSearchType.author:BBSSearchType.title;
            switch (ddl_Time.SelectedValue)
            {
            case "0":
                option.TimeBound = TimeSpan.MaxValue;
                break;

            case "d":
                option.TimeBound = new TimeSpan(Int32.Parse((tbx_Time.Text.Trim() == "")?"1":tbx_Time.Text.Trim()), 0, 0, 0);
                break;

            case "w":
                option.TimeBound = new TimeSpan(Int32.Parse((tbx_Time.Text.Trim() == "")?"1":tbx_Time.Text.Trim()) * 7, 0, 0, 0);
                break;

            case "m":
                option.TimeBound = new TimeSpan(Int32.Parse((tbx_Time.Text.Trim() == "")?"1":tbx_Time.Text.Trim()) * 30, 0, 0, 0);
                break;

            case "y":
                option.TimeBound = new TimeSpan(Int32.Parse((tbx_Time.Text.Trim() == "")?"1":tbx_Time.Text.Trim()) * 365, 0, 0, 0);
                break;
            }

            option.BoardID = Int32.Parse(dll_Board.SelectedValue);

            UDS.Components.BBSClass bbs1 = new UDS.Components.BBSClass();
            if (Request.Cookies["UDSBBSAdmin"].Value == "1")
            {
                dr_board = bbs1.GetAllBBSBoard();
            }
            else
            {
                dr_board = bbs1.GetBBSBoard(Request.Cookies["UserName"].Value);
            }

            dr_result = bbs.Find(tbx_Key.Text.Trim(), option, UDS.Components.Tools.ConvertDataReaderToDataTable(dr_board));
            DataTable dt_result = UDS.Components.Tools.ConvertDataReaderToDataTable(dr_result);

            dgrd_Result.DataSource = dt_result.DefaultView;
            dgrd_Result.DataBind();
        }
        private void BindGridTopesTarif(int currentPageIndex)
        {
            //Llenar la grilla con topes del tarifario
            dtgTopesTarifario.DataSource       = tari.GetTopesDataSet();
            dtgTopesTarifario.CurrentPageIndex = currentPageIndex;
            dtgTopesTarifario.DataBind();
            if (tari.ValorizacionTarifario == SisPack.ValorizacionTarifario.Kilogramo)
            {
                dtgTopesTarifario.Columns[2].Visible = false;
                dtgTopesTarifario.Columns[4].Visible = false;
                dtgTopesTarifario.Columns[5].Visible = true;
            }
            else
            {
                dtgTopesTarifario.Columns[5].Visible = false;
            }

            if (tari.ValorizacionTarifario == SisPack.ValorizacionTarifario.Bulto)
            {
                dtgTopesTarifario.Columns[4].Visible = false;
            }

            if (tari.ValorizacionTarifario == SisPack.ValorizacionTarifario.ValorDeclarado)
            {
                dtgTopesTarifario.Columns[2].Visible = false;
                dtgTopesTarifario.Columns[4].Visible = false;
                dtgTopesTarifario.Columns[5].Visible = false;
            }

            if (tari.ValorizacionTarifario == SisPack.ValorizacionTarifario.Bulto_Variable)
            {
                dtgTopesTarifario.Columns[2].Visible = true;
                dtgTopesTarifario.Columns[4].Visible = false;
                dtgTopesTarifario.Columns[5].Visible = false;
            }

            //this.SetBotones();

            /*
             * this.SetBotonImportes();
             *
             * if((dtgTopesTarifario.Items.Count)==0)
             * {
             *      this.chkTopesTarifTodos.Checked=false;
             *      this.chkTopesTarifTodos.Enabled=false;
             * }
             * else
             * {
             *      this.chkTopesTarifTodos.Enabled=true;
             * }*/
            //Session["tarifario"] = tariFlete;
        }
        private void BindGrid(int currentPage)
        {
            try
            {
                bool inhabilitado;
                IServicioTransporte servicio = ServicioTransporteFactory.GetServicioTransporte();

                servicio.oLineaTransporte.LineaTransporteID   = Utiles.Validaciones.obtieneEntero(ddlLineaTransporte.SelectedValue);
                servicio.oUnidadTransporte.UnidadTransporteID = Utiles.Validaciones.obtieneEntero(ddlUnidadTransporte.SelectedValue);
                servicio.ServicioIDSITT = (Utiles.Validaciones.obtieneEntero(ddlCodServicioTransporte.SelectedValue)).ToString();
                if (busqChofer.Legajo == "")
                {
                    servicio.oChofer.ChoferID = 0;
                }
                else
                {
                    servicio.oChofer.ChoferID = Utiles.Validaciones.obtieneEntero(busqChofer.ChoferID);
                }


                servicio.ServicioEmpresaSITT = "TAQ";
                servicio.ServicioCodigoSITT  = txtCodSITT.Text;
                if (txtFecha.Text != "")
                {
                    servicio.ServicioFecha = Utiles.Fechas.FormatFechaDDMMYYYY(txtFecha.Text);
                }



                AdministrarGrillas.Configurar(dtgServicios, "ServicioTransporteID", CantidadOpciones, true, false);

                dtgServicios.CurrentPageIndex = currentPage;

                /*definimos si se desean ver los servicios  inhabilitados / ambos*/
                if (chkInhabilitados.Checked)
                {
                    inhabilitado = true;                  //ambos
                }
                else
                {
                    inhabilitado = false;                  //solo los habilitados
                }
                dtgServicios.DataSource = servicio.GetServicioTransportes(inhabilitado).Datos;
                //this.dtgServicios.ShowFooter = true;
                this.dtgServicios.PageSize = 50;
                dtgServicios.DataBind();
            }
            catch (Exception ex)
            {
                ((ErrorWeb)phErrores.Controls[0]).setMensaje(ex.Message);
            }
        }
 private void BindGrilla()
 {
     try
     {
         IHojaRutaInterno hojaRuta = HojaRutaInternoFactory.GetHojaRutaInterno();
         hojaRuta.AgenciaDestinoID  = AgenciaConectadaID;
         hojaRuta.HojaRutaInternoID = Utiles.Validaciones.obtieneEntero(txtNroHojaRutaInterno.Text);
         DsHojaRutaInternoGuias ds = new DsHojaRutaInternoGuias();
         if (Session["DsGuias"] == null)
         {
             ds = hojaRuta.GetGuiasAsignadasByNroHojaRutaInterno(!butConfirmar.Enabled);
         }
         else
         {
             ds = (DsHojaRutaInternoGuias)Session["DsGuias"];
         }
         if (Session["DsHojaRutaInterno"] != null)
         {
             DsHojaRutaInternoGuias dsS = (DsHojaRutaInternoGuias)Session["DsHojaRutaInterno"];
             foreach (DsHojaRutaInternoGuias.DatosRow dr in ds.Datos)
             {
                 DsHojaRutaInternoGuias.DatosRow[] drS = (DsHojaRutaInternoGuias.DatosRow[])dsS.Datos.Select("GuiaID = " + dr.GuiaID);
                 if (drS.Length == 1)
                 {
                     dr.Asignada = true;
                 }
                 else
                 {
                     dr.Asignada = false;
                 }
             }
         }
         else
         {
             foreach (DataGridItem item in dtgGuiasAsociadas.Items)
             {
                 DsHojaRutaInternoGuias.DatosRow dr = (DsHojaRutaInternoGuias.DatosRow)ds.Datos.Rows[item.DataSetIndex];
                 CheckBox chk = (CheckBox)item.FindControl("chkGuia");
                 dr.Asignada = chk.Checked;
             }
         }
         Session["DsGuias"] = ds;
         SisPackController.AdministrarGrillas.Configurar(dtgGuiasAsociadas, "GuiaID", CantidadOpciones);
         dtgGuiasAsociadas.AllowPaging = false;
         dtgGuiasAsociadas.DataSource  = ds.Datos;
         dtgGuiasAsociadas.DataBind();
     }
     catch (Exception ex)
     {
         ((ErrorWeb)phErrores.Controls[0]).setMensaje(ex.Message);
     }
 }
Exemplo n.º 31
0
        private void Bind()
        {
            UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
            DataTable dt;

            labTitle.Text = df.GetFlowTitle(FlowID);
            df.GetStep(FlowID, 0, out dt);

            dgStepList.DataSource = dt.DefaultView;
            dgStepList.DataBind();

            df = null;
        }
Exemplo n.º 32
0
        public void DysplayGrid()
        {
            Hashtable _HS     = (Hashtable)Session["ParametriSelectSchema"];
            string    VISTA   = Convert.ToString(_HS["NomeVista"]);
            int       IdVista = Convert.ToInt32(_HS["IdVista"]);

            VISTA = " " + VISTA + " ";
            TheSite.GIC.App_Code.Consultazioni.interogazioni DQ = new TheSite.GIC.App_Code.Consultazioni.interogazioni();
            DQ.VISTA   = VISTA;
            DQ.IdVista = IdVista;
            DataGridQuery.DataSource = DQ.GetData(IdQ);
            DataGridQuery.DataBind();
        }
Exemplo n.º 33
0
        private void BinGridSolicitudOrDes(int currentPageIndex)
        {
            ISolicitudCotizacionUVentaModalidadOrigenDestino    oCotizaOriDest = SolicitudCotizacionUVentaOrigenDestinoFactory.GetSolicitudCotizacionUVentaOrigenDestino();
            DsSolicitudCotizacionUVentaModOrigenDestinoCompleto ds             = oCotizaOriDest.GetSolCotOrigenDestinoConsultaDataSet();

            AdministrarGrillas.ConfigurarChica(this.dtgSolCotOrigenDestino, "SolicitudCotizacionUVentaModalidadOrigenDestinoID");
            if (ds != null)
            {
                dtgSolCotOrigenDestino.DataSource       = ds.Datos.Select(("SolicitudCotizacionUVentaID = " + cotizacionClienteUVentasel.SolicitudCotizacionUVentaID));
                dtgSolCotOrigenDestino.CurrentPageIndex = currentPageIndex;
                dtgSolCotOrigenDestino.DataBind();
            }
        }
Exemplo n.º 34
0
        private void BindPermissions()
        {
            Permission.PermissionList perms =
                new Permissions(Globals.CurrentIdentity).GetTypePermissions(GetObjectType());

            int       prinID = (int)dgRoles.DataKeys[dgRoles.SelectedIndex];
            Principal prin   = new Principals(Globals.CurrentIdentity).GetInfo(prinID);

            lblPrin.Text = "Selection: " + prin.Name;

            dgPerms.DataSource = perms;
            dgPerms.DataBind();
        }
Exemplo n.º 35
0
 private void Page_Load(object sender, System.EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         Session["SelectedCategory"] = null;
     }
     // Refresh the DataSet every time, even for postbacks.
     // This is not a performance drag, because the DataSet
     // is usuaslly cached.
     gridMaster.DataSource = db.GetCategoriesProductsDataSet();
     gridMaster.DataMember = "Categories";
     gridMaster.DataBind();
 }
Exemplo n.º 36
0
 private void Page_Load(object sender, System.EventArgs e)
 {
     // 在此处放置用户代码以初始化页面
     if (!Page.IsPostBack)
     {
         UDS.Components.CM cm = new UDS.Components.CM();
         SqlDataReader     dr = cm.GetAllLinkman();
         DataTable         dt = UDS.Components.Tools.ConvertDataReaderToDataTable(dr);
         dgrd_Linkman.DataSource = dt.DefaultView;
         dgrd_Linkman.DataBind();
         ltl_Count.Text = dt.Rows.Count.ToString();
     }
 }
Exemplo n.º 37
0
        private void BindGrid(int currentPage)
        {
            SisPackController.AdministrarGrillas.Configurar(dtgAgencias, "AgenciaID", this.CantidadOpciones);
            IAgencia oAgencia = AgenciaFactory.GetAgencia();
            //oAgencia.RazonSocial = this.txtRazonSocial.Text;
            //oAgencia.Domicilio.Localidad.Provincia.ProvinciaDescrip = this.txtProvincia.Text;
            //dtgAgencias.DataSource = oAgencia.GetAgenciasConsultaDataSet(this.UnidadNegocioID);
            DsAgencias ds = oAgencia.GetAgenciasConsultaDataSet();

            dtgAgencias.DataSource       = (DsAgencias.DatosRow[])ds.Datos.Select("UnidadNegocioID = " + this.UnidadNegocioID + " AND RazonSocial LIKE '" + this.txtRazonSocial.Text + "%'" + " AND ProvinciaDescrip LIKE '" + this.txtProvincia.Text + "%'", "RazonSocial");
            dtgAgencias.CurrentPageIndex = currentPage;
            dtgAgencias.DataBind();
        }
Exemplo n.º 38
0
        private void DataGrid1_pager(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
        {
            this.DataGrid1.CurrentPageIndex = e.NewPageIndex;
            ArrayList ColNew;

            ColNew = DocumentManager.getDataGridVersioni(this);

            DataGrid1.DataSource = ColNew;

            DataGrid1.DataBind();

            this.PerformActionSelectionFirstVersion();
        }
Exemplo n.º 39
0
        private void BindGrid()
        {
            DateTime fechaDesde = Convert.ToDateTime(txtFechaDesde.Text);
            DateTime fechaHasta = Convert.ToDateTime(txtFechaHasta.Text);

            AdministrarGrillas.Configurar(dtgPlanillas, "PlanillaRedespachoID", CantidadOpciones);
            IRecepcionRedespacho redespacho = RecepcionRedespachoFactory.GetRecepcionRedespacho();

            redespacho.AgenciaID          = AgenciaConectadaID;
            dtgPlanillas.CurrentPageIndex = Utiles.Validaciones.obtieneEntero(txtPagina.Text);
            dtgPlanillas.DataSource       = redespacho.GetDataSetPlanillaConsul(fechaDesde, fechaHasta, Utiles.Validaciones.obtieneEntero(txtOrden.Text)).Datos;
            dtgPlanillas.DataBind();
        }
Exemplo n.º 40
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            SqlConnection cnPubs = new SqlConnection("server=(local);uid=sa;pwd=;database=pubs");

            SqlDataAdapter daTitles = new SqlDataAdapter("select title, notes, price, pubdate from titles", cnPubs);

            DataSet dsTitles = new DataSet();

            daTitles.Fill(dsTitles, "titles");

            dgdTitles.DataSource = dsTitles.Tables["titles"].DefaultView;
            dgdTitles.DataBind();
        }
Exemplo n.º 41
0
        private void BindGrid(int currentPage)
        {
            SisPackController.AdministrarGrillas.Configurar(dtgLocalidades, "LocalidadID", this.CantidadOpciones);
            ILocalidad oLocalidad = LocalidadFactory.GetLocalidad();

            oLocalidad.LocalidadDescrip = this.txtLocalidadDescrip.Text;
            ///if (ddlProvincia.SelectedIndex > 0 )
            //	oLocalidad.Provincia.ProvinciaID = Convert.ToInt32(this.ddlProvincia.SelectedValue);
            oLocalidad.Provincia.ProvinciaDescrip = this.txtProvinciaDescrip.Text;
            dtgLocalidades.DataSource             = oLocalidad.GetLocalidadesConsultaDataSet();
            dtgLocalidades.CurrentPageIndex       = currentPage;
            dtgLocalidades.DataBind();
        }
Exemplo n.º 42
0
        protected void Buscar_Centros_Costo(string codempleado)
        {
            int     i;
            DataSet centrocosto = new DataSet();

            DBFunctions.Request(centrocosto, IncludeSchema.NO, "Select * from DBXSCHEMA.MEMPLEADOPCENTROCOSTO where memp_codiempl='" + codempleado + "' ORDER BY MEMP_CODIEMPL,PCEN_CODIGO");
            if (centrocosto.Tables[0].Rows.Count == 0)
            {
                Utils.MostrarAlerta(Response, "Este empleado no tiene ingresado ningun Centro de Costo");
                Session.Clear();
                gridRtns.DataSource = tablaRtns;
                gridRtns.DataBind();
            }
            else
            {
                for (i = 0; i < centrocosto.Tables[0].Rows.Count; i++)
                {
                    this.ingresar_datos_datatable(centrocosto.Tables[0].Rows[i][0].ToString(), centrocosto.Tables[0].Rows[i][3].ToString(), centrocosto.Tables[0].Rows[i][1].ToString(), double.Parse(centrocosto.Tables[0].Rows[i][2].ToString()));
                }
                Session["tablaRtns"] = tablaRtns;
            }
        }
        private void BindGrid()
        {
            IRecepcionRedespacho redespacho = RecepcionRedespachoFactory.GetRecepcionRedespacho();

            redespacho.AgenciaID = AgenciaConectadaID;
            AdministrarGrillas.Configurar(dtgPlanilla, "RedespachoID", CantidadOpciones);
            dtgPlanilla.CurrentPageIndex = Utiles.Validaciones.obtieneEntero(txtPagina.Text);
            DsPlanillaRedespacho ds = redespacho.GetDataSetPlanillaRedespacho();

            dtgPlanilla.DataSource          = ds.Detalle;
            Session["DsPlanillaRedespacho"] = ds;
            dtgPlanilla.DataBind();
        }
Exemplo n.º 44
0
 public override void ExecuteResult(ControllerContext context)
 {
     var Response = context.HttpContext.Response;
     Response.Buffer = true;
     Response.ContentType = "application/vnd.ms-excel";
     Response.AddHeader("Content-Disposition", "attachment;filename=CMSOrganizations.xls");
     Response.Charset = "";
     var d = m.OrganizationExcelList();
     var dg = new DataGrid();
     dg.DataSource = d;
     dg.DataBind();
     dg.RenderControl(new HtmlTextWriter(Response.Output));
 }
Exemplo n.º 45
0
        public void bind()
        {
            SqlConnection  con = new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);
            SqlDataAdapter da  = new SqlDataAdapter("Select * from Customers", con);
            DataTable      dt  = new DataTable("Customers");

            da.Fill(dt);
            if (DataGrid1.Attributes["SortOn"] != null)
            {
                dt.DefaultView.Sort = DataGrid1.Attributes["SortOn"];
            }
            BoundColumn col = new BoundColumn();

            col.ReadOnly   = true;
            col.HeaderText = "SL NO.";
            DataGrid1.Columns.AddAt(0, col);
            TemplateColumn col1 = new TemplateColumn();

            col1.ItemTemplate = LoadTemplate("ItemTemplate.ascx");
            col1.HeaderText   = "template - from ascx";
            DataGrid1.Columns.Add(col1);
            //E.Item.Cells[0].Text= E.Item.DataSetIndex + 1;
            //http://www.dotnetbips.com/displayarticle.aspx?id=84
            //http://www.dotnetbips.com/displayarticle.aspx?id=85
            TemplateColumn col2 = new TemplateColumn();

            col2.HeaderText   = "template - from code";
            col2.ItemTemplate = new CTemplateColumn("Customer_Name");
            DataGrid1.Columns.Add(col2);
            DataGrid1.DataSource = dt.DefaultView;
            //next 2 lines to check if the pageindex is greater than noof pages when records are deleted from DB
            double actualPageCount = Math.Ceiling(dt.Rows.Count / (double)DataGrid1.PageSize);

            if (DataGrid1.CurrentPageIndex >= actualPageCount)
            {
                DataGrid1.CurrentPageIndex = (int)actualPageCount - 1;
            }
            DataGrid1.DataBind();
        }
 private void BindGrid()
 {
     try
     {
         AdministrarGrillas.Configurar(dtgGuias, "GuiaID", CantidadOpciones);
         dtgGuias.DataSource = (DsGuias)Session["DsGuias"];
         dtgGuias.DataBind();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private void Page_Load(object sender, System.EventArgs e)
        {
            Utilities.CreateTableHeader(tableRetineriHeader, "Angajatii carora le expira diferite retineri in acesta luna", "", "normal");

            int angajatorId = int.Parse(Session["AngajatorId"].ToString());

            Salaries.Business.Luni luni     = new Salaries.Business.Luni(angajatorId);
            Salaries.Data.LunaData lunaData = luni.GetLunaActiva();

            if (!IsPostBack)
            {
                Salaries.Business.Angajat objAngajat = new Salaries.Business.Angajat();
                DataSet ds = objAngajat.GetAngajatiExpiraRetineri(lunaData.LunaId);

                Session["SortBy"] = "";
                Ind = 1;
                Session["DataSource_Retineri"] = ds;

                listDataGridAngajati.DataSource = ds;
                listDataGridAngajati.DataBind();
            }
        }
        private void CargarDetalles(string Au_id)
        {
            SqlConnection  conn  = new SqlConnection("Data Source=.;Initial Catalog=pubs;User ID=sa;Password=INWORX");
            SqlDataAdapter da_de = new SqlDataAdapter("select titleauthor.au_id, titles.* from titles, titleauthor " +
                                                      "where titles.title_id = titleauthor.title_id " +
                                                      "and au_id = '" + Au_id + "'", conn);
            DataSet ds = new DataSet();

            da_de.Fill(ds, "Libros");

            DataGrid1.DataSource = ds.Tables[0];
            DataGrid1.DataBind();
        }
Exemplo n.º 49
0
        public static void fillDataGrid(System.Web.UI.WebControls.DataGrid dg, string config, string sql)
        {
            string         ConnStr = ConfigurationManager.AppSettings[config];
            SqlConnection  cn      = new SqlConnection(ConnStr);
            SqlDataAdapter da      = new SqlDataAdapter(sql, cn);

            DataSet ds = new DataSet();

            da.Fill(ds, "datasetresult");

            dg.DataSource = ds.Tables["datasetresult"].DefaultView;
            dg.DataBind();
        }
Exemplo n.º 50
0
        public override void ExecuteResult(ControllerContext context)
        {
            var Response = context.HttpContext.Response;

            Response.Buffer = true;
            Response.ContentType = "application/vnd.ms-excel";
            Response.AddHeader("Content-Disposition", "attachment;filename=CMSStatusFlags.xls");
            Response.Charset = "";

            var collist = from ss in DbUtil.Db.ViewStatusFlagNamesRoles.ToList()
                          where ss.Role == null || HttpContext.Current.User.IsInRole(ss.Role)
                          select ss;

            IEnumerable<string> cq = null;

            if (flags.HasValue())
                cq = from f in flags.Split(',')
                     join c in collist on f equals c.Flag
                     select "\tss.{0} as [{0}_{1}]".Fmt(c.Flag, c.Name);
            else
                cq = from c in collist
                     where c.Role == null || HttpContext.Current.User.IsInRole(c.Role)
                     select "\tss.{0} as [{1}]".Fmt(c.Flag, c.Name);

            var tag = DbUtil.Db.PopulateSpecialTag(qid, DbUtil.TagTypeId_StatusFlags);
            var cols = string.Join(",\n", cq);
            var cn = new SqlConnection(Util.ConnectionString);
            cn.Open();
            var cmd = new SqlCommand(@"
            SELECT
            md.PeopleId,
            md.[First],
            md.[Last],
            md.Age,
            md.Marital,
            md.Decision,
            md.DecisionDt,
            md.JoinDt,
            md.Baptism,
            " + cols + @"
            FROM StatusFlagColumns ss
            JOIN MemberData md ON md.PeopleId = ss.PeopleId
            JOIN dbo.TagPerson tp ON tp.PeopleId = md.PeopleId
            WHERE tp.Id = @p1", cn);
            cmd.Parameters.AddWithValue("@p1", tag.Id);
            var rd = cmd.ExecuteReader();
            var dg = new DataGrid();
            dg.DataSource = rd;
            dg.DataBind();
            dg.RenderControl(new HtmlTextWriter(Response.Output));
        }
Exemplo n.º 51
0
        public static string Export(System.Data.DataTable dt, string fileName)
        {
            System.Web.UI.Page page = System.Web.HttpContext.Current.Handler as System.Web.UI.Page;

            StringWriter stringWriter = new StringWriter();
            HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
            DataGrid dGrid = new DataGrid();

            TableItemStyle alternatingStyle = new TableItemStyle();
            TableItemStyle headerStyle = new TableItemStyle();
            TableItemStyle itemStyle = new TableItemStyle();

            alternatingStyle.BackColor = Color.LightGray;

            headerStyle.BackColor = Color.LightGray;
            headerStyle.Font.Bold = true;
            headerStyle.HorizontalAlign = HorizontalAlign.Center;

            itemStyle.HorizontalAlign = HorizontalAlign.Center;

            dGrid.GridLines = GridLines.Both;

            dGrid.HeaderStyle.MergeWith(headerStyle);
            dGrid.HeaderStyle.Font.Bold = true;

            dGrid.AlternatingItemStyle.MergeWith(alternatingStyle);
            dGrid.ItemStyle.MergeWith(itemStyle);

            dGrid.DataSource = dt.DefaultView;
            dGrid.DataBind();
            dGrid.RenderControl(htmlWriter);

            string filePath = Path.Combine(excelFullFolder, fileName + ext);
            if (System.IO.File.Exists(filePath))
            {
                System.IO.File.Delete(filePath);
            }
            StreamWriter sw = new StreamWriter(filePath, false, System.Text.Encoding.UTF8);
            sw.Write(stringWriter.ToString());
            sw.Close();

            int pos = page.Request.Url.ToString().LastIndexOf(page.Request.Path);

            string fileUrl = page.Request.Url.ToString().Substring(0, pos);
            fileUrl += page.Request.ApplicationPath + excelFolder.Replace("\\", "/") + fileName + ext;
            HttpContext.Current.Response.Redirect(fileUrl);

            return fileUrl;
        }
        protected void btnReport_Click(object sender, EventArgs e)
        {
            LogicaNegocio.AconpanaClase aconpanaClase = new LogicaNegocio.AconpanaClase();
               // List<ModeloNegocio.Asesor> listUsuario = new List<ModeloNegocio.Asesor>();

            // NOW ASSIGN DATA TO A DATAGRID.
            DataGrid dg = new DataGrid();
            dg.DataSource = aconpanaClase.getReportAllAconpanaClase();
            dg.DataBind();

            // THE EXCEL FILE.
            string sFileName = "Segui-Clase-" + System.DateTime.Now.Date + "-.xls";
            sFileName = sFileName.Replace("/", "");

            // SEND OUTPUT TO THE CLIENT MACHINE USING "RESPONSE OBJECT".
            Encoding encoding = Encoding.UTF8;
            Response.ClearContent();
            Response.Buffer = true;
            //Response.Charset = encoding.EncodingName;
            //Response.ContentEncoding = System.Text.Encoding.UTF8;

            Response.Charset = encoding.EncodingName ;
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("Windows-1252");
            Response.AddHeader("content-disposition", "attachment; filename=" + sFileName);
            Response.ContentType = "application/vnd.ms-excel";
            //Response.ContentType = "application/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            //Response.AppendHeader("content-disposition", "attachment; filename=myfile.xlsx");
            EnableViewState = false;

            System.IO.StringWriter objSW = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter objHTW = new System.Web.UI.HtmlTextWriter(objSW);

            dg.HeaderStyle.Font.Bold = true;     // SET EXCEL HEADERS AS BOLD.
            dg.HeaderStyle.ForeColor = Color.White;
            dg.HeaderStyle.BackColor = Color.Blue;

            dg.RenderControl(objHTW);

            // STYLE THE SHEET AND WRITE DATA TO IT.
            Response.Write("<style> TABLE { border:solid 1px #999; } " +
                "TD { border:solid 1px #000000; text-align:center } </style>");
            Response.Write(objSW.ToString());

            // ADD A ROW AT THE END OF THE SHEET SHOWING A RUNNING TOTAL OF PRICE.
            //Response.Write("<table><tr><td><b>Total: </b></td><td></td><td><b>" +
            //dTotalPrice.ToString("N2") + "</b></td></tr></table>");

            Response.End();
        }
Exemplo n.º 53
0
        public void RunTestWithoutDI()
        {
            DataView dv = CreateDataSource();

            int runs = 1000;

            StopWatch watch = new StopWatch();
            using (watch.Start("Duration: {0}"))
            {
                for (int i = 0; i < runs; i++)
                {
                    DataGrid grid = new DataGrid();
                    grid.DataSource = dv;
                    grid.DataBind();
                }
            }
        }
Exemplo n.º 54
0
        public void DataTableToExcel(System.Data.DataTable dtData)
        {
            string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls";
            System.Web.UI.WebControls.DataGrid dgExport = null;
            // ��ǰ�Ի�
            System.Web.HttpContext curContext = System.Web.HttpContext.Current;
            // IO���ڵ���������excel�ļ�
            System.IO.StringWriter strWriter = null;
            System.Web.UI.HtmlTextWriter htmlWriter = null;
            if (dtData != null)
            {
                // ���ñ���͸�����ʽ
                //Response.ContentTypeָ���ļ����� ����Ϊapplication/ms-excel��application/ms-word��application/ms-txt��application/ms-html
                curContext.Response.ContentType = "application/vnd.ms-excel";
                curContext.Response.ContentEncoding = System.Text.Encoding.UTF8;
                System.Web.HttpContext.Current.Response.Charset = "GB2312";
                //�������к���Ҫ�� attachment ������ʾ��Ϊ�������أ������Ըij� online���ߴ�
                //filename=FileFlow.xls ָ������ļ������ƣ�ע������չ����ָ���ļ��������������Ϊ��.doc  .xls .txt��.htm����

                System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(filename, Encoding.GetEncoding("utf-8")));
                //    curContext.Response.Charset = "";

                // ����excel�ļ�
                strWriter = new System.IO.StringWriter();
                htmlWriter = new System.Web.UI.HtmlTextWriter(strWriter);

                // Ϊ�˽��dgData�п��ܽ����˷�ҳ���������Ҫ���¶���һ���޷�ҳ��DataGrid
                dgExport = new System.Web.UI.WebControls.DataGrid();

                dgExport.DataSource = dtData.DefaultView;
                dgExport.AllowPaging = false;

                //���֤�ŵĴ���Ĺؼ��ڴ��¼�

                dgExport.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(gridHrInfo_ItemDataBound1);

                dgExport.DataBind();

                // ���ؿͻ���
                dgExport.RenderControl(htmlWriter);
                curContext.Response.Write(strWriter.ToString());
                //curContext.flush();
                curContext.Response.End();
            }
        }
Exemplo n.º 55
0
        //Exporting to Excel
        public void ExportToExcel(DataTable dt)
        {
            if (dt.Rows.Count > 0)
            {

                string filename = "ClientJobs.xls";

                string excelHeader = "Report generated by :" + strArrUser[0].ToString() + " ";

                System.IO.StringWriter tw = new System.IO.StringWriter();

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

                DataGrid dgGrid = new DataGrid();

                dgGrid.DataSource = dt;

                dgGrid.DataBind();

                dgGrid.HeaderStyle.BackColor = System.Drawing.Color.LightBlue;
                dgGrid.HeaderStyle.Font.Bold = true;
                dgGrid.GridLines = GridLines.Both;

                // Report Header

                /*arivu*/
                hw.WriteLine("<table>");
                hw.WriteLine("<tr><td><b><u><font size=’3′> " + excelHeader + " </font></u></b></td></tr>");
                hw.WriteLine("<tr><td><b><u><font size=’3′> " + "Client Type:" + lbClientType.Text.ToUpper() + " </font></u></b></td><td><b><u><font size=’3′> " + "Client Name:" + lbClientName.Text.ToUpper() + " </font></u></b></td>");
                hw.WriteLine("</table>");
                /**/

                //Get the HTML for the control.
                dgGrid.RenderControl(hw);

                Response.ContentType = "application/vnd.ms-excel";
                Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename + "");

                //this.EnableViewState = false;
                Response.Write(tw.ToString());
                Response.End();

            }
        }
Exemplo n.º 56
0
        protected override void RenderContents(HtmlTextWriter writer)
        {
            base.RenderContents(writer);

            String sql = "select * from Vendors";
            SqlConnection conn = new SqlConnection("Data Source=ABCUNIVERSITY\\SHAREPOINT;Initial Catalog=ABCPurchasing;User Id=dbu;Password=test");
            DataSet ds = new DataSet("root");
            SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
            sda.Fill(ds, "Vendors");
            grid = new DataGrid();
            grid.HeaderStyle.CssClass = "msh-vh2";
            grid.CellPadding = 2;
            grid.DataSource = ds;
            grid.DataMember = "Vendors";
            grid.DataBind();

            Controls.Add(grid);
            grid.RenderControl(writer);
        }
Exemplo n.º 57
0
        public void Test_DataGrid()
        {
            PrecisionModel pm = new PrecisionModel(100000,0,0);
            GeometryFactory geometryFactory = new GeometryFactory(pm,-1);

            string filename= Global.GetUnitTestRootDirectory()+@"\IO\Shapefile\Testfiles\statepop";
            ShapefileDataReader shpDataReader = Geotools.IO.Shapefile.CreateDataReader(filename, geometryFactory);

            // make sure the datagrid gets the column headings.
            DataGrid grid = new DataGrid();
            grid.DataSource = shpDataReader;
            grid.DataBind();

            TextWriter tempWriter = new StringWriter();
            grid.RenderControl(new HtmlTextWriter(tempWriter));
            string html = tempWriter.ToString();
            bool same = Compare.CompareAgainstString(Global.GetUnitTestRootDirectory()+@"\IO\Shapefile\Testfiles\ExpectedDataGridDataReader.txt",html);
            Assertion.AssertEquals("Datagrid properties",true,same);
        }
Exemplo n.º 58
0
        public override void ExecuteResult(ControllerContext context)
        {
            var Response = context.HttpContext.Response;

            Response.Buffer = true;
            Response.ContentType = "application/vnd.ms-excel";
            Response.AddHeader("Content-Disposition", "attachment;filename=CMSPeople.xls");
            Response.Charset = "";

            var q = from p in DbUtil.Db.PeopleQuery(qid)
                    let p2 = p.Family.People.FirstOrDefault(pp => pp.PositionInFamilyId == 10 && pp.PeopleId != p.PeopleId)
                    let name = DbUtil.Db.PeopleExtras.SingleOrDefault(ee => ee.Field == "name" && ee.PeopleId == p.PeopleId).Data
                    let web = DbUtil.Db.PeopleExtras.SingleOrDefault(ee => ee.Field == "web" && ee.PeopleId == p.PeopleId).Data

                    select new
                    {
                        Organization = name != "name" ? name : p.LastName,
                        FirstName = p2.PreferredName,
                        p2.LastName,
                        Email = p2.EmailAddress,
                        Street = p.PrimaryAddress,
                        Street2 = p.PrimaryAddress2,
                        City = p.PrimaryCity,
                        Province = p.PrimaryState,
                        Country = "USA",
                        PostalCode = p.PrimaryZip,
                        BusPhone = p.WorkPhone.FmtFone(),
                        MobPhone = p2.CellPhone.FmtFone(),
                        Fax = "",
                        SecStreet = p.AddressLineOne,
                        SecStreet2 = p.AddressLineTwo,
                        SecCity = p.CityName,
                        SecProvince = p.StateCode,
                        SecCountry = "USA",
                        SecPostalCode = p.ZipCode,
                        Notes = "DbName: " + p.LastName + "\nWeb:" + web
                    };
            var dg = new DataGrid();
            dg.DataSource = q;
            dg.DataBind();
            dg.RenderControl(new HtmlTextWriter(Response.Output));
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create a DataTable object and set it as DataSource of DataGrid.
            DataTable dataTable = new DataTable("Products");
            dataTable.Columns.Add("Product ID", typeof(Int32));
            dataTable.Columns.Add("Product Name", typeof(string));
            dataTable.Columns.Add("Units In Stock", typeof(Int32));
            DataRow dr = dataTable.NewRow();
            dr[0] = 1;
            dr[1] = "Aniseed Syrup";
            dr[2] = 15;
            dataTable.Rows.Add(dr);
            dr = dataTable.NewRow();
            dr[0] = 2;
            dr[1] = "Boston Crab Meat";
            dr[2] = 123;
            dataTable.Rows.Add(dr);

            // Now take care of DataGrid
            DataGrid dg = new DataGrid();
            dg.DataSource = dataTable;
            dg.DataBind();

            // We have a DataGrid object with some data in it.
            // Lets import it into our spreadsheet

            // Creat a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            // Importing the contents of the data grid to the worksheet
            worksheet.Cells.ImportDataGrid(dg, 0, 0, false);

            // Save it as Excel file
            workbook.Save(dataDir + "output.xlsx");
            // ExEnd:1
        }
Exemplo n.º 60
0
        public override void ExecuteResult(ControllerContext context)
        {
            var Response = context.HttpContext.Response;
            Response.Buffer = true;
            Response.ContentType = "application/vnd.ms-excel";
            Response.AddHeader("Content-Disposition", "attachment;filename=CMSTasks.xls");
            Response.Charset = "";

            var q = DbUtil.Db.PeopleQuery(qid);
            var q2 = from p in q
                     let t = p.TasksAboutPerson.OrderByDescending(t => t.CreatedOn).FirstOrDefault(t => t.Notes != null)
                     where t != null
                     select new
                     {
                         p.Name,
                         t.Notes,
                         t.CreatedOn
                     };
            var dg = new DataGrid();
            dg.DataSource = q2;
            dg.DataBind();
            dg.RenderControl(new HtmlTextWriter(Response.Output));
        }