Example #1
0
        public static System.IO.StringWriter CreateExcel_HTML(
            DataTable Dt
            , ClsExcel_Columns Columns)
        {
            System.IO.StringWriter          Sw  = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter    Htw = new System.Web.UI.HtmlTextWriter(Sw);
            System.Web.UI.WebControls.Table Tb  = new System.Web.UI.WebControls.Table();

            System.Web.UI.WebControls.TableRow Tbr_Header = new System.Web.UI.WebControls.TableRow();
            foreach (ClsExcel_Columns.Str_Columns?Obj in Columns.pObj)
            {
                System.Web.UI.WebControls.TableCell Tbc = new System.Web.UI.WebControls.TableCell();
                Tbc.Text = Obj.Value.FieldDesc;
                Tbr_Header.Cells.Add(Tbc);
            }

            Tb.Rows.Add(Tbr_Header);

            foreach (DataRow Dr in Dt.Rows)
            {
                System.Web.UI.WebControls.TableRow Tbr = new System.Web.UI.WebControls.TableRow();
                foreach (ClsExcel_Columns.Str_Columns?Obj in Columns.pObj)
                {
                    System.Web.UI.WebControls.TableCell Tbc = new System.Web.UI.WebControls.TableCell();
                    Tbc.Text = Dr[Obj.Value.FieldName].ToString();
                    Tbr.Cells.Add(Tbc);
                }
                Tb.Rows.Add(Tbr);
            }
            Tb.RenderControl(Htw);
            return(Sw);
        }
        public static void Export(string fileName, GridView gv)
        {
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.AddHeader(
            "content-disposition", string.Format("attachment; filename={0}", fileName));
            HttpContext.Current.Response.ContentType = "application/ms-excel";

            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    Table table = new Table();
                    if (gv.HeaderRow != null)
                    {
                        table.Rows.Add(gv.HeaderRow);
                    }

                    foreach (GridViewRow row in gv.Rows)
                    {
                        GridViewExportUtil.PrepareControlForExport(row);
                        table.Rows.Add(row);
                    }
                    if (gv.FooterRow != null)
                    {
                        GridViewExportUtil.PrepareControlForExport(gv.FooterRow);
                        table.Rows.Add(gv.FooterRow);
                    }
                    table.RenderControl(htw);
                    HttpContext.Current.Response.Write(sw.ToString());
                    HttpContext.Current.Response.End();
                }
            }
        }
 public override string GetDesignTimeHtml()
 {
     var style = new TableStyle();
     var table = new Table();
     var component = Component as DeluxeSearch;
     var writer = new StringWriter();
     var html = new HtmlTextWriter(writer);
     if (null != component)
     {
         if (component.Categories.Count > 0)
         {
             foreach (var item in component.Categories)
             {
                 var cell = new TableCell();
                 var row = new TableRow();
                 cell.Text = string.Format("{0}:{1}", item.DataTextField, item.DataSourceID);
                 row.Cells.Add(cell);
                 table.Rows.Add(row);
             }
         }
         else
         {
             var cell = new TableCell();
             var row = new TableRow();
             cell.Text = component.ID;
             row.Cells.Add(cell);
             table.Rows.Add(row);
         }
         table.ApplyStyle(style);              
         table.RenderControl(html);
     }
     return writer.ToString();
 }
Example #4
0
 // ReSharper restore MemberCanBePrivate.Global
 // ReSharper restore UnaccessedField.Global
 public void loadBoardTable(Table theTable)
 {
     TextWriter ourTextWriter2 = new StringWriter();
     HtmlTextWriter ourHtmlWriter2 = new HtmlTextWriter(ourTextWriter2);
     theTable.RenderControl(ourHtmlWriter2);
     newBoardHTML = ourTextWriter2.ToString();
 }
        public static void ExportExcell(string fileName, GridView gv)
        {
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Buffer = true;

            HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));
            HttpContext.Current.Response.Charset = "";
            HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
            StringWriter sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            Table tb = new Table();
            TableRow tr1 = new TableRow();
            TableCell cell1 = new TableCell();
            cell1.Controls.Add(gv);
            tr1.Cells.Add(cell1);

            TableCell cell2 = new TableCell();
            cell2.Text = " ";

            TableRow tr2 = new TableRow();
            tr2.Cells.Add(cell2);

            tb.Rows.Add(tr1);
            tb.Rows.Add(tr2);

            tb.RenderControl(hw);

            //style to format numbers to string
            string style = @"<style> .textmode { mso-number-format:\@; } </style>";
            HttpContext.Current.Response.Write(style);
            HttpContext.Current.Response.Output.Write(sw.ToString());
            HttpContext.Current.Response.Flush();
            HttpContext.Current.Response.End();
        }
Example #6
0
    protected void btn_exportarExcel_Click(object sender, EventArgs e)
    {
        DataView view = new DataView();

        view.Table = (DataTable)ViewState["lista"];
        GridView gv = new GridView();

        gv.DataSource = view;
        gv.DataBind();

        string fileName = "rutas_generadas.xls";

        PrepareControlForExport(gv);
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.AddHeader("Content-type", "application / xls");

        HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));
        HttpContext.Current.Response.Charset = "";
        HttpContext.Current.Response.Cache.SetCacheability(System.Web.HttpCacheability.Public);
        HttpContext.Current.Response.ContentType = "application/ms-excel";
        try
        {
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    System.Web.UI.WebControls.Table table = new System.Web.UI.WebControls.Table();
                    table.GridLines = gv.GridLines;

                    if (gv.HeaderRow != null)
                    {
                        PrepareControlForExport(gv.HeaderRow);
                        table.Rows.Add(gv.HeaderRow);
                    }

                    foreach (GridViewRow row in gv.Rows)
                    {
                        PrepareControlForExport(row);
                        table.Rows.Add(row);
                    }

                    if (gv.FooterRow != null)
                    {
                        PrepareControlForExport(gv.FooterRow);
                        table.Rows.Add(gv.FooterRow);
                    }

                    gv.GridLines = GridLines.Both;
                    table.RenderControl(htw);
                    HttpContext.Current.Response.Write(sw.ToString());
                    HttpContext.Current.Response.End();
                }
            }
        }
        catch (HttpException ex)
        {
            throw ex;
        }
    }
Example #7
0
        public IHtmlString RenderBody()
        {
            var table        = new System.Web.UI.WebControls.Table();
            var stringWriter = new StringWriter();

            table.Rows.AddRange(GenerateTBody().ToArray());
            table.RenderControl(new HtmlTextWriter(stringWriter));
            return(new HtmlString(stringWriter.ToString()));
        }
    /// <summary>
    /// This Method Exports The Given Grid View to Excel File Without Formatting
    /// </summary>
    /// <returns>Excel File</returns>
    public static void ExporttoExcel_Withoutformatting(GridView gv)
    {
        try
        {
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename=cgnicin.xls"));
            HttpContext.Current.Response.ContentType = "application/ms-excel";
            gv.AllowPaging = false;
            gv.DataBind();
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    //  Create a form to contain the grid
                    System.Web.UI.WebControls.Table table = new System.Web.UI.WebControls.Table();
                    table.GridLines    = GridLines.Both;
                    table.CaptionAlign = TableCaptionAlign.Right;
                    table.Caption      = "Generated By http://cg.nic.in on " + System.DateTime.Now.ToString("dd MMMM yyyy") + " at " + System.DateTime.Now.ToString("h:mm:ss tt");
                    //  add the header row to the table
                    if (gv.HeaderRow != null)
                    {
                        PrepareControlForExport(gv.HeaderRow);
                        table.Rows.Add(gv.HeaderRow);
                    }

                    foreach (GridViewRow row in gv.Rows)
                    {
                        PrepareControlForExport(row);
                        table.Rows.Add(row);
                    }

                    //  add the footer row to the table
                    if (gv.FooterRow != null)
                    {
                        PrepareControlForExport(gv.FooterRow);
                        table.Rows.Add(gv.FooterRow);
                    }

                    //  render the table into the htmlwriter
                    table.RenderControl(htw);

                    //  render the htmlwriter into the response
                    HttpContext.Current.Response.Write(sw.ToString());
                    HttpContext.Current.Response.End();
                }
            }
        }
        catch (ThreadAbortException)
        {
        }
        catch (Exception e)
        {
            Gen_Error_Rpt.Write_Error("Class:Utilitie | Method: ExporttoExcel_Withoutformatting | Error:", e);
        }
    }
Example #9
0
        /// <summary>
        /// Gets the design time HTML code.
        /// </summary>
        /// <returns>A string containing the HTML to render.</returns>
        public override string GetDesignTimeHtml()
        {
            PagedControl pagerBuilder = (PagedControl)base.Component;

            StringBuilder stringBuilder = new StringBuilder();

            StringWriter   stringWriter = new StringWriter();
            HtmlTextWriter writer       = new HtmlTextWriter(stringWriter);

            // Initialize the structure.
            System.Web.UI.WebControls.Table     pagerPanel               = new System.Web.UI.WebControls.Table();
            System.Web.UI.WebControls.TableRow  pagerPanelRow            = new System.Web.UI.WebControls.TableRow();
            System.Web.UI.WebControls.TableCell pagerPanelInfoCell       = new System.Web.UI.WebControls.TableCell();
            System.Web.UI.WebControls.TableCell pagerPanelNavigationCell = new System.Web.UI.WebControls.TableCell();

            pagerPanelRow.Cells.Add(pagerPanelInfoCell);
            pagerPanelRow.Cells.Add(pagerPanelNavigationCell);

            pagerPanel.Rows.Add(pagerPanelRow);

            // Initialize structure appearance
            pagerPanel.ApplyStyle(pagerBuilder.PagerStyle);
            pagerPanel.Width           = pagerBuilder.Width;
            pagerPanel.Height          = pagerBuilder.Height;
            pagerPanel.HorizontalAlign = pagerBuilder.HorizontalAlign;

            pagerPanel.CellPadding = pagerBuilder.CellPadding;
            pagerPanel.CellSpacing = pagerBuilder.CellSpacing;

            pagerPanelRow.CssClass = pagerBuilder.PanelCssClass;

            //pagerBuilder.InfoPanelStyle.MergeWith(pagerBuilder.PagerStyle);
            //pagerPanelInfoCell.ApplyStyle(pagerBuilder.InfoPanelStyle);
            pagerPanelInfoCell.ApplyStyle(pagerBuilder.PagerStyle);
            pagerPanelInfoCell.HorizontalAlign = pagerBuilder.InfoPanelHorizontalAlign;
            pagerPanelInfoCell.VerticalAlign   = pagerBuilder.InfoPanelVerticalAlign;
            pagerPanelInfoCell.Visible         = !pagerBuilder.InfoPanelDisabled;

            //pagerBuilder.NavPanelStyle.MergeWith(pagerBuilder.PagerStyle);
            //pagerPanelNavigationCell.ApplyStyle(pagerBuilder.NavPanelStyle);
            pagerPanelNavigationCell.ApplyStyle(pagerBuilder.PagerStyle);
            pagerPanelNavigationCell.HorizontalAlign = pagerBuilder.NavPanelHorizontalAlign;
            pagerPanelNavigationCell.VerticalAlign   = pagerBuilder.NavPanelVerticalAlign;

            // Initialize the info panel
            pagerBuilder.BuildInfo(pagerPanelInfoCell, true);

            // Initialize the navigation panel
            pagerBuilder.BuildNavigation(pagerPanelNavigationCell);

            // Add the whole structure to the control collection
            pagerPanel.RenderControl(writer);

            return(stringWriter.ToString());
        }
        public static void Export(string fileName, GridView gv, HttpResponse response)
        {
            gv.AllowPaging = false;
            gv.DataBind();
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.AddHeader(
                "content-disposition", string.Format("attachment; filename=" + fileName + ".xls"));
            HttpContext.Current.Response.Charset = "";
            HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";

            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    //  Create a form to contain the grid
                    Table table = new Table();

                    //  add the header row to the table
                    if (gv.HeaderRow != null)
                    {
                        PrepareControlForExport(gv.HeaderRow);
                        table.Rows.Add(gv.HeaderRow);
                    }

                    //  add each of the data rows to the table
                    foreach (GridViewRow row in gv.Rows)
                    {
                        PrepareControlForExport(row);
                        table.Rows.Add(row);
                    }

                    //  add the footer row to the table
                    if (gv.FooterRow != null)
                    {
                        PrepareControlForExport(gv.FooterRow);
                        table.Rows.Add(gv.FooterRow);
                    }

                    //  render the table into the htmlwriter
                    table.RenderControl(htw);

                    //  render the htmlwriter into the response
                    HttpContext.Current.Response.Write(sw.ToString());
                    HttpContext.Current.Response.Flush();
                    HttpContext.Current.Response.End();
                }
            }
        }
 protected override void Render(HtmlTextWriter output)
 {
     double num4 = this.TableWidth.Value;
     double num = Math.Round((double) ((70.0 * num4) / 100.0));
     double num2 = Math.Round((double) ((this.RatingPercent * num) / 100.0));
     double num3 = Math.Round((double) (num - num2));
     Table child = new Table();
     TableRow row = new TableRow();
     TableRow row2 = new TableRow();
     TableCell cell = new TableCell();
     TableCell cell2 = new TableCell();
     TableCell cell3 = new TableCell();
     row2.ControlStyle.CopyFrom(this.ItemStyle);
     cell.ColumnSpan = 2;
     if (this.Rating == 0.0)
     {
         cell.Text = string.Format(ResourceManager.GetString("RatingResults"), this.Rating, this.MaxRating);
     }
     else
     {
         cell.Text = string.Format(ResourceManager.GetString("RatingResults"), this.Rating.ToString("##.##"), this.MaxRating);
     }
     row2.Cells.Add(cell);
     child.Rows.Add(row2);
     cell3.ControlStyle.Font.Size = FontUnit.XXSmall;
     cell3.Text = "&nbsp;" + this.MaxRating.ToString();
     child.CellPadding = 0;
     child.CellSpacing = 3;
     child.BorderWidth = 0;
     child.Width = Unit.Pixel((int) num);
     System.Web.UI.WebControls.Image image = new System.Web.UI.WebControls.Image();
     image.ImageUrl = GlobalConfig.ImagesPath + "PositiveRatingBar.gif";
     image.Width = Unit.Pixel((int) num2);
     image.Height = 12;
     cell2.Controls.Add(image);
     image = new System.Web.UI.WebControls.Image();
     image.ImageUrl = GlobalConfig.ImagesPath + "NegativeRatingBar.gif";
     image.Width = Unit.Pixel((int) num3);
     image.Height = 12;
     cell2.Controls.Add(image);
     row.ControlStyle.CopyFrom(this.ItemStyle);
     row.Cells.Add(cell2);
     row.Cells.Add(cell3);
     child.Controls.Add(row);
     this.Controls.Add(child);
     child.RenderControl(output);
 }
Example #12
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="gv"></param>
        public static void Export(string fileName, GridView gv)
        {
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.AddHeader(
                "content-disposition", string.Format("attachment; filename={0}", fileName));
            HttpContext.Current.Response.ContentType = "application/ms-excel";

            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    //  Create a table to contain the grid
                    Table table = new Table();

                    //  include the gridline settings
                    table.GridLines = gv.GridLines;

                    //  add the header row to the table
                    if (gv.HeaderRow != null)
                    {
                        GridViewExportUtil.PrepareControlForExport(gv.HeaderRow);
                        table.Rows.Add(gv.HeaderRow);
                    }

                    //  add each of the data rows to the table
                    foreach (GridViewRow row in gv.Rows)
                    {
                        GridViewExportUtil.PrepareControlForExport(row);
                        table.Rows.Add(row);
                    }

                    //  add the footer row to the table
                    if (gv.FooterRow != null)
                    {
                        GridViewExportUtil.PrepareControlForExport(gv.FooterRow);
                        table.Rows.Add(gv.FooterRow);
                    }

                    //  render the table into the htmlwriter
                    table.RenderControl(htw);

                    //  render the htmlwriter into the response
                    HttpContext.Current.Response.Write(sw.ToString());
                    HttpContext.Current.Response.End();
                }
            }
        }
Example #13
0
        public static void Export(string fileName, GridView gv)
        {
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.AddHeader(
                "content-disposition", string.Format("attachment; filename={0}", fileName));
            HttpContext.Current.Response.ContentType = "application/ms-excel";
            //HttpContext.Current.Response.Charset = "utf-8";

            using (var sw = new StringWriter())
            {
                using (var htw = new HtmlTextWriter(sw))
                {
                    //  Create a form to contain the grid
                    var table = new Table
                    {
                        GridLines = GridLines.Both  //单元格之间添加实线
                    };

                    //  add the header row to the table
                    if (gv.HeaderRow != null)
                    {
                        PrepareControlForExport(gv.HeaderRow);
                        table.Rows.Add(gv.HeaderRow);
                    }

                    //  add each of the data rows to the table
                    foreach (GridViewRow row in gv.Rows)
                    {
                        PrepareControlForExport(row);
                        table.Rows.Add(row);
                    }

                    //  add the footer row to the table
                    if (gv.FooterRow != null)
                    {
                        PrepareControlForExport(gv.FooterRow);
                        table.Rows.Add(gv.FooterRow);
                    }

                    //  render the table into the htmlwriter
                    table.RenderControl(htw);
                    //  render the htmlwriter into the response
                    HttpContext.Current.Response.Write(sw.ToString());
                    HttpContext.Current.Response.End();
                }
            }
        }
 protected override void Render(HtmlTextWriter output)
 {
     double num4 = this.TableWidth.Value;
     double num = Math.Round((double) ((70.0 * num4) / 100.0));
     double num2 = Math.Round((double) ((this.Progress * num) / 100.0));
     double num3 = Math.Round((double) (num - num2));
     Table child = new Table();
     TableRow row = new TableRow();
     TableCell cell = new TableCell();
     child.CellPadding = 0;
     child.CellSpacing = 0;
     child.BorderWidth = 0;
     child.Width = Unit.Pixel((int) num);
     Image image = new Image();
     if (this.BarColor == null)
     {
         image.ImageUrl = GlobalConfig.ImagesPath + "bar/BarOn_red.gif";
     }
     else
     {
         image.ImageUrl = GlobalConfig.ImagesPath + "bar/BarOn_" + this.BarColor + ".gif";
     }
     image.Width = Unit.Pixel((int) num2);
     image.Height = 14;
     cell.Controls.Add(image);
     image = new Image();
     image.ImageUrl = GlobalConfig.ImagesPath + "bar/BarOff.gif";
     image.Width = Unit.Pixel((int) num3);
     image.Height = 14;
     cell.Controls.Add(image);
     row.ControlStyle.CopyFrom(this.ItemStyle);
     row.Cells.Add(cell);
     cell = new TableCell();
     if (this.Progress == 0)
     {
         cell.Text = "&nbsp;&nbsp;0%";
     }
     else
     {
         cell.Text = "&nbsp;&nbsp;" + this.Progress.ToString("##.##") + "%";
     }
     cell.HorizontalAlign = HorizontalAlign.Right;
     row.Cells.Add(cell);
     child.Controls.Add(row);
     this.Controls.Add(child);
     child.RenderControl(output);
 }
Example #15
0
        /// <summary>
        /// Generates the table.
        /// </summary>
        /// <param name="cssClass">The CSS class.</param>
        /// <returns>HtmlString.</returns>
        /// <exception cref="System.Exception"></exception>
        public HtmlString GenerateTable(string cssClass = "")
        {
            var classname = !string.IsNullOrWhiteSpace(cssClass) ? string.Format("table {0}", cssClass) : "table";
            var table     = new System.Web.UI.WebControls.Table
            {
                CssClass = classname
            };

            #region Generate THEAD

            table.Rows.Add(GenerateTHead());

            #endregion

            #region Generate TBODY

            var rows = GenerateTBody();
            foreach (var row in rows)
            {
                table.Rows.Add(row);
            }

            #endregion

            #region Generate TFOOT

            //table.Rows.Add(GenerateTFoot());

            #endregion

            try
            {
                var strWriter = new StringWriter();
                table.RenderControl(new HtmlTextWriter(strWriter));
                var html = new HtmlString(strWriter.ToString());
                return(html);
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Problems generating table. Exception: {0}{2}, Message: {1}{2}", ex, ex.Message, Environment.NewLine));
            }
        }
Example #16
0
    public static void Export(string fileName, GridView gv)
    {
        string style = @"<style> .text { mso-number-format:\@; } </style> ";

        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.AddHeader(
            "content-disposition", string.Format("attachment; filename={0}", fileName));
        HttpContext.Current.Response.ContentType = "application/ms-excel";

        using (StringWriter sw = new StringWriter())
        {
            using (HtmlTextWriter htw = new HtmlTextWriter(sw))
            {
                System.Web.UI.WebControls.Table tbl = new System.Web.UI.WebControls.Table();

                if (gv.HeaderRow != null)
                {
                    PrepareControlForExport(gv.HeaderRow);
                    tbl.Rows.Add(gv.HeaderRow);
                }

                foreach (GridViewRow row in gv.Rows)
                {
                    PrepareControlForExport(row);
                    tbl.Rows.Add(row);
                }

                if (gv.FooterRow != null)
                {
                    PrepareControlForExport(gv.FooterRow);
                    tbl.Rows.Add(gv.FooterRow);
                }

                tbl.RenderControl(htw);
                HttpContext.Current.Response.Write(style);
                HttpContext.Current.Response.Write(sw.ToString());
                HttpContext.Current.Response.End();
            }
        }
    }
        /// <summary>
        /// 将此控件呈现给指定的输出参数。
        /// </summary>
        /// <param name="writer"> 要写出到的 HTML 编写器 </param>
        private void Render_TopToBottom(HtmlTextWriter writer)
        {
            this.RenderBeginTag(writer);
            if (this.Htmls.Count > 0)
            {
                System.Web.UI.WebControls.Table tableArray = new System.Web.UI.WebControls.Table();
                tableArray.Width       = System.Web.UI.WebControls.Unit.Parse("100%");
                tableArray.BorderWidth = System.Web.UI.WebControls.Unit.Parse("0px");
                tableArray.CellPadding = 0;
                tableArray.CellSpacing = 0;
                for (int i = 0; i < this.Htmls.Count; i++)
                {
                    System.Web.UI.WebControls.TableRow trowArray = new System.Web.UI.WebControls.TableRow();
                    tableArray.Rows.Add(trowArray);
                    System.Web.UI.WebControls.TableCell tc = new System.Web.UI.WebControls.TableCell();
                    tc.Text = this.Htmls[i];
                    trowArray.Cells.Add(tc);
                    if (this.Interval != System.Web.UI.WebControls.Unit.Empty)//插入 HTML 代码块 之间的间隔距离。
                    {
                        System.Web.UI.WebControls.TableRow sptrowArray = new System.Web.UI.WebControls.TableRow();
                        tableArray.Rows.Add(sptrowArray);
                        System.Web.UI.WebControls.TableCell sptc = new System.Web.UI.WebControls.TableCell();
                        sptc.Text = "<div style=\"HEIGHT:" + this.Interval.ToString() + "\" />";
                        sptrowArray.Cells.Add(sptc);
                    }
                }
                System.IO.StringWriter       sw  = new System.IO.StringWriter();
                System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw);
                tableArray.RenderControl(htw);
                writer.Write(sw.ToString());
            }

            writer.Write(@"<script type=""text/javascript"">
HtmlRotator('" + this.ClientID + @"', 3, " + this.PlaySpeed.ToString() + @", " + this.PauseTime.ToString() + ", " + this.StopOnMouseOver.ToString().ToLower() + @");
</script>
");

            this.RenderEndTag(writer);
        }
Example #18
0
        //public
        /// <summary> 
        /// Render this control to the output parameter specified.
        /// </summary>
        /// <param name="output"> The HTML writer to write out to </param>
        protected override void Render(HtmlTextWriter output)
        {
            if (Context.User.Identity.IsAuthenticated)
              {
            NdiMenuItem item0 =
              new NdiMenuItem(0, "Felhasználói adatok", "Felhasználói adatok", "UserData.aspx", "_images/userdataS.gif",
                          "_images/userdataL.gif");
            NdiMenuItem item1 =
              new NdiMenuItem(1, "Felhasználói adatok módosítása", "Felhasználói adatok módosítása", "UserDataModify.aspx",
                          "_images/userdataModS.gif",
                          "_images/userdataModL.gif");
            NdiMenuItem item2 =
              new NdiMenuItem(2, "Jelszó változtatás", "Jelszó változtatás", "UserPassword.aspx", "_images/passChangeS.gif",
                          "_images/passChangeL.gif");

            Table table = new Table();
            table.CellPadding = 0;
            table.CellSpacing = 0;
            table.CssClass = "almenu";
            TableRow row1 = new TableRow();

            TableCell cell0 = CreateCell(item0);

            TableCell cell2 = CreateCell(item2);
            TableCell cell1 = CreateCell(item1);

            table.Rows.Add(row1);
            row1.Cells.Add(cell0);

            row1.Cells.Add(cell1);
            row1.Cells.Add(cell2);
            table.Width = Unit.Percentage(100);

            table.RenderControl(output);
              }
        }
        public void ExportToExcel(string column, string order)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-us");// Thread.CurrentThread.CurrentUICulture;

            GridView grdProductList = new GridView();

            grdProductList.AutoGenerateColumns = false;

            #region Columns
            BoundField bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "SaleOrderCode";
            bf.HeaderText      = "OV";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "PurchaseOrderItemCode";
            bf.HeaderText      = "Producto";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "PurchaseOrderCode";
            bf.HeaderText      = "OC";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "Quantity";
            bf.HeaderText      = "Cantidad";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "CustomerCode";
            bf.HeaderText      = "Cliente";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "GAP";
            bf.HeaderText      = "GAP";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "WayOfDelivery";
            bf.HeaderText      = "Modo Envio";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "SaleOrderDeliveryDate";
            bf.HeaderText      = "Entrega OV";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "PurchaseOrderArrivalDate";
            bf.HeaderText      = "Llegada OC";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "OrderDate";
            bf.HeaderText      = "Creaci&oacute;n";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);
            #endregion

            if (!string.IsNullOrEmpty(column))
            {
                grdProductList.DataSource = ShowAlert(column, order);
            }
            else
            {
                grdProductList.DataSource = ShowAlert4();
            }

            grdProductList.DataBind();

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename=OVNoCumplimentadas.xls"));
            HttpContext.Current.Response.ContentType = "application/ms-excel";

            StringWriter   sw  = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            System.Web.UI.WebControls.Table table = new System.Web.UI.WebControls.Table();
            table.GridLines = grdProductList.GridLines;

            //Set the Cell format
            string codeFormat = @"<style>.cF  { mso-number-format:'\@'; }</style>";

            //  add the header row to the table
            if (grdProductList.HeaderRow != null)
            {
                PrepareControlForExport(grdProductList.HeaderRow);
                table.Rows.Add(grdProductList.HeaderRow);
                table.Rows[0].ForeColor = Color.FromArgb(102, 102, 102);

                for (int i = 0; i < table.Rows[0].Cells.Count; i++)
                {
                    table.Rows[0].Cells[i].BackColor = Color.FromArgb(225, 224, 224);
                }
            }

            //  add each of the data rows to the table
            foreach (GridViewRow row in grdProductList.Rows)
            {
                PrepareControlForExport(row);
                int pos = table.Rows.Add(row);
                table.Rows[pos].Cells[0].Attributes.Add("class", "cF");
                table.Rows[pos].Cells[1].Attributes.Add("class", "cF");
                table.Rows[pos].Cells[2].Attributes.Add("class", "cF");
            }

            //  render the table into the htmlwriter
            table.RenderControl(htw);

            //  render the htmlwriter into the response adding de style
            HttpContext.Current.Response.Write(codeFormat + sw.ToString());
            HttpContext.Current.Response.End();
        }
Example #20
0
        public void BindData(int IdClanak)
        {
            DataSet ds = new DataSet();
            DataSet ds2 = new DataSet();
            SqlCommand cmd = new SqlCommand("Select Id,Pitanje,Datum from Pitanja where IdClanak="+ IdClanak, connection);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            SqlCommand cmd2 = null;
            SqlDataAdapter da2;
            DataTable dt = new DataTable();
            int idpitanje;

            Table t = new Table();

            DataTable dataTable = new DataTable();
            DataRow dr;
            dt.Columns.Add("Id");
            dt.Columns.Add("Question");
            dt.Columns.Add("Date");
            dt.Columns.Add("IdType");
            dt.Columns.Add("Type");
            //dt.Columns.Add("Ocjena");

            //dt.Columns.Add("josjednacolona");
            da.Fill(dataTable);

            da.Fill(ds, "Pitanja");
            //ds = da.GetOrderStatus(iOrderId);
            if (ds.Tables.Count > 0)
            {

                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {

                        if (dataTable != null)
                        {

                            dr = dt.NewRow();
                            dr["Id"] = ds.Tables[0].Rows[i]["Id"].ToString();
                            dr["Question"] = ds.Tables[0].Rows[i]["Pitanje"].ToString();
                            dr["Date"] = ds.Tables[0].Rows[i]["Datum"].ToString();
                            dr["IdType"] = 1;
                            dr["Type"] = "Pitanje postavljeno dana: ";
                           // = ds.Tables[0].Rows[i]["Pitanje"].ToString();
                            //dr["Answer"] = txtAnswer.Text;

                            dt.Rows.Add(dr);
                            dt.AcceptChanges();

                            gvPitanjaOdgovori.DataSource = dt;
                            gvPitanjaOdgovori.DataBind();
                           // gvPitanjaOdgovori.Rows[0].Cells[0].BackColor = System.Drawing.Color.Red;
                        }

                        idpitanje = (int)ds.Tables[0].Rows[i]["Id"];
                        cmd2 = new SqlCommand("Select Id,Odgovor,Datum from Odgovori where IdPitanje=" + idpitanje, connection);
                        da2 = new SqlDataAdapter(cmd2);
                        da2.Fill(ds2, "Odgovori");

                        TableRow tr = new TableRow();
                        TableCell td = new TableCell { Text = ds.Tables[0].Rows[i]["Pitanje"].ToString() };
                        tr.Cells.Add(td);
                        t.Rows.Add(tr);

                        for (int j = 0; j < ds2.Tables[0].Rows.Count; j++)
                        {

                            if (dataTable != null)
                            {

                                dr = dt.NewRow();
                                dr["Id"] = ds2.Tables[0].Rows[j]["Id"].ToString();
                                dr["Question"] = ds2.Tables[0].Rows[j]["Odgovor"].ToString();
                                dr["Date"] = ds2.Tables[0].Rows[j]["Datum"].ToString();
                                dr["IdType"] = 2;
                                dr["Type"] = "Odgovoreno dana: ";
                                //dr["Answer"] = txtAnswer.Text;
                                dt.Rows.Add(dr);
                                dt.AcceptChanges();

                                gvPitanjaOdgovori.DataSource = dt;
                                gvPitanjaOdgovori.DataBind();
                               // gvPitanjaOdgovori.Rows[0].Cells[0].BackColor = System.Drawing.Color.Yellow;
                            }

                            TableRow tr1 = new TableRow();
                            TableCell td1 = new TableCell { Text = "-------" + ds2.Tables[0].Rows[j]["Odgovor"].ToString() };
                            tr1.Cells.Add(td1);
                            t.Rows.Add(tr1);

                        }
                        ds2 = new DataSet();
                    }
                    using (StringWriter sw = new StringWriter())
                    {
                        t.RenderControl(new HtmlTextWriter(sw));
                        string html = sw.ToString();
                    }
             }
            else
            {
                //lblinform.Text = "No data found.";
            }

            for (int d = 0; d<gvPitanjaOdgovori.Rows.Count; d++)
            {
                for (int j = 0; j < gvPitanjaOdgovori.Rows[d].Cells.Count; j++)
                {
                    if (gvPitanjaOdgovori.Rows[d].Cells[3].Text.ToString()=="1")
                        gvPitanjaOdgovori.Rows[d].Cells[2].BackColor = System.Drawing.Color.Lavender;
                    else
                        gvPitanjaOdgovori.Rows[d].Cells[2].BackColor = System.Drawing.Color.Honeydew;

                }
            }

            MyPanel.Controls.Add(t);
        }
    protected void LBExportToExcel_Click(object sender, EventArgs e)
    {
        try
        {
            string fileName  = "Employee_Report" + System.DateTime.Now + ".xls";
            string Extension = ".xls";
            if (Extension == ".xls")
            {
                for (int i = 0; i < GVEmployee.Columns.Count; i++)
                {
                    GVEmployee.Columns[i].Visible = true;
                }

                BindGVEmployees();

                clsConnectionSql.PrepareControlForExport(GVEmployee);
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));
                HttpContext.Current.Response.Charset = "";
                HttpContext.Current.Response.Cache.SetCacheability(System.Web.HttpCacheability.Public);
                HttpContext.Current.Response.ContentType = "application/ms-excel";
                try
                {
                    using (StringWriter sw = new StringWriter())
                    {
                        using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                        {
                            //Create a form to contain the grid
                            System.Web.UI.WebControls.Table table = new System.Web.UI.WebControls.Table();
                            table.GridLines = GVEmployee.GridLines;
                            //add the header row to the table
                            if (GVEmployee.HeaderRow != null)
                            {
                                clsConnectionSql.PrepareControlForExport(GVEmployee.HeaderRow);
                                table.Rows.Add(GVEmployee.HeaderRow);
                            }
                            //add each of the data rows to the table
                            foreach (GridViewRow row in GVEmployee.Rows)
                            {
                                clsConnectionSql.PrepareControlForExport(row);
                                table.Rows.Add(row);
                            }

                            //add the footer row to the table
                            if (GVEmployee.FooterRow != null)
                            {
                                clsConnectionSql.PrepareControlForExport(GVEmployee.FooterRow);
                                table.Rows.Add(GVEmployee.FooterRow);
                            }
                            //render the table into the htmlwriter
                            GVEmployee.GridLines = GridLines.Both;
                            table.RenderControl(htw);
                            HttpContext.Current.Response.Write(sw.ToString());
                            HttpContext.Current.Response.End();
                        }
                    }
                }
                catch (HttpException ex)
                {
                    ShowMessage(ex.Message, MessageType.Error);
                }
            }
        }
        catch (Exception ex)
        {
            ShowMessage(ex.Message, MessageType.Error);
        }
    }
Example #22
0
        public void  generar(Object Sender, EventArgs e)
        {
            string [] pr = new string[2];
            pr[0] = pr[1] = "";
            Press frontEnd = new Press(new DataSet(), reportTitle);

            frontEnd.PreHeader(tabPreHeader, Grid.Width, pr);
            frontEnd.Firmas(tabFirmas, Grid.Width);
            lb.Text = "";
            Año     = Convert.ToInt32(año.SelectedValue.ToString());
            Mes     = Convert.ToInt32(DBFunctions.SingleData("SELECT pmes_mes FROM DBXSCHEMA.pmes WHERE pmes_nombre='" + mes.SelectedValue.ToString() + "' "));
            dia     = Convert.ToInt32(Dia.Text.ToString());

            ///////////////////////////////////////////////////////
            this.PrepararTabla();
            this.PrepararTabla1();
            this.PrepararTabla2();
            this.PrepararTabla4();

            lineas  = new DataSet();
            lineas2 = new DataSet();
            lineas3 = new DataSet();
            lineas4 = new DataSet();

            DBFunctions.Request(lineas, IncludeSchema.NO, "Select MREM.MCAT_PLACA AS PLACA,MREM.NUM_REM AS NUMERO,MREM.VALO_FLET AS REMESA from DBXSCHEMA.MREMESA MREM where year(MREM_FECHA)=" + Año + " AND MONTH(MREM_FECHA)=" + Mes + " AND DAY(MREM_FECHA)=" + dia + " ");     //remesa
            DBFunctions.Request(lineas2, IncludeSchema.NO, "SELECT MAN.MCAT_PLACA AS PLACA,MAN.MAN_CODIGO AS NUMERO,MAN.MAN_VALOTOTAL AS VALOR from DBXSCHEMA.MANTICIPO MAN WHERE year(MAN_FECHA)=" + Año + " AND MONTH(MAN_FECHA)=" + Mes + " AND DAY(MAN_FECHA)=" + dia + " ");   //anticipo
            DBFunctions.Request(lineas3, IncludeSchema.NO, "select MAU.MCAT_PLACA AS PLACA,MAU.MAU_CODIGO AS NUMERO,MAU.MAU_VALOTOT AS VALOR from DBXSCHEMA.MAUTORIZACION MAU WHERE year(MAU_FECHA)=" + Año + " AND MONTH(MAU_FECHA)=" + Mes + " AND DAY(MAU_FECHA)=" + dia + " "); //autorizacion de servicio
            DBFunctions.Request(lineas4, IncludeSchema.NO, "select DRUT.MCAT_PLACA,DRUT.DRUT_PLANILLA,DRUT.DRUT_CODIGO from DBXSCHEMA.DRUTA DRUT  WHERE year(DRUT.DRUT_FECHA)=" + Año + " AND MONTH(DRUT.DRUT_FECHA)=" + Mes + " AND DAY(DRUT.DRUT_FECHA)=" + dia + " ");           // tiquetes

            /////////////////////////TABLAS//////////////////////////

            /////////////////// TABLA 1 /////////////////////////////
            for (int i = 0; i < lineas.Tables[0].Rows.Count; i++)
            {
                //Vamos a crear una fila para nuestro DataTable resultado, que almacene los resultados de las operaciones anteriores
                DataRow fila;
                fila = resultado.NewRow();
                double valor        = 0;
                string ValorFormato = null;
                valor          = Convert.ToDouble(lineas.Tables[0].Rows[i].ItemArray[2].ToString());
                ValorFormato   = String.Format("{0:C}", valor);
                fila["BUS"]    = lineas.Tables[0].Rows[i].ItemArray[0].ToString();
                fila["NUMERO"] = lineas.Tables[0].Rows[i].ItemArray[1].ToString();
                fila["VALOR"]  = ValorFormato.ToString();
                resultado.Rows.Add(fila);
            }
            ///////////////////////TABLA 2///////////////////////////
            for (int a = 0; a < lineas2.Tables[0].Rows.Count; a++)
            {
                //Vamos a crear una fila para nuestro DataTable resultado, que almacene los resultados de las operaciones anteriores
                DataRow fila2;
                fila2 = resultado2.NewRow();
                double valor2        = 0;
                string ValorFormato2 = null;
                valor2           = Convert.ToDouble(lineas2.Tables[0].Rows[a].ItemArray[2].ToString());
                ValorFormato2    = String.Format("{0:C}", valor2);
                fila2["BUS1"]    = lineas2.Tables[0].Rows[a].ItemArray[0].ToString();
                fila2["NUMERO1"] = lineas2.Tables[0].Rows[a].ItemArray[1].ToString();
                fila2["VALOR1"]  = ValorFormato2.ToString();
                resultado2.Rows.Add(fila2);
            }
            /////////////////// TABLA 3 /////////////////////
            for (int b = 0; b < lineas3.Tables[0].Rows.Count; b++)
            {
                //Vamos a crear una fila para nuestro DataTable resultado, que almacene los resultados de las operaciones anteriores
                DataRow fila3;
                fila3 = resultado3.NewRow();
                double valor3        = 0;
                string ValorFormato3 = null;
                valor3           = Convert.ToDouble(lineas3.Tables[0].Rows[b].ItemArray[2].ToString());
                ValorFormato3    = String.Format("{0:C}", valor3);
                fila3["BUS2"]    = lineas3.Tables[0].Rows[b].ItemArray[0].ToString();
                fila3["NUMERO2"] = lineas3.Tables[0].Rows[b].ItemArray[1].ToString();
                fila3["VALOR2"]  = ValorFormato3.ToString();
                resultado3.Rows.Add(fila3);
            }
            /////////////////// TABLA 4 /////////////////////
            for (int c = 0; c < lineas4.Tables[0].Rows.Count; c++)
            {
                int    codigoruta  = Convert.ToInt32(lineas4.Tables[0].Rows[c].ItemArray[2].ToString());
                int    Puestos     = Convert.ToInt32(DBFunctions.SingleData("SELECT count(*) AS NUMERO from DBXSCHEMA.DTIQUETE where DRUT_CODIGO=" + codigoruta + " and TTIQ_CODIGO=1"));
                int    codigoMruta = Convert.ToInt32(DBFunctions.SingleData("select MRUT_CODIGO FROM DBXSCHEMA.DRUTA WHERE DRUT_CODIGO=" + codigoruta + " "));
                double precio      = Convert.ToDouble(DBFunctions.SingleData("select MRUT_VALOR from DBXSCHEMA.MRUTA WHERE MRUT_CODIGO=" + codigoMruta + ""));
                double total       = precio * Puestos;
                //Vamos a crear una fila para nuestro DataTable resultado, que almacene los resultados de las operaciones anteriores



                DataRow fila4;
                fila4 = resultado4.NewRow();

                string ValorFormato4 = null;
                ValorFormato4   = String.Format("{0:C}", total);
                fila4["BUS4"]   = lineas4.Tables[0].Rows[c].ItemArray[0].ToString();
                fila4["TOTAL"]  = Puestos;
                fila4["VALOR4"] = ValorFormato4.ToString();
                resultado4.Rows.Add(fila4);
            }

            ///////////// FIN TABLAS ////////////////////


            Grid.DataSource = resultado;
            Grid.DataBind();
            StringBuilder  SB     = new StringBuilder();
            StringWriter   SW     = new StringWriter(SB);
            HtmlTextWriter htmlTW = new HtmlTextWriter(SW);

            tabPreHeader.RenderControl(htmlTW);
            Grid.RenderControl(htmlTW);
            tabFirmas.RenderControl(htmlTW);
            string strRep;

            strRep = SB.ToString();
            Session.Clear();
            Session["Rep"]      = strRep;
            toolsHolder.Visible = true;
            //////////////////////////////
            Grid1.DataSource = resultado2;
            Grid1.DataBind();
            Grid1.RenderControl(htmlTW);

            //////////////////////////////
            Grid2.DataSource = resultado3;
            Grid2.DataBind();
            Grid2.RenderControl(htmlTW);
            //////////////////////////////
            Grid3.DataSource = resultado4;
            Grid3.DataBind();
            Grid3.RenderControl(htmlTW);
            ////////////////////////////////
        }
        public void ExportToExcel(string column, string order)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-us");// Thread.CurrentThread.CurrentUICulture;

            GridView grdProductList = new GridView();

            grdProductList.AutoGenerateColumns = false;

            #region Columns
            BoundField bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "ProductCode";
            bf.HeaderText      = "Producto";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "ProductName";
            bf.HeaderText      = "Descripci&oacute;n";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "Group";
            bf.HeaderText      = "Grupo";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "Sales";
            bf.HeaderText      = "VTA. 12M";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "CuatrimestralSales";
            bf.HeaderText      = "VTA. 12M/3";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "SaleMonths";
            bf.HeaderText      = "Vida del Producto";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "RepositionLevel";
            bf.HeaderText      = "N. Reposici&oacute;n";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "Result";
            bf.HeaderText      = "Diferenc&iacute;a %";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "ProductCountryCode";
            bf.HeaderText      = "Código de País";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "OrderInfo";
            bf.HeaderText      = "Información de Orden de Venta (Cant. Ordenes/%/N. Orden)";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            #endregion

            grdProductList.DataSource = ShowAlert(column, order);
            grdProductList.DataBind();

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename=DiferenciaEnNivelDeReposición.xls"));
            HttpContext.Current.Response.ContentType = "application/ms-excel";

            StringWriter   sw  = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            System.Web.UI.WebControls.Table table = new System.Web.UI.WebControls.Table();
            table.GridLines = grdProductList.GridLines;

            //Set the Cell format
            string codeFormat = @"<style>.cF  { mso-number-format:'\@'; }</style>";

            //  add the header row to the table
            if (grdProductList.HeaderRow != null)
            {
                PrepareControlForExport(grdProductList.HeaderRow);
                table.Rows.Add(grdProductList.HeaderRow);
                table.Rows[0].ForeColor = Color.FromArgb(102, 102, 102);

                for (int i = 0; i < table.Rows[0].Cells.Count; i++)
                {
                    table.Rows[0].Cells[i].BackColor = Color.FromArgb(225, 224, 224);
                }
            }

            //  add each of the data rows to the table
            List <AlertReposition> arLSt = grdProductList.DataSource as List <AlertReposition>;
            foreach (GridViewRow row in grdProductList.Rows)
            {
                PrepareControlForExport(row);
                int pos = table.Rows.Add(row);
                table.Rows[pos].Cells[0].Attributes.Add("class", "cF");

                //ver esto
                AlertReposition ar = arLSt[pos - 1];
                if (ar != null && ar.IsConflicted)
                {
                    for (int i = 0; i < table.Rows[pos].Cells.Count; i++)
                    {
                        table.Rows[pos].Cells[i].BackColor = Color.FromArgb(250, 128, 114);
                    }
                }
            }

            //  render the table into the htmlwriter
            table.RenderControl(htw);

            //  render the htmlwriter into the response adding de style
            HttpContext.Current.Response.Write(codeFormat + sw.ToString());
            HttpContext.Current.Response.End();
        }
Example #24
0
        private void ExportToExcel(string fileName, Microsoft.SharePoint.WebControls.SPGridView spGV)
        {
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    Table table = new Table();

                    if (spGV.HeaderRow != null)
                    {
                        table.Rows.Add(spGV.HeaderRow);
                    }

                    foreach (GridViewRow gvRow in spGV.Rows)
                    {
                        table.Rows.Add(gvRow);
                    }

                    if (spGV.FooterRow != null)
                    {
                        table.Rows.Add(spGV.FooterRow);
                    }

                    table.BorderWidth = 1;

                    foreach (TableRow tr in table.Rows)
                    {
                        foreach (TableCell td in tr.Cells)
                        {
                            td.BorderWidth = 1;
                        }
                    }

                    //htw.RenderBeginTag(HtmlTextWriterTag.Span);
                    //htw.Write("Test");
                    //htw.RenderEndTag();

                    table.RenderControl(htw);

                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));
                    HttpContext.Current.Response.ContentType = "application/ms-excel";
                    HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    HttpContext.Current.Response.Charset = Encoding.UTF8.ToString();
                    HttpContext.Current.Response.ContentEncoding = Encoding.UTF8;

                    Response.Write("<html><head><meta http-equiv=Content-Type content=\"text/html; charset=utf-8\">");
                    HttpContext.Current.Response.Write(sw.ToString());
                    Response.Write("</body></html>");
                    HttpContext.Current.Response.End();
                }
            }
        }
Example #25
0
        //public
        /// <summary> 
        /// Render this control to the output parameter specified.
        /// </summary>
        /// <param name="output"> The HTML writer to write out to </param>
        protected override void Render(HtmlTextWriter output)
        {
            NdiMenuItem item0 =
            new NdiMenuItem(0, "Állás keresések listája", "Elérhetõ állás keresések szûréssel", "JobFinds.aspx", "_images/searchKexWordS.gif",
                        "_images/searchKexWordL.gif");

              NdiMenuItem item1 =
            new NdiMenuItem(1, "Új állás keresés rögzítése", "Új állás keresés rögzítése", "JobFindCreate.aspx", "_images/searchFreeTextS.gif",
                        "_images/searchFreeTextL.gif");
              NdiMenuItem item2 =
            new NdiMenuItem(2, "Milyen keresésekre válaszoltam", "Milyen  keresésekre válaszoltam", "JobFindMyAnswers.aspx", "_images/searchQuestionFormS.gif",
                        "_images/searchQuestionFormL.gif");

              NdiMenuItem item3 =
            new NdiMenuItem(3, "Saját állás kereséseim", "Saját állás kereséseim", "JobFindsFromMe.aspx", "_images/searchQuestionFormS.gif",
                        "_images/searchQuestionFormL.gif");

              Table table = new Table();
              table.CellPadding = 0;
              table.CellSpacing = 0;
              table.CssClass = "almenu";
              TableRow row1 = new TableRow();
              TableRow row2 = new TableRow();
              TableCell cell0 = CreateCell(item0);

              TableCell cell1 = CreateCell(item1);
              TableCell cell2 = CreateCell(item2);
              TableCell cell3 = CreateCell(item3);

              table.Rows.Add(row2);
              table.Rows.Add(row1);
              if (item0.Index == m_selectedindex)
            row1.Cells.Add(cell0);
              else
            row2.Cells.Add(cell0);

              if (item1.Index == m_selectedindex)
            row1.Cells.Add(cell1);
              else
            row2.Cells.Add(cell1);

              if (item2.Index == m_selectedindex)
            row1.Cells.Add(cell2);
              else
            row2.Cells.Add(cell2);

              if (item3.Index == m_selectedindex)
            row1.Cells.Add(cell3);
              else
            row2.Cells.Add(cell3);

              if (row1.Cells != null && row1.Cells.Count > 0 && row2.Cells != null && row2.Cells.Count > 0)
              {
            row1.Cells[0].ColumnSpan = row2.Cells.Count;

              }
              table.Width = Unit.Percentage(100);

              table.RenderControl(output);
        }
        public static System.IO.StringWriter CreateExcel_HTML(
            DataTable Dt
            , ClsExcel_Columns Columns)
        {
            System.IO.StringWriter Sw = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter Htw = new System.Web.UI.HtmlTextWriter(Sw);
            System.Web.UI.WebControls.Table Tb = new System.Web.UI.WebControls.Table();

            System.Web.UI.WebControls.TableRow Tbr_Header = new System.Web.UI.WebControls.TableRow();
            foreach (ClsExcel_Columns.Str_Columns? Obj in Columns.pObj)
            {
                System.Web.UI.WebControls.TableCell Tbc = new System.Web.UI.WebControls.TableCell();
                Tbc.Text = Obj.Value.FieldDesc;
                Tbr_Header.Cells.Add(Tbc);
            }

            Tb.Rows.Add(Tbr_Header);

            foreach (DataRow Dr in Dt.Rows)
            {
                System.Web.UI.WebControls.TableRow Tbr = new System.Web.UI.WebControls.TableRow();
                foreach (ClsExcel_Columns.Str_Columns? Obj in Columns.pObj)
                {
                    System.Web.UI.WebControls.TableCell Tbc = new System.Web.UI.WebControls.TableCell();
                    Tbc.Text = Dr[Obj.Value.FieldName].ToString();
                    Tbr.Cells.Add(Tbc);
                }
                Tb.Rows.Add(Tbr);
            }
            Tb.RenderControl(Htw);
            return Sw;
        }
Example #27
0
        private void ExportToExcel(GridState gs, IList <IFilter> filters)
        {
            Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture;

            GridView grdProductList = new GridView();

            grdProductList.AutoGenerateColumns = false;

            BoundField bf = new BoundField();

            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "Code";
            bf.HeaderText      = "C&oacute;digo";
            bf.HtmlEncode      = false;
            // bf.DataFormatString = "{0:00000000}";
            grdProductList.Columns.Add(bf);


            bf = new BoundField();
            bf.ItemStyle.Width           = Unit.Pixel(600);
            bf.DataField                 = "FinalInfo";
            bf.HeaderText                = "Modelo";
            bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
            grdProductList.Columns.Add(bf);

            //si sos Admin
            ExecutePermissionValidator epv = new ExecutePermissionValidator();

            epv.ClassType     = typeof(ProductListView);
            epv.KeyIdentifier = Config.CanExportAll;
            bool canExporAll = PermissionManager.Check(epv);

            if (canExporAll)
            {
                bf = new BoundField();
                bf.ItemStyle.Width = Unit.Pixel(150);
                bf.DataField       = "Provider";
                bf.HeaderText      = "Proveedor";
                grdProductList.Columns.Add(bf);

                bf = new BoundField();
                bf.ItemStyle.Width  = Unit.Pixel(50);
                bf.DataField        = "Index";
                bf.HeaderText       = "Index";
                bf.HtmlEncode       = false;
                bf.DataFormatString = "{0:F2}";
                grdProductList.Columns.Add(bf);

                bf = new BoundField();
                bf.ItemStyle.Width = Unit.Pixel(70);
                bf.DataField       = "Type";
                bf.HeaderText      = "Frecuencia";
                grdProductList.Columns.Add(bf);


                bf = new BoundField();
                bf.ItemStyle.Width = Unit.Pixel(30);
                bf.DataField       = "PricePurchaseCurrency";
                bf.HeaderText      = "M. TP";
                grdProductList.Columns.Add(bf);

                bf = new BoundField();
                bf.ItemStyle.Width  = Unit.Pixel(70);
                bf.DataField        = "PricePurchase";
                bf.HeaderText       = "TP";
                bf.HtmlEncode       = false;
                bf.DataFormatString = "{0:F2}";
                grdProductList.Columns.Add(bf);

                bf = new BoundField();
                bf.ItemStyle.Width = Unit.Pixel(30);
                bf.DataField       = "PriceSuggestCurrency";
                bf.HeaderText      = "M. GRP";
                grdProductList.Columns.Add(bf);

                bf = new BoundField();
                bf.ItemStyle.Width  = Unit.Pixel(70);
                bf.DataField        = "PriceSuggest";
                bf.HeaderText       = "GRP";
                bf.HtmlEncode       = false;
                bf.DataFormatString = "{0:F2}";
                grdProductList.Columns.Add(bf);

                bf = new BoundField();
                bf.ItemStyle.Width = Unit.Pixel(30);
                bf.DataField       = "PriceListCurrency";
                bf.HeaderText      = "M. PV";
                grdProductList.Columns.Add(bf);

                bf = new BoundField();
                bf.ItemStyle.Width  = Unit.Pixel(70);
                bf.DataField        = "PriceSell";
                bf.HeaderText       = "PV";
                bf.HtmlEncode       = false;
                bf.DataFormatString = "{0:F2}";
                grdProductList.Columns.Add(bf);
            }

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(10);
            bf.DataField       = "PriceListCurrency";
            bf.HeaderText      = "M. PL";
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width  = Unit.Pixel(70);
            bf.DataField        = "Price";
            bf.HeaderText       = "PL";
            bf.HtmlEncode       = false;
            bf.DataFormatString = "{0:F2}";
            grdProductList.Columns.Add(bf);

            if (canExporAll)
            {
                bf = new BoundField();
                bf.ItemStyle.Width = Unit.Pixel(30);
                bf.DataField       = "PriceListCurrency";
                bf.HeaderText      = "M. CTM";
                grdProductList.Columns.Add(bf);

                bf = new BoundField();
                bf.ItemStyle.Width  = Unit.Pixel(70);
                bf.DataField        = "CTM";
                bf.HeaderText       = "CTM";
                bf.HtmlEncode       = false;
                bf.DataFormatString = "{0:F2}";
                grdProductList.Columns.Add(bf);

                bf = new BoundField();
                bf.ItemStyle.Width  = Unit.Pixel(70);
                bf.DataField        = "CTR";
                bf.HeaderText       = "CTR";
                bf.HtmlEncode       = false;
                bf.DataFormatString = "{0:F2}";
                grdProductList.Columns.Add(bf);

                //bf = new BoundField();
                //bf.ItemStyle.Width = Unit.Pixel(70);
                //bf.DataField = "Status";
                //bf.HeaderText = "Estado";
                //grdProductList.Columns.Add(bf);
            }
            //***************//



            grdProductList.DataSource = GetFiltered(gs, filters);
            grdProductList.DataBind();

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename=ListadePrecios.xls"));
            HttpContext.Current.Response.ContentType = "application/ms-excel";

            StringWriter   sw  = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            System.Web.UI.WebControls.Table table = new System.Web.UI.WebControls.Table();
            table.GridLines = grdProductList.GridLines;

            //Set the Cell format
            string codeFormat = @"<style>.cF  { mso-number-format:'\@'; }</style>";

            //  add the header row to the table
            if (grdProductList.HeaderRow != null)
            {
                PrepareControlForExport(grdProductList.HeaderRow);
                table.Rows.Add(grdProductList.HeaderRow);
                table.Rows[0].ForeColor = System.Drawing.Color.FromArgb(102, 102, 102);

                for (int i = 0; i < table.Rows[0].Cells.Count; i++)
                {
                    table.Rows[0].Cells[i].BackColor = System.Drawing.Color.FromArgb(225, 224, 224);
                }
            }

            //  add each of the data rows to the table
            foreach (GridViewRow row in grdProductList.Rows)
            {
                PrepareControlForExport(row);
                int pos = table.Rows.Add(row);

                table.Rows[pos].Cells[0].Attributes.Add("class", "cF");
                table.Rows[pos].Cells[0].HorizontalAlign  = HorizontalAlign.Right;
                table.Rows[pos].Cells[0].Width            = 95;
                table.Rows[pos].Cells[1].Width            = 600;
                table.Rows[pos].Cells[2].Width            = 110;
                table.Rows[pos].Cells[2].HorizontalAlign  = HorizontalAlign.Left;
                table.Rows[pos].Cells[4].HorizontalAlign  = HorizontalAlign.Right;
                table.Rows[pos].Cells[5].HorizontalAlign  = HorizontalAlign.Right;
                table.Rows[pos].Cells[7].HorizontalAlign  = HorizontalAlign.Right;
                table.Rows[pos].Cells[9].HorizontalAlign  = HorizontalAlign.Right;
                table.Rows[pos].Cells[11].HorizontalAlign = HorizontalAlign.Right;
                table.Rows[pos].Cells[13].HorizontalAlign = HorizontalAlign.Right;
                //Set Euro Symbol Correctly
                if (row.Cells[13].Text == "€")
                {
                    table.Rows[pos].Cells[13].Text = "&#8364";
                }
                if (canExporAll)
                {
                    if (row.Cells[5].Text == "€")
                    {
                        table.Rows[pos].Cells[5].Text = "&#8364";
                    }
                    if (row.Cells[7].Text == "€")
                    {
                        table.Rows[pos].Cells[7].Text = "&#8364";
                    }
                    if (row.Cells[9].Text == "€")
                    {
                        table.Rows[pos].Cells[9].Text = "&#8364";
                    }
                    if (row.Cells[11].Text == "€")
                    {
                        table.Rows[pos].Cells[11].Text = "&#8364";
                    }
                }
                table.Rows[pos].Cells[3].Attributes.Add("class", "pF");
                table.Rows[pos].Cells[3].Width = 110;
            }

            //  render the table into the htmlwriter
            table.RenderControl(htw);

            //  render the htmlwriter into the response adding de style

            HttpContext.Current.Response.Write(codeFormat + sw.ToString());
            HttpContext.Current.Response.End();
        }
Example #28
0
    protected void btn_export_Click(object sender, EventArgs e)
    {
        DataView view = new DataView();

        view.Table = (DataTable)this.ViewState["listar"];
        if (view.Count > 0)
        {
            GridView gv = new GridView();
            gv.DataSource = view;
            gv.DataBind();

            string fileName  = "Reporte_Ottawa.xls";
            string Extension = ".xls";
            if (Extension == ".xls")
            {
                PrepareControlForExport(gv);
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));
                HttpContext.Current.Response.Charset = "";
                HttpContext.Current.Response.Cache.SetCacheability(System.Web.HttpCacheability.Public);
                HttpContext.Current.Response.ContentType = "application/ms-excel";
                try
                {
                    using (StringWriter sw = new StringWriter())
                    {
                        using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                        {
                            System.Web.UI.WebControls.Table table = new System.Web.UI.WebControls.Table();
                            table.GridLines = gv.GridLines;

                            if (gv.HeaderRow != null)
                            {
                                PrepareControlForExport(gv.HeaderRow);
                                table.Rows.Add(gv.HeaderRow);
                            }

                            foreach (GridViewRow row in gv.Rows)
                            {
                                PrepareControlForExport(row);
                                table.Rows.Add(row);
                            }

                            if (gv.FooterRow != null)
                            {
                                PrepareControlForExport(gv.FooterRow);
                                table.Rows.Add(gv.FooterRow);
                            }

                            gv.GridLines = GridLines.Both;
                            table.RenderControl(htw);
                            HttpContext.Current.Response.Write(sw.ToString());
                            HttpContext.Current.Response.End();
                        }
                    }
                }
                catch (HttpException ex)
                {
                    throw ex;
                }
            }
        }
        else
        {
            string texto = "Debe cargar datos antes de exportar!";
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", string.Format("alert('{0}');", texto), true);
        }
    }
Example #29
0
    protected void btnExportar_Click(object sender, EventArgs e)
    {
        DataView view = new DataView();

        view.Table = (DataTable)this.ViewState["lista"];
        view.Table.Columns.Remove(view.Table.Columns["ID"]);
        view.Table.Columns.Remove(view.Table.Columns["EXCLUYENTES"]);
        view.Table.Columns.Remove(view.Table.Columns["NO_EXCLUYENTES"]);
        view.Table.Columns.Remove(view.Table.Columns["CARACTERISTICAS"]);
        view.Table.Columns.Remove(view.Table.Columns["COMU_ID"]);
        view.Table.Columns.Remove(view.Table.Columns["REGI_ID"]);
        GridView gv = new GridView();

        gv.DataSource = view;
        gv.DataBind();

        string fileName  = "Reporte_Locales.xls";
        string Extension = ".xls";

        if (Extension == ".xls")
        {
            PrepareControlForExport(gv);
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));
            HttpContext.Current.Response.Charset = "";
            HttpContext.Current.Response.Cache.SetCacheability(System.Web.HttpCacheability.Public);
            HttpContext.Current.Response.ContentType = "application/ms-excel";
            try
            {
                using (StringWriter sw = new StringWriter())
                {
                    using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                    {
                        System.Web.UI.WebControls.Table table = new System.Web.UI.WebControls.Table();
                        table.GridLines = gv.GridLines;

                        if (gv.HeaderRow != null)
                        {
                            PrepareControlForExport(gv.HeaderRow);
                            table.Rows.Add(gv.HeaderRow);
                        }

                        foreach (GridViewRow row in gv.Rows)
                        {
                            PrepareControlForExport(row);
                            table.Rows.Add(row);
                        }

                        if (gv.FooterRow != null)
                        {
                            PrepareControlForExport(gv.FooterRow);
                            table.Rows.Add(gv.FooterRow);
                        }

                        gv.GridLines = GridLines.Both;
                        table.RenderControl(htw);
                        HttpContext.Current.Response.Write(sw.ToString());
                        HttpContext.Current.Response.End();
                    }
                }
            }
            catch (HttpException ex)
            {
                throw ex;
            }
        }
    }
        /// <summary>
        /// Creates html table to hold passed in feature info, and stream back to client.
        /// </summary>
        /// <param name="ftr">feature object</param>
        private void CreateInfoTable(Feature ftr)
        {
            //create a table control and populat it with the column name/value(s) from the feature returned and
            // and the name of the layer where the feature belong
            System.Web.UI.WebControls.Table infoTable = new System.Web.UI.WebControls.Table();
            //set table attribute/styles
            infoTable.CellPadding = 4;
            infoTable.Font.Name   = "Arial";
            infoTable.Font.Size   = new FontUnit(8);
            infoTable.BorderWidth = 1;
            //infoTable.BorderStyle = BorderStyle.Outset;

            System.Drawing.Color backColor = Color.Bisque;

            //add the first row, the layer name/value where the selected feature belongs
            TableRow r = new TableRow();

            r.BackColor = backColor;

            TableCell c = new TableCell();

            c.Font.Bold = true;
            c.ForeColor = Color.Indigo;

            c.Text = "Layer Name";
            r.Cells.Add(c);

            c = new TableCell();

            //the feature returned is from a resultset table whose name is got from appending _2
            //to the real table name, so below is to get the real table name.
            string alias = ftr.Table.Alias;

            c.Text      = alias.Substring(0, alias.Length - 2);
            c.Font.Bold = true;
            r.Cells.Add(c);

            infoTable.Rows.Add(r);

            foreach (Column col in ftr.Columns)
            {
                String upAlias = col.Alias.ToUpper();
                //don't display obj, MI_Key or MI_Style columns
                if (upAlias != "OBJ" && upAlias != "MI_STYLE" && upAlias != "MI_KEY")
                {
                    r           = new TableRow();
                    r.BackColor = backColor;

                    r.Cells.Clear();
                    c           = new TableCell();
                    c.Text      = col.Alias;
                    c.Font.Bold = true;
                    c.ForeColor = Color.RoyalBlue;

                    r.Cells.Add(c);
                    c      = new TableCell();
                    c.Text = ftr[col.Alias].ToString();
                    r.Cells.Add(c);
                    infoTable.Rows.Add(r);
                }
            }

            //stream the html table back to client
            StringWriter   sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            infoTable.RenderControl(hw);
            String strHTML = sw.ToString();

            HttpContext.Current.Response.Output.Write(strHTML);
        }
Example #31
0
        /// <summary>
        /// Generates the pager links.
        /// </summary>
        /// <param name="writer">The writer.</param>
        private void GeneratePagerLinks(HtmlTextWriter writer)
        {
            var mainTable = new Table { CssClass = "PagerTable" };

            var mainTableRow = new TableRow();

            mainTable.Rows.Add(mainTableRow);

            var previousColumn = new TableCell { CssClass = "PagerFirstColumn" };

            int iStart = this.CurrentPageIndex - 2;
            int iEnd = this.CurrentPageIndex + 3;

            if (iStart < 0)
            {
                iStart = 0;
            }

            if (iEnd > this.PageCount)
            {
                iEnd = this.PageCount;
            }

            var ulFirstElement = new HtmlGenericControl("ul");

            ulFirstElement.Attributes.Add("class", "FilesPager");

            // First Page
            if (iStart > 0)
            {
                var liFirstElement = new HtmlGenericControl("li");

                liFirstElement.Attributes.Add("class", "FirstPage");

                var firstPageLink = new HyperLink
                {
                    ID = "FirstPageLink",
                    ToolTip = string.Format("{0}{1}", Localization.GetString("GoTo.Text", this.RessourceFile, this.LanguageCode), Localization.GetString("FirstPage.Text", this.RessourceFile, this.LanguageCode)),
                    Text = string.Format("&laquo; {0}", Localization.GetString("FirstPage.Text", this.RessourceFile, this.LanguageCode)),
                    NavigateUrl =
                        this.Page.ClientScript.GetPostBackClientHyperlink(this, string.Format("Page_{0}", 0), false)
                };

                liFirstElement.Controls.Add(firstPageLink);

                ulFirstElement.Controls.Add(liFirstElement);
            }

            // Previous Page
            if (this.CurrentPageIndex > iStart)
            {
                var liPrevElement = new HtmlGenericControl("li");

                liPrevElement.Attributes.Add("class", "PreviousPage");

                var lastPrevLink = new HyperLink
                {
                    ID = "PreviousPageLink",
                    ToolTip = string.Format("{0}{1}", Localization.GetString("GoTo.Text", this.RessourceFile, this.LanguageCode), Localization.GetString("PreviousPage.Text", this.RessourceFile, this.LanguageCode)),
                    Text = string.Format("&lt; {0}", Localization.GetString("PreviousPage.Text", this.RessourceFile, this.LanguageCode)),
                    NavigateUrl =
                        this.Page.ClientScript.GetPostBackClientHyperlink(
                            this, string.Format("Page_{0}", this.CurrentPageIndex - 1), false)
                };

                liPrevElement.Controls.Add(lastPrevLink);

                ulFirstElement.Controls.Add(liPrevElement);
            }

            // Add Column
            previousColumn.Controls.Add(ulFirstElement);
            mainTableRow.Cells.Add(previousColumn);

            // Second Page Numbers Column
            var ulSecondElement = new HtmlGenericControl("ul");

            var pageNumbersColumn = new TableCell { CssClass = "PagerNumbersColumn", HorizontalAlign = HorizontalAlign.Center };

            ulSecondElement.Attributes.Add("class", "FilesPager");

            for (int i = iStart; i < iEnd; i++)
            {
                var liElement = new HtmlGenericControl("li");

                liElement.Attributes.Add("class", i.Equals(this.CurrentPageIndex) ? "ActivePage" : "NormalPage");

                var page = (i + 1).ToString();

                var pageLink = new HyperLink
                {
                    ID = string.Format("NextPageLink{0}", page),
                    ToolTip = string.Format("{0}: {1}", Localization.GetString("GoTo.Text", this.RessourceFile, this.LanguageCode), page),
                    Text = page,
                    NavigateUrl =
                        this.Page.ClientScript.GetPostBackClientHyperlink(this, string.Format("Page_{0}", i), false)
                };

                liElement.Controls.Add(pageLink);

                ulSecondElement.Controls.Add(liElement);
            }

            // Add Column
            pageNumbersColumn.Controls.Add(ulSecondElement);
            mainTableRow.Cells.Add(pageNumbersColumn);

            // Last Page Column
            var ulThirdElement = new HtmlGenericControl("ul");

            ulThirdElement.Attributes.Add("class", "FilesPager");

            var lastColumn = new TableCell { CssClass = "PagerLastColumn" };

            // Next Page
            if (this.CurrentPageIndex < (this.PageCount - 1))
            {
                var liNextElement = new HtmlGenericControl("li");

                liNextElement.Attributes.Add("class", "NextPage");

                var lastNextLink = new HyperLink
                {
                    ID = "NextPageLink",
                    ToolTip = string.Format("{0}{1}", Localization.GetString("GoTo.Text", this.RessourceFile, this.LanguageCode), Localization.GetString("NextPage.Text", this.RessourceFile, this.LanguageCode)),
                    Text = string.Format("{0} &gt;", Localization.GetString("NextPage.Text", this.RessourceFile, this.LanguageCode)),
                    NavigateUrl =
                        this.Page.ClientScript.GetPostBackClientHyperlink(
                            this, string.Format("Page_{0}", (this.CurrentPageIndex + 2 - 1)), false)
                };

                liNextElement.Controls.Add(lastNextLink);

                ulThirdElement.Controls.Add(liNextElement);
            }

            if (iEnd < this.PageCount)
            {
                var liLastElement = new HtmlGenericControl("li");

                liLastElement.Attributes.Add("class", "LastPage");

                var lastPageLink = new HyperLink
                {
                    ID = "LastPageLink",
                    ToolTip =
                        string.Format(
                            "{0}{1}",
                            Localization.GetString("GoTo.Text", this.RessourceFile, this.LanguageCode),
                            Localization.GetString("LastPage.Text", this.RessourceFile, this.LanguageCode)),
                    Text =
                        string.Format(
                            "{0} &raquo;",
                            Localization.GetString("LastPage.Text", this.RessourceFile, this.LanguageCode)),
                    NavigateUrl =
                        this.Page.ClientScript.GetPostBackClientHyperlink(
                            this, string.Format("Page_{0}", (this.PageCount - 1)), false)
                };

                liLastElement.Controls.Add(lastPageLink);

                ulThirdElement.Controls.Add(liLastElement);
            }

            // Add Column
            lastColumn.Controls.Add(ulThirdElement);
            mainTableRow.Cells.Add(lastColumn);

            // Render Complete Control
            mainTable.RenderControl(writer);
        }
 public static void ExportToExcel(string fileName, List<Listing> AdminList)
 {
     //The Clear method erases any buffered HTML output.
     HttpContext.Current.Response.Clear();
     //The AddHeader method adds a new HTML header and value to the response sent to the client.
     HttpContext.Current.Response.AddHeader(
          "content-disposition", string.Format("attachment; filename={0}", fileName + ".xls"));
     //The ContentType property specifies the HTTP content type for the response.
     HttpContext.Current.Response.ContentType = "application/ms-excel";
     //Implements a TextWriter for writing information to a string. The information is stored in an underlying StringBuilder.
     using (StringWriter sw = new StringWriter())
     {
         //Writes markup characters and text to an ASP.NET server control output stream. This class provides formatting capabilities that ASP.NET server controls use when rendering markup to clients.
         using (HtmlTextWriter htw = new HtmlTextWriter(sw))
         {
             //  Create a form to contain the List
             Table table = new Table();
             TableRow row = new TableRow();
             foreach (PropertyInfo proinfo in new Listing().GetType().GetProperties())
             {
                 TableHeaderCell hcell = new TableHeaderCell();
                 hcell.Text = proinfo.Name;
                 row.Cells.Add(hcell);
             }
             table.Rows.Add(row);
             //  add each of the data item to the table
             foreach (Listing lst in AdminList)
             {
                 TableRow row1 = new TableRow();
                 TableCell cellStaffID = new TableCell();
                 cellStaffID.Text = "" + lst.StaffID;
                 TableCell cellStaffName = new TableCell();
                 cellStaffName.Text = "" + lst.StaffName;
                 TableCell cellSuperName = new TableCell();
                 cellSuperName.Text = "" + lst.SupervisorName;
                 TableCell cellType = new TableCell();
                 cellType.Text = "" + lst.ApplicationType;
                 TableCell cellTitle = new TableCell();
                 cellTitle.Text = "" + lst.Title;
                 TableCell cellDate = new TableCell();
                 cellDate.Text = "" + lst.DateRequest;
                 TableCell cellStatus = new TableCell();
                 cellStatus.Text = "" + lst.Status;
                 TableCell cellSAP = new TableCell();
                 cellSAP.Text = "" + lst.PostedSAPStatus;
                 row1.Cells.Add(cellStaffID);
                 row1.Cells.Add(cellStaffName);
                 row1.Cells.Add(cellSuperName);
                 row1.Cells.Add(cellType);
                 row1.Cells.Add(cellTitle);
                 row1.Cells.Add(cellDate);
                 row1.Cells.Add(cellStatus);
                 row1.Cells.Add(cellSAP);
                 table.Rows.Add(row1);
             }
             //  render the table into the htmlwriter
             table.RenderControl(htw);
             //  render the htmlwriter into the response
             HttpContext.Current.Response.Write(sw.ToString());
             HttpContext.Current.Response.Flush();
             HttpContext.Current.Response.End();
         }
     }
 }
        /// <summary>
        /// Creates html table to hold passed in feature info, and stream back to client.
        /// </summary>
        /// <param name="ftr">feature object</param>
        private void CreateInfoTable(Feature ftr)
        {
            //create a table control and populat it with the column name/value(s) from the feature returned and
            // and the name of the layer where the feature belong
            System.Web.UI.WebControls.Table infoTable = new System.Web.UI.WebControls.Table();
            //set table attribute/styles
            infoTable.CellPadding = 4;
            infoTable.Font.Name = "Arial";
            infoTable.Font.Size = new FontUnit(8);
            infoTable.BorderWidth = 1;
            //infoTable.BorderStyle = BorderStyle.Outset;

            System.Drawing.Color backColor = Color.Bisque;

            //add the first row, the layer name/value where the selected feature belongs
            TableRow r = new TableRow();
            r.BackColor = backColor;

            TableCell c = new TableCell();
            c.Font.Bold = true;
            c.ForeColor = Color.Indigo;

            c.Text = "Layer Name";
            r.Cells.Add(c);

            c = new TableCell();

            //the feature returned is from a resultset table whose name is got from appending _2
            //to the real table name, so below is to get the real table name.
            string alias = ftr.Table.Alias;
            c.Text = alias.Substring(0, alias.Length-2);
            c.Font.Bold = true;
            r.Cells.Add(c);

            infoTable.Rows.Add(r);

            foreach(Column col in ftr.Columns)
            {
                String upAlias = col.Alias.ToUpper();
                //don't display obj, MI_Key or MI_Style columns
                if(upAlias != "OBJ" && upAlias != "MI_STYLE" && upAlias != "MI_KEY")
                {
                    r = new TableRow();
                    r.BackColor = backColor;

                    r.Cells.Clear();
                    c = new TableCell();
                    c.Text = col.Alias;
                    c.Font.Bold = true;
                    c.ForeColor = Color.RoyalBlue;

                    r.Cells.Add(c);
                    c = new TableCell();
                    c.Text = ftr[col.Alias].ToString();
                    r.Cells.Add(c);
                    infoTable.Rows.Add(r);
                }
            }

            //stream the html table back to client
            StringWriter sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            infoTable.RenderControl(hw);
            String strHTML = sw.ToString();
            HttpContext.Current.Response.Output.Write(strHTML);
        }
        private void ExportExcel()
        {

            #region Declare
            string keyword = txtKeyword.Value;

            var obj = _ProjectData.GetListByYearOrder(Utils.CIntDef(ddlNam.SelectedValue), _Field, _Search);
            double tongNoNam = 0;
            double tongPhiDV1 = 0, tongPhiDV2 = 0, tongPhiDV3 = 0, tongPhiDV4 = 0, tongPhiDV5 = 0, tongPhiDV6 = 0, 
                tongPhiDV7 = 0, tongPhiDV8 = 0, tongPhiDV9 = 0, tongPhiDV10 = 0, tongPhiDV11 = 0, tongPhiDV12 = 0, tongPhiDV13 = 0;
            double tongDaTT1 = 0, tongDaTT2 = 0, tongDaTT3 = 0, tongDaTT4 = 0, tongDaTT5 = 0, tongDaTT6 = 0, 
                tongDaTT7 = 0, tongDaTT8 = 0, tongDaTT9 = 0, tongDaTT10 = 0, tongDaTT11 = 0, tongDaTT12 = 0, tongDaTT13 = 0;
            double tongConNo1 = 0, tongConNo2 = 0, tongConNo3 = 0, tongConNo4 = 0, tongConNo5 = 0, tongConNo6 = 0, 
                tongConNo7 = 0, tongConNo8 = 0, tongConNo9 = 0, tongConNo10 = 0, tongConNo11 = 0, tongConNo12 = 0, tongConNo13 = 0;
            double tongNo = 0;

            string name_ = "CongNoKeToan" + ddlNam.SelectedValue;
            //Tạo bảng
            Table tb = new Table();
            //Định dạng bảng
            tb.CellPadding = 4;
            tb.GridLines = GridLines.Both;
            tb.Font.Name = "Times New Roman";
            
            TableCell cell;
            TableRow row;
            int header = 0;
            #endregion

            #region Header
            row = new TableRow();
            row.Font.Bold = true;
            row.Font.Size = 18;

            cell = new TableCell();
            cell.Height = 40;
            cell.Text = "DANH SÁCH TỔNG HỢP BCT NĂM " + ddlNam.SelectedValue;
            cell.HorizontalAlign = HorizontalAlign.Center;
            cell.ColumnSpan = 5;
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.ColumnSpan = 9;
            row.Cells.Add(cell);

            for (int t = 0; t < 12; t++)
            {
                cell = new TableCell();
                cell.Text = "T" + (t + 1);
                cell.HorizontalAlign = HorizontalAlign.Center;
                cell.ColumnSpan = 4;
                row.Cells.Add(cell);
            }

            cell = new TableCell();
            cell.Text = "BCTC";
            cell.HorizontalAlign = HorizontalAlign.Center;
            cell.ColumnSpan = 4;
            row.Cells.Add(cell);

            header++;
            tb.Rows.Add(row);
            #endregion
            #region Title
            row = new TableRow();
            row.Font.Bold = true;
            row.Font.Size = 12;
            row.Style.Value = "vertical-align: middle";

            List<InfoCells> _iHeader = new List<InfoCells>();
            _iHeader.Add(new InfoCells { Header = "STT", Width = 45 });
            _iHeader.Add(new InfoCells { Header = "Tình Trạng", Width = 100 });
            _iHeader.Add(new InfoCells { Header = "Tên khách hàng", Width = 300 });
            _iHeader.Add(new InfoCells { Header = "Quản lý thuế", Width = 120 });
            _iHeader.Add(new InfoCells { Header = "MST", Width = 80 });
            _iHeader.Add(new InfoCells { Header = "Địa chỉ", Width = 250 });
            _iHeader.Add(new InfoCells { Header = "Giám đốc", Width = 120 });
            _iHeader.Add(new InfoCells { Header = "Điện thoại liên lạc", Width = 120 });
            _iHeader.Add(new InfoCells { Header = "Email", Width = 120 });
            _iHeader.Add(new InfoCells { Header = "Phí", Width = 100 });
            _iHeader.Add(new InfoCells { Header = "Tháng bắt đầu thu", Width = 100 });
            _iHeader.Add(new InfoCells { Header = "NV Kế Toán", Width = 100 });
            _iHeader.Add(new InfoCells { Header = "Năm " + (Utils.CIntDef(ddlNam.SelectedValue) - 1), Width = 100 });

            //Từng tháng
            for (int imonth = 0; imonth < 13; imonth++)
            {
                _iHeader.Add(new InfoCells { Header = "Phí dịch vụ", Width = 100 });
                _iHeader.Add(new InfoCells { Header = "Đã thanh toán", Width = 100 });
                _iHeader.Add(new InfoCells { Header = "Ngày TT", Width = 100 });
                _iHeader.Add(new InfoCells { Header = "Còn nợ", Width = 100 });
            }
            _iHeader.Add(new InfoCells { Header = "TỔNG NỢ", Width = 100 });
            _iHeader.Add(new InfoCells { Header = "NVKD", Width = 100 });
            _iHeader.Add(new InfoCells { Header = "NV Giao Nhận", Width = 100 });
            _iHeader.Add(new InfoCells { Header = "Ghi chú", Width = 200 });

            int ktemp1 = 0;
            int ktemp2 = 0;
            for (int k = 0; k < _iHeader.Count; k++)
            {
                cell = new TableCell();
                if (k < 12 || k > 65)
                {
                    cell.BackColor = System.Drawing.Color.FromName("#99CCFF");
                }
                else if (k == 12)
                {
                    cell.BackColor = System.Drawing.Color.FromName("#00CC00");
                }
                else if (k > 12 && 52 > (k - 13))
                {
                    if (ktemp2 < 4)
                    {
                        if (ktemp1 % 2 == 0)
                        {
                            cell.BackColor = System.Drawing.Color.FromName("#FFFF00");
                            ktemp1 += 2;
                            ktemp2++;
                        }
                        else
                        {
                            cell.BackColor = System.Drawing.Color.FromName("#FF9900");
                            ktemp1 += 2;
                            ktemp2++;
                        }
                    }
                    else
                    {
                        ktemp1++;
                        ktemp2 = 0;
                        if (ktemp1 % 2 == 0)
                        {
                            cell.BackColor = System.Drawing.Color.FromName("#FFFF00");
                            ktemp1 += 2;
                            ktemp2++;
                        }
                        else
                        {
                            cell.BackColor = System.Drawing.Color.FromName("#FF9900");
                            ktemp1 += 2;
                            ktemp2++;
                        }
                    }
                }
                else
                {
                    cell.BackColor = System.Drawing.Color.FromName("#DA8347");
                }
                cell.Height = 60;
                cell.Width = _iHeader[k].Width;
                cell.Text = _iHeader[k].Header;
                cell.HorizontalAlign = HorizontalAlign.Center;
                row.Cells.Add(cell);
            }

            header++;
            tb.Rows.Add(row);
            #endregion
            for (int i = 0; i < obj.Count; i++)
            {
                #region Items
                row = new TableRow();
                row.Font.Size = 10;
                row.Style.Value = "vertical-align: middle";

                List<InfoCells> _items = new List<InfoCells>();
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].STT) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].TINH_TRANG) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].TEN_KH) });
                _items.Add(new InfoCells { Field = getPropertyName(obj[i].QL_THUE_DIST) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].MST) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].DIA_CHI) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].GIAM_DOC) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].DIEN_THOAI) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].EMAIL) });
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].PHI) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].THANG_BD_THU).Replace("12:00:00 AM", "").Trim() });
                _items.Add(new InfoCells { Field = GetUser(obj[i].NV_KT) });

                tongNoNam += Utils.CDblDef(obj[i].NO_NAM_TRUOC);
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].NO_NAM_TRUOC) });

                tongPhiDV1 += Utils.CDblDef(obj[i].PHI_DV_1);
                tongDaTT1 += Utils.CDblDef(obj[i].DA_TT1_1) + Utils.CDblDef(obj[i].DA_TT1_2) + Utils.CDblDef(obj[i].DA_TT1_3) + Utils.CDblDef(obj[i].DA_TT1_4);
                tongConNo1 += Utils.CDblDef(obj[i].CON_NO_1);
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].PHI_DV_1) });
                _items.Add(new InfoCells { Field = fun.Getprice(Utils.CDblDef(obj[i].DA_TT1_1) + Utils.CDblDef(obj[i].DA_TT1_2) + Utils.CDblDef(obj[i].DA_TT1_3) + Utils.CDblDef(obj[i].DA_TT1_4)) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].NGAY_TT_1).Replace("12:00:00 AM", "").Trim() });
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].CON_NO_1) });

                tongPhiDV2 += Utils.CDblDef(obj[i].PHI_DV_2);
                tongDaTT2 += Utils.CDblDef(obj[i].DA_TT2_1) + Utils.CDblDef(obj[i].DA_TT2_2) + Utils.CDblDef(obj[i].DA_TT2_3) + Utils.CDblDef(obj[i].DA_TT2_4);
                tongConNo2 += Utils.CDblDef(obj[i].CON_NO_2);
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].PHI_DV_2) });
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].DA_TT2_1 + obj[i].DA_TT2_2 + obj[i].DA_TT2_3 + obj[i].DA_TT2_4) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].NGAY_TT_2).Replace("12:00:00 AM", "").Trim() });
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].CON_NO_2) });

                tongPhiDV3 += Utils.CDblDef(obj[i].PHI_DV_3);
                tongDaTT3 += Utils.CDblDef(obj[i].DA_TT3_1) + Utils.CDblDef(obj[i].DA_TT3_2) + Utils.CDblDef(obj[i].DA_TT3_3) + Utils.CDblDef(obj[i].DA_TT3_4);
                tongConNo3 += Utils.CDblDef(obj[i].CON_NO_3);
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].PHI_DV_3) });
                _items.Add(new InfoCells { Field = fun.Getprice(Utils.CDblDef(obj[i].DA_TT3_1) + Utils.CDblDef(obj[i].DA_TT3_2) + Utils.CDblDef(obj[i].DA_TT3_3) + Utils.CDblDef(obj[i].DA_TT3_4)) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].NGAY_TT_3).Replace("12:00:00 AM", "").Trim() });
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].CON_NO_3) });

                tongPhiDV4 += Utils.CDblDef(obj[i].PHI_DV_4);
                tongDaTT4 += Utils.CDblDef(obj[i].DA_TT4_1) + Utils.CDblDef(obj[i].DA_TT4_2) + Utils.CDblDef(obj[i].DA_TT4_3) + Utils.CDblDef(obj[i].DA_TT4_4);
                tongConNo4 += Utils.CDblDef(obj[i].CON_NO_4);
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].PHI_DV_4) });
                _items.Add(new InfoCells { Field = fun.Getprice(Utils.CDblDef(obj[i].DA_TT4_1) + Utils.CDblDef(obj[i].DA_TT4_2) + Utils.CDblDef(obj[i].DA_TT4_3) + Utils.CDblDef(obj[i].DA_TT4_4)) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].NGAY_TT_4).Replace("12:00:00 AM", "").Trim() });
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].CON_NO_4) });

                tongPhiDV5 += Utils.CDblDef(obj[i].PHI_DV_5);
                tongDaTT5 += Utils.CDblDef(obj[i].DA_TT5_1) + Utils.CDblDef(obj[i].DA_TT5_2) + Utils.CDblDef(obj[i].DA_TT5_3) + Utils.CDblDef(obj[i].DA_TT5_4);
                tongConNo5 += Utils.CDblDef(obj[i].CON_NO_5);
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].PHI_DV_5) });
                _items.Add(new InfoCells { Field = fun.Getprice(Utils.CDblDef(obj[i].DA_TT5_1) + Utils.CDblDef(obj[i].DA_TT5_2) + Utils.CDblDef(obj[i].DA_TT5_3) + Utils.CDblDef(obj[i].DA_TT5_4)) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].NGAY_TT_5).Replace("12:00:00 AM", "").Trim() });
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].CON_NO_5) });

                tongPhiDV6 += Utils.CDblDef(obj[i].PHI_DV_6);
                tongDaTT6 += Utils.CDblDef(obj[i].DA_TT6_1) + Utils.CDblDef(obj[i].DA_TT6_2) + Utils.CDblDef(obj[i].DA_TT6_3) + Utils.CDblDef(obj[i].DA_TT6_4);
                tongConNo6 += Utils.CDblDef(obj[i].CON_NO_6);
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].PHI_DV_6) });
                _items.Add(new InfoCells { Field = fun.Getprice(Utils.CDblDef(obj[i].DA_TT6_1) + Utils.CDblDef(obj[i].DA_TT6_2) + Utils.CDblDef(obj[i].DA_TT6_3) + Utils.CDblDef(obj[i].DA_TT6_4)) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].NGAY_TT_6).Replace("12:00:00 AM", "").Trim() });
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].CON_NO_6) });

                tongPhiDV7 += Utils.CDblDef(obj[i].PHI_DV_7);
                tongDaTT7 += Utils.CDblDef(obj[i].DA_TT7_1) + Utils.CDblDef(obj[i].DA_TT7_2) + Utils.CDblDef(obj[i].DA_TT7_3) + Utils.CDblDef(obj[i].DA_TT7_4);
                tongConNo7 += Utils.CDblDef(obj[i].CON_NO_7);
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].PHI_DV_7) });
                _items.Add(new InfoCells { Field = fun.Getprice(Utils.CDblDef(obj[i].DA_TT7_1) + Utils.CDblDef(obj[i].DA_TT7_2) + Utils.CDblDef(obj[i].DA_TT7_3) + Utils.CDblDef(obj[i].DA_TT7_4)) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].NGAY_TT_7).Replace("12:00:00 AM", "").Trim() });
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].CON_NO_7) });

                tongPhiDV8 += Utils.CDblDef(obj[i].PHI_DV_8);
                tongDaTT8 += Utils.CDblDef(obj[i].DA_TT8_1) + Utils.CDblDef(obj[i].DA_TT8_2) + Utils.CDblDef(obj[i].DA_TT8_3) + Utils.CDblDef(obj[i].DA_TT8_4);
                tongConNo8 += Utils.CDblDef(obj[i].CON_NO_8);
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].PHI_DV_8) });
                _items.Add(new InfoCells { Field = fun.Getprice(Utils.CDblDef(obj[i].DA_TT8_1) + Utils.CDblDef(obj[i].DA_TT8_2) + Utils.CDblDef(obj[i].DA_TT8_3) + Utils.CDblDef(obj[i].DA_TT8_4)) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].NGAY_TT_8).Replace("12:00:00 AM", "").Trim() });
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].CON_NO_8) });

                tongPhiDV9 += Utils.CDblDef(obj[i].PHI_DV_9);
                tongDaTT9 += Utils.CDblDef(obj[i].DA_TT9_1) + Utils.CDblDef(obj[i].DA_TT9_2) + Utils.CDblDef(obj[i].DA_TT9_3) + Utils.CDblDef(obj[i].DA_TT9_4);
                tongConNo9 += Utils.CDblDef(obj[i].CON_NO_9);
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].PHI_DV_9) });
                _items.Add(new InfoCells { Field = fun.Getprice(Utils.CDblDef(obj[i].DA_TT9_1) + Utils.CDblDef(obj[i].DA_TT9_2) + Utils.CDblDef(obj[i].DA_TT9_3) + Utils.CDblDef(obj[i].DA_TT9_4)) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].NGAY_TT_9).Replace("12:00:00 AM", "").Trim() });
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].CON_NO_9) });

                tongPhiDV10 += Utils.CDblDef(obj[i].PHI_DV_10);
                tongDaTT10 += Utils.CDblDef(obj[i].DA_TT10_1) + Utils.CDblDef(obj[i].DA_TT10_2) + Utils.CDblDef(obj[i].DA_TT10_3) + Utils.CDblDef(obj[i].DA_TT10_4);
                tongConNo10 += Utils.CDblDef(obj[i].CON_NO_10);
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].PHI_DV_10) });
                _items.Add(new InfoCells { Field = fun.Getprice(Utils.CDblDef(obj[i].DA_TT10_1) + Utils.CDblDef(obj[i].DA_TT10_2) + Utils.CDblDef(obj[i].DA_TT10_3) + Utils.CDblDef(obj[i].DA_TT10_4)) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].NGAY_TT_10).Replace("12:00:00 AM", "").Trim() });
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].CON_NO_10) });

                tongPhiDV11 += Utils.CDblDef(obj[i].PHI_DV_11);
                tongDaTT11 += Utils.CDblDef(obj[i].DA_TT11_1) + Utils.CDblDef(obj[i].DA_TT11_2) + Utils.CDblDef(obj[i].DA_TT11_3) + Utils.CDblDef(obj[i].DA_TT11_4);
                tongConNo11 += Utils.CDblDef(obj[i].CON_NO_11);
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].PHI_DV_11) });
                _items.Add(new InfoCells { Field = fun.Getprice(Utils.CDblDef(obj[i].DA_TT11_1) + Utils.CDblDef(obj[i].DA_TT11_2) + Utils.CDblDef(obj[i].DA_TT11_3) + Utils.CDblDef(obj[i].DA_TT11_4)) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].NGAY_TT_11).Replace("12:00:00 AM", "").Trim() });
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].CON_NO_11) });

                tongPhiDV12 += Utils.CDblDef(obj[i].PHI_DV_12);
                tongDaTT12 += Utils.CDblDef(obj[i].DA_TT12_1) + Utils.CDblDef(obj[i].DA_TT12_2) + Utils.CDblDef(obj[i].DA_TT12_3) + Utils.CDblDef(obj[i].DA_TT12_4);
                tongConNo12 += Utils.CDblDef(obj[i].CON_NO_12);
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].PHI_DV_12) });
                _items.Add(new InfoCells { Field = fun.Getprice(Utils.CDblDef(obj[i].DA_TT12_1) + Utils.CDblDef(obj[i].DA_TT12_2) + Utils.CDblDef(obj[i].DA_TT12_3) + Utils.CDblDef(obj[i].DA_TT12_4)) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].NGAY_TT_12).Replace("12:00:00 AM", "").Trim() });
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].CON_NO_12) });

                tongPhiDV13 += Utils.CDblDef(obj[i].PHI_DV_BCTC);
                tongDaTT13 += Utils.CDblDef(obj[i].DA_TT13_1) + Utils.CDblDef(obj[i].DA_TT13_2) + Utils.CDblDef(obj[i].DA_TT13_3) + Utils.CDblDef(obj[i].DA_TT13_4);
                tongConNo13 += Utils.CDblDef(obj[i].CON_NO_BCTC);
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].PHI_DV_BCTC) });
                _items.Add(new InfoCells { Field = fun.Getprice(Utils.CDblDef(obj[i].DA_TT13_1) + Utils.CDblDef(obj[i].DA_TT13_2) + Utils.CDblDef(obj[i].DA_TT13_3) + Utils.CDblDef(obj[i].DA_TT13_4)) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].NGAY_TT_BCTC).Replace("12:00:00 AM", "").Trim() });
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].CON_NO_BCTC) });

                tongNo += Utils.CDblDef(obj[i].TONG_NO);
                _items.Add(new InfoCells { Field = fun.Getprice(obj[i].TONG_NO) });
                _items.Add(new InfoCells { Field = GetUser(obj[i].NV_KD) });
                _items.Add(new InfoCells { Field = GetUser(obj[i].NV_GN) });
                _items.Add(new InfoCells { Field = Utils.CStrDef(obj[i].GHI_CHU) });

                int jtemp1 = 0;
                int jtemp2 = 0;
                for (int j = 0; j < _items.Count; j++)
                {
                    cell = new TableCell();
                    if (j < 12 || j > 65)
                    {
                        if (j == 0 || j == 3 || j == 4)
                            cell.Style.Value = "text-align: center";
                        cell.BackColor = System.Drawing.Color.FromName("#fff");
                    }
                    else if (j == 12)
                        cell.BackColor = System.Drawing.Color.FromName("#00CC00");
                    else if (j > 12 && 52 > (j - 13))
                    {
                        if (jtemp2 < 4)
                        {
                            if (jtemp1 % 2 == 0)
                            {
                                cell.BackColor = System.Drawing.Color.FromName("#FFFF00");
                                jtemp1 += 2;
                                jtemp2++;
                            }
                            else
                            {
                                cell.BackColor = System.Drawing.Color.FromName("#FF9900");
                                jtemp1 += 2;
                                jtemp2++;
                            }
                        }
                        else
                        {
                            jtemp1++;
                            jtemp2 = 0;
                            if (jtemp1 % 2 == 0)
                            {
                                cell.BackColor = System.Drawing.Color.FromName("#FFFF00");
                                jtemp1 += 2;
                                jtemp2++;
                            }
                            else
                            {
                                cell.BackColor = System.Drawing.Color.FromName("#FF9900");
                                jtemp1 += 2;
                                jtemp2++;
                            }
                        }
                    }
                    else
                    {
                        cell.BackColor = System.Drawing.Color.FromName("#DA8347");
                    }

                    cell.Text = _items[j].Field;
                    row.Cells.Add(cell);
                }
                tb.Rows.Add(row);
                #endregion
            }

            #region Footer
            row = new TableRow();
            row.BackColor = System.Drawing.Color.FromName("#C79393");
            row.Font.Size = 10;
            row.Style.Value = "vertical-align: middle";
            row.Font.Bold = true;
            cell = new TableCell();
            cell.Height = 40;
            cell.Text = "Tổng cộng doanh thu DV hàng tháng";
            cell.HorizontalAlign = HorizontalAlign.Center;
            cell.ColumnSpan = 5;
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.ColumnSpan = 7;
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.Text = fun.Getprice(tongNoNam);
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.Text = fun.Getprice(tongPhiDV1);
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongDaTT1);
            row.Cells.Add(cell);
            cell = new TableCell();
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongConNo1);
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.Text = fun.Getprice(tongPhiDV2);
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongDaTT2);
            row.Cells.Add(cell);
            cell = new TableCell();
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongConNo2);
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.Text = fun.Getprice(tongPhiDV3);
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongDaTT3);
            row.Cells.Add(cell);
            cell = new TableCell();
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongConNo3);
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.Text = fun.Getprice(tongPhiDV4);
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongDaTT4);
            row.Cells.Add(cell);
            cell = new TableCell();
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongConNo4);
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.Text = fun.Getprice(tongPhiDV5);
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongDaTT5);
            row.Cells.Add(cell);
            cell = new TableCell();
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongConNo5);
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.Text = fun.Getprice(tongPhiDV6);
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongDaTT6);
            row.Cells.Add(cell);
            cell = new TableCell();
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongConNo6);
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.Text = fun.Getprice(tongPhiDV7);
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongDaTT7);
            row.Cells.Add(cell);
            cell = new TableCell();
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongConNo7);
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.Text = fun.Getprice(tongPhiDV8);
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongDaTT8);
            row.Cells.Add(cell);
            cell = new TableCell();
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongConNo8);
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.Text = fun.Getprice(tongPhiDV9);
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongDaTT9);
            row.Cells.Add(cell);
            cell = new TableCell();
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongConNo9);
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.Text = fun.Getprice(tongPhiDV10);
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongDaTT10);
            row.Cells.Add(cell);
            cell = new TableCell();
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongConNo10);
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.Text = fun.Getprice(tongPhiDV11);
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongDaTT11);
            row.Cells.Add(cell);
            cell = new TableCell();
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongConNo11);
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.Text = fun.Getprice(tongPhiDV12);
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongDaTT12);
            row.Cells.Add(cell);
            cell = new TableCell();
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongConNo12);
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.Text = fun.Getprice(tongPhiDV13);
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongDaTT13);
            row.Cells.Add(cell);
            cell = new TableCell();
            row.Cells.Add(cell);
            cell = new TableCell();
            cell.Text = fun.Getprice(tongConNo13);
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.Text = fun.Getprice(tongNo);
            row.Cells.Add(cell);

            tb.Rows.Add(row);
            #endregion

            #region Process
            Response.Clear();
            Response.Buffer = true;

            string ex_ = "xls";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + name_ + "." + ex_);

            Response.ContentType = "application/vnd.ms-excel";
            Response.Charset = "UTF-8";
            this.EnableViewState = false;
            System.IO.StringWriter sw = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter ht = new System.Web.UI.HtmlTextWriter(sw);
            ht.WriteLine("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
            tb.RenderControl(ht);
            Response.Write(sw.ToString());
            Response.End();
            #endregion
        }
        private void RenderWeekTable(List<TaskData> lstTasks)
        {
            Table tblInfoCallender = new Table();

            string[] dayLabels = EnumDay.getDaysOfTheWeek();

            TableRow tableHRow = new TableRow();
            for (int iCell = 0; iCell < 8; iCell++)
            {
                TableCell tableCell = new TableCell();

                if(iCell>0){
                    Label label = new Label();
                    label.Text = dayLabels[iCell-1];
                    tableCell.Controls.Add(label);
                }

                 tableHRow.Cells.Add(tableCell);
            }
            tblInfoCallender.Rows.Add(tableHRow);

            //Make the rows
            for (int iRow = 0; iRow < 24; iRow++)
            {
                TableRow tableRow = new TableRow();

                for(int iCell=0; iCell < 8; iCell++){
                    TableCell tableCell = new TableCell();
                    if (iCell == 0)
                    {
                        Label lblHour = new Label();
                        lblHour.Text = iRow + ":00";
                        tableCell.Controls.Add(lblHour);
                        tableCell.CssClass = "hour";
                    }
                    else
                    {
                        Label lblId = new Label();
                        lblId.ID = "lblId" + iRow.ToString() + iCell.ToString();
                        lblId.Text = "";
                        tableCell.Controls.Add(lblId);
                        tableCell.CssClass = "calendarCell";
                    }
                    tableRow.Cells.Add(tableCell);
                }
                tblInfoCallender.Rows.Add(tableRow);
            }

            DateTime now = DateTime.Now;

            for(int i=0;i<lstTasks.Count;i++){
                TaskData data = lstTasks[i];

                //Check the day
                TableCell tableCell = null;
                switch (data.Repeat)
                {
                    case (int)EnumSchedule.Task.Once:
                        tableCell = tblInfoCallender.Rows[data.Date.Hour+1].Cells[(int)data.Date.DayOfWeek];
                        tableCell.BackColor = (Color)System.Drawing.ColorTranslator.FromHtml("#d41926");
                        createTaskImageButton(tableCell, data,i);
                        //RenderInfoCell(tableCell, data);
                    break;
                    case (int)EnumSchedule.Task.Dailey:
                        for (int iDayOfWeek = 1; iDayOfWeek < 8; iDayOfWeek++)
                        {
                            tableCell = tblInfoCallender.Rows[data.Date.Hour + 1].Cells[iDayOfWeek];
                            tableCell.BackColor = (Color)System.Drawing.ColorTranslator.FromHtml("#a19f9f");
                            createTaskImageButton(tableCell, data, i + 100 + iDayOfWeek);
                            //RenderInfoCell(tableCell, data);
                        }
                    break;
                    case (int)EnumSchedule.Task.Weekley:
                        tableCell = tblInfoCallender.Rows[data.Date.Hour+1].Cells[(int)data.RepeatDayOftheWeek+1];
                        tableCell.BackColor = (Color)System.Drawing.ColorTranslator.FromHtml("#a19f9f");
                        createTaskImageButton(tableCell, data,i);
                        //RenderInfoCell(tableCell, data);
                    break;
                    case (int)EnumSchedule.Task.Monthly:
                        DateTime monthTime = new DateTime(now.Year,now.Month,(int)data.RepeatDay);
                        tableCell = tblInfoCallender.Rows[data.Date.Hour + 1].Cells[(int)monthTime.DayOfWeek + 1];
                        tableCell.BackColor = (Color)System.Drawing.ColorTranslator.FromHtml("#a19f9f");
                        createTaskImageButton(tableCell, data,i);
                        //RenderInfoCell(tableCell, data);
                    break;
                    case (int)EnumSchedule.Task.Annually:
                        DateTime yearTime = new DateTime(now.Year, (int)data.RepeatMonth, (int)data.RepeatDay);
                        tableCell = tblInfoCallender.Rows[data.Date.Hour + 1].Cells[(int)yearTime.DayOfWeek + 1];
                        tableCell.BackColor = (Color)System.Drawing.ColorTranslator.FromHtml("#a19f9f");
                        createTaskImageButton(tableCell, data,i);
                        //RenderInfoCell(tableCell,data);
                    break;
                }
            }

            TextWriter textWriter = new StringWriter();
            HtmlTextWriter htmlTextWriter = new HtmlTextWriter(textWriter);
            tblInfoCallender.RenderControl(htmlTextWriter);
            containerCalendar.InnerHtml = textWriter.ToString();
        }
        protected void ExportWord(GridView gridView)
        {
            HttpContext.Current.Response.Clear();
            System.Web.HttpContext curContext = System.Web.HttpContext.Current;
            curContext.Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("StaffAppraisal.doc"));

            HttpContext.Current.Response.ContentType = "application/ms-word";

            //  Create a table to contain the grid
            Table table = new Table();

            //  include the gridline settings
            table.GridLines = gridView.GridLines;

            //  add the header row to the table
            if (gridView.HeaderRow != null)
            {
                PrepareControlForExport(gridView.HeaderRow);
                gridView.HeaderRow.Style.Add("background", "black");
                table.Rows.Add(gridView.HeaderRow);
            }

            //  add each of the data rows to the table

            foreach (GridViewRow row in gridView.Rows)
            {
                PrepareControlForExport(row);
                table.Rows.Add(row);
            }

            //  add the footer row to the table
            if (gridView.FooterRow != null)
            {
                PrepareControlForExport(gridView.FooterRow);
                table.Rows.Add(gridView.FooterRow);
            }

            for (int i = 0; i <= gridView.Rows.Count; i++)
            {
                table.Rows[i].Cells[0].Visible = false;
            }

            using (StringWriter stringWriter = new StringWriter())
            {
                using (HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter))
                {
                    //  render the table into the htmlwriter
                    table.RenderControl(htmlWriter);

                    //  render the htmlwriter into the response
                    curContext.Response.Write(stringWriter.ToString());
                    curContext.Response.End();
                }
            }
        }
 private void RenderTable(HttpContext context, Table table)
 {
     StringWriter writer1 = new StringWriter();
     HtmlTextWriter writer2 = new HtmlTextWriter(writer1);
     table.RenderControl(writer2);
     context.Response.Write("<div class='tableDetail'>");
     context.Response.Write(writer1.ToString());
     context.Response.Write("</div>");
 }
        protected override void Render(HtmlTextWriter w)
        {
            EnsureChildControls();

            Table t = new Table();
            t.BorderWidth = 0;
            t.CellPadding = 0;
            t.CellSpacing = 0;

            TableRow r = null; 
            TableCell c = null;

            r = new TableRow();
            c = new TableCell();
            c.Controls.Add(img);
            r.Cells.Add(c);
            t.Rows.Add(r);

            r = new TableRow();
            c = new TableCell();
            c.Controls.Add(lnk);
            r.Cells.Add(c);
            t.Rows.Add(r);

            t.RenderControl(w);
        }
Example #39
0
        private void RenderErrors(HtmlTextWriter writer)
        {
            Debug.Assert(writer != null);

            //
            // Create a table to display error information in each row.
            //

            Table table = new Table();
            table.ID = "ErrorLog";
            table.CellSpacing = 0;

            //
            // Create the table row for headings.
            //

            TableRow headRow = new TableRow();

            headRow.Cells.Add(FormatCell(new TableHeaderCell(), "Host", "host-col"));
            headRow.Cells.Add(FormatCell(new TableHeaderCell(), "Code", "code-col"));
            headRow.Cells.Add(FormatCell(new TableHeaderCell(), "Type", "type-col"));
            headRow.Cells.Add(FormatCell(new TableHeaderCell(), "Error", "error-col"));
            headRow.Cells.Add(FormatCell(new TableHeaderCell(), "User", "user-col"));
            headRow.Cells.Add(FormatCell(new TableHeaderCell(), "Date", "date-col"));
            headRow.Cells.Add(FormatCell(new TableHeaderCell(), "Time", "time-col"));

            table.Rows.Add(headRow);

            //
            // Generate a table body row for each error.
            //

            for (int errorIndex = 0; errorIndex < _errorEntryList.Count; errorIndex++)
            {
                ErrorLogEntry errorEntry = (ErrorLogEntry) _errorEntryList[errorIndex];
                Error error = errorEntry.Error;

                TableRow bodyRow = new TableRow();
                bodyRow.CssClass = errorIndex % 2 == 0 ? "even-row" : "odd-row";

                //
                // Format host and status code cells.
                //

                bodyRow.Cells.Add(FormatCell(new TableCell(), error.HostName, "host-col"));
                bodyRow.Cells.Add(FormatCell(new TableCell(), error.StatusCode.ToString(), "code-col", Mask.NullString(HttpWorkerRequest.GetStatusDescription(error.StatusCode))));
                bodyRow.Cells.Add(FormatCell(new TableCell(), ErrorDisplay.HumaneExceptionErrorType(error), "type-col", error.Type));

                //
                // Format the message cell, which contains the message
                // text and a details link pointing to the page where
                // all error details can be viewed.
                //

                TableCell messageCell = new TableCell();
                messageCell.CssClass = "error-col";

                Label messageLabel = new Label();
                messageLabel.Text = this.Server.HtmlEncode(error.Message);

                HyperLink detailsLink = new HyperLink();
                detailsLink.NavigateUrl = BasePageName + "/detail?id=" + HttpUtility.UrlEncode(errorEntry.Id);
                detailsLink.Text = "Details&hellip;";

                messageCell.Controls.Add(messageLabel);
                messageCell.Controls.Add(new LiteralControl(" "));
                messageCell.Controls.Add(detailsLink);

                bodyRow.Cells.Add(messageCell);

                //
                // Format the user, date and time cells.
                //

                bodyRow.Cells.Add(FormatCell(new TableCell(), error.User, "user-col"));
                bodyRow.Cells.Add(FormatCell(new TableCell(), error.Time.ToShortDateString(), "date-col",
                    error.Time.ToLongDateString()));
                bodyRow.Cells.Add(FormatCell(new TableCell(), error.Time.ToShortTimeString(), "time-col",
                    error.Time.ToLongTimeString()));

                //
                // Finally, add the row to the table.
                //

                table.Rows.Add(bodyRow);
            }

            table.RenderControl(writer);
        }
Example #40
0
        public void ExportToExcel(AlertPurchaseOrderType?type, string provider, string product, string purchaseOrder, DateTime?fromDate, DateTime?untilDate, bool?license, string column, string order, WayOfDelivery?wayOfDelivery)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-us");// Thread.CurrentThread.CurrentUICulture;

            GridView grdProductList = new GridView();

            grdProductList.AutoGenerateColumns = false;

            #region Columns
            BoundField bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "PurchaseOrderCode";
            bf.HeaderText      = "OC";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "PurchaseOrderProviderCode";
            bf.HeaderText      = "C&oacute;digo de Proveedor";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "ProductCode";
            bf.HeaderText      = "Producto";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "ProductDescription";
            bf.HeaderText      = "Descripci&oacute;n";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "Quantity";
            bf.HeaderText      = "Cantidad";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width  = Unit.Pixel(95);
            bf.DataField        = "ArrivalDate";
            bf.HeaderText       = "Confirmaci&oacute;n";
            bf.HtmlEncode       = false;
            bf.DataFormatString = "{0:dd/MM/yyyy}";
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width  = Unit.Pixel(95);
            bf.DataField        = "PurchaseOrderDate";
            bf.HeaderText       = "Creada";
            bf.HtmlEncode       = false;
            bf.DataFormatString = "{0:dd/MM/yyyy}";
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "GAP";
            bf.HeaderText      = "GAP";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "WayOfDelivery";
            bf.HeaderText      = "Modo Env&iacute;o";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "Type";
            bf.HeaderText      = "Status";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);
            #endregion
            grdProductList.DataSource = Search(type, provider, product, purchaseOrder, fromDate, untilDate, license, column, order, wayOfDelivery);

            grdProductList.DataBind();

            HttpContext.Current.Response.Clear();

            HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename=SeguimientoOC.xls"));

            HttpContext.Current.Response.ContentType = "application/ms-excel";

            StringWriter   sw  = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            System.Web.UI.WebControls.Table table = new System.Web.UI.WebControls.Table();
            table.GridLines = grdProductList.GridLines;

            //Set the Cell format
            string codeFormat = @"<style>.cF  { mso-number-format:'\@'; }</style>";

            //  add the header row to the table
            if (grdProductList.HeaderRow != null)
            {
                PrepareControlForExport(grdProductList.HeaderRow);
                table.Rows.Add(grdProductList.HeaderRow);
                table.Rows[0].ForeColor = Color.FromArgb(102, 102, 102);

                for (int i = 0; i < table.Rows[0].Cells.Count; i++)
                {
                    table.Rows[0].Cells[i].BackColor = Color.FromArgb(225, 224, 224);
                }
            }

            //  add each of the data rows to the table
            foreach (GridViewRow row in grdProductList.Rows)
            {
                PrepareControlForExport(row);
                int pos = table.Rows.Add(row);
                table.Rows[pos].Cells[1].Attributes.Add("class", "cF");
                table.Rows[pos].Cells[2].Attributes.Add("class", "cF");
                table.Rows[pos].Cells[3].Width = 300;
            }

            //  render the table into the htmlwriter
            table.RenderControl(htw);

            //  render the htmlwriter into the response adding de style
            HttpContext.Current.Response.Write(codeFormat + sw.ToString());
            HttpContext.Current.Response.End();
        }
        public void ExportToExcel(string column, string order, int type)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-us");// Thread.CurrentThread.CurrentUICulture;

            GridView grdProductList = new GridView();

            grdProductList.AutoGenerateColumns = false;

            #region Columns

            BoundField bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "ProductCode";
            bf.HeaderText      = "Producto";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            if (type == 1)
            {
                bf = new BoundField();
                bf.ItemStyle.Width = Unit.Pixel(95);
                bf.DataField       = "StandardCost";
                bf.HeaderText      = "Costo Standard";
                bf.HtmlEncode      = false;
                grdProductList.Columns.Add(bf);

                bf = new BoundField();
                bf.ItemStyle.Width = Unit.Pixel(295);
                bf.DataField       = "Subtotal";
                bf.HeaderText      = "SubTotal";
                bf.HtmlEncode      = false;
                grdProductList.Columns.Add(bf);
            }
            else
            {
                bf = new BoundField();
                bf.ItemStyle.Width = Unit.Pixel(95);
                bf.DataField       = "NegativeDate";
                bf.HeaderText      = "Fecha de Quiebre";
                bf.HtmlEncode      = false;
                grdProductList.Columns.Add(bf);
            }

            bf = new BoundField();
            bf.ItemStyle.Width = Unit.Pixel(95);
            bf.DataField       = "Quantity";
            bf.HeaderText      = "Cantidad";
            bf.HtmlEncode      = false;
            grdProductList.Columns.Add(bf);

            #endregion

            if (!string.IsNullOrEmpty(column))
            {
                grdProductList.DataSource = ShowAlert(column, order, type);
            }
            else
            {
                if (type == 1)
                {
                    grdProductList.DataSource = ShowAlert3();
                }
                else
                {
                    grdProductList.DataSource = ShowAlert5();
                }
            }
            grdProductList.DataBind();

            HttpContext.Current.Response.Clear();
            if (type == 1)
            {
                HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename=ProductosConStockNegativo.xls"));
            }
            else
            {
                HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename=StockQueCaeraDelSafety.xls"));
            }

            HttpContext.Current.Response.ContentType = "application/ms-excel";

            StringWriter   sw  = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            System.Web.UI.WebControls.Table table = new System.Web.UI.WebControls.Table();
            table.GridLines = grdProductList.GridLines;

            //Set the Cell format
            string codeFormat = @"<style>.cF  { mso-number-format:'\@'; }</style>";

            //  add the header row to the table
            if (grdProductList.HeaderRow != null)
            {
                PrepareControlForExport(grdProductList.HeaderRow);
                table.Rows.Add(grdProductList.HeaderRow);
                table.Rows[0].ForeColor = Color.FromArgb(102, 102, 102);

                for (int i = 0; i < table.Rows[0].Cells.Count; i++)
                {
                    table.Rows[0].Cells[i].BackColor = Color.FromArgb(225, 224, 224);
                }
            }

            //  add each of the data rows to the table
            foreach (GridViewRow row in grdProductList.Rows)
            {
                PrepareControlForExport(row);
                int pos = table.Rows.Add(row);
                table.Rows[pos].Cells[0].Attributes.Add("class", "cF");
                if (type == 1)
                {
                    table.Rows[pos].Cells[1].Text            = "$ " + table.Rows[pos].Cells[1].Text;
                    table.Rows[pos].Cells[2].Text            = "$ " + table.Rows[pos].Cells[2].Text;
                    table.Rows[pos].Cells[1].HorizontalAlign = HorizontalAlign.Left;
                    table.Rows[pos].Cells[2].HorizontalAlign = HorizontalAlign.Left;
                    table.Rows[pos].Cells[3].HorizontalAlign = HorizontalAlign.Left;
                }
            }

            //  render the table into the htmlwriter
            table.RenderControl(htw);

            //  render the htmlwriter into the response adding de style
            HttpContext.Current.Response.Write(codeFormat + sw.ToString());
            HttpContext.Current.Response.End();
        }
Example #42
0
        protected void  generar(Object Sender, EventArgs e)
        {
            string [] pr = new string[2];
            pr[0] = pr[1] = "";
            Press frontEnd = new Press(new DataSet(), reportTitle);

            frontEnd.PreHeader(tabPreHeader, Grid.Width, pr);
            frontEnd.Firmas(tabFirmas, Grid.Width);
            lb.Text = "";
//////////////FECHA////////////
            int    Año1  = Convert.ToInt32(añoI.SelectedValue.ToString());
            int    Año2  = Convert.ToInt32(añoF.SelectedValue.ToString());
            int    Mes1  = Convert.ToInt32(DBFunctions.SingleData("select PMES_MES from DBXSCHEMA.PMES WHERE PMES_NOMBRE='" + mesI.SelectedValue.ToString() + "'"));
            int    Mes2  = Convert.ToInt32(DBFunctions.SingleData("select PMES_MES from DBXSCHEMA.PMES WHERE PMES_NOMBRE='" + mesF.SelectedValue.ToString() + "'"));
            int    dia1  = 1;
            int    dia2  = 1;
            string dia1S = diaI.Text;
            string dia2S = diaF.Text;

            if (dia1S.ToString().Equals(null) || dia1S.ToString().Equals("0"))
            {
                dia1 = 1;
            }
            else
            {
                dia1 = Convert.ToInt32(diaI.Text.ToString());
            }
            if (dia2S.ToString().Equals(null) || dia2S.ToString().Equals("0"))
            {
                dia2 = Convert.ToInt32(DateTime.Now.Day);
            }
            else
            {
                dia2 = Convert.ToInt32(diaF.Text.ToString());
            }

            string fecha  = Año1 + "-" + Mes1 + "-" + dia1;
            string fecha2 = Año2 + "-" + Mes2 + "-" + dia2;

///////////////////////////////
/////opciones de estado comparendo
            if (pago.Checked.Equals(true))
            {
                queryEstado = "AND MCOM_ESTADO =1";
            }
            if (nopago.Checked.Equals(true))
            {
                queryEstado = "AND MCOM_ESTADO =3";
            }
            if (proceso.Checked.Equals(true))
            {
                queryEstado = "AND MCOM_ESTADO =2";
            }
            if (todos.Checked.Equals(true))
            {
                queryEstado = " ";
            }
//////////////////////////////////////////////////
////seleccion conductor

            conductoresS = conductor.SelectedValue.ToString();

            if (conductoresS.Equals("0"))
            {
                queryF = "select MCOM_FECHACOM,MCOM_INFRACCION,MCOM_CONDUCTOR,MCOM_ESTADO,MCOM_NUMCOM FROM DBXSCHEMA.MCOMPARENDOS WHERE MCOM_FECHACOM BETWEEN '" + fecha + "' AND '" + fecha2 + "'  " + queryEstado + " ";
            }
            else
            {
                string nit = DBFunctions.SingleData("select MNIT.MNIT_NIT FROM DBXSCHEMA.MNIT MNIT WHERE MNIT.MNIT_NOMBRES CONCAT ' ' CONCAT coalesce(MNIT.MNIT_NOMBRE2,'') CONCAT ' ' CONCAT MNIT.MNIT_APELLIDOS CONCAT ' 'CONCAT coalesce(MNIT.MNIT_APELLIDO2,'') ='" + conductoresS + "' ");
                queryF = "select MCOM_FECHACOM,MCOM_INFRACCION,MCOM_CONDUCTOR,MCOM_ESTADO,MCOM_NUMCOM FROM DBXSCHEMA.MCOMPARENDOS WHERE MCOM_FECHACOM BETWEEN '" + fecha + "' AND '" + fecha2 + "'  " + queryEstado + " AND MCOM_CONDUCTOR='" + nit + "' ";
            }
///////////////////////////////////////////////////////


            this.PrepararTabla();
            lineas = new DataSet();

            DBFunctions.Request(lineas, IncludeSchema.NO, " " + queryF + " ");
            for (int i = 0; i < lineas.Tables[0].Rows.Count; i++)
            {
                string infraccion       = null;
                int    codigoinfraccion = 0;
                double valorcomparendo  = 0;
                codigoinfraccion = Convert.ToInt32(lineas.Tables[0].Rows[i].ItemArray[1].ToString());
                infraccion       = DBFunctions.SingleData("Select DESC_COMPARENDO from DBXSCHEMA.TCOMPARENDO WHERE COD_COMPARENDO=" + codigoinfraccion + " ");
                valorcomparendo  = Convert.ToDouble(DBFunctions.SingleData("Select VALO_COMPARENDO from DBXSCHEMA.TCOMPARENDO WHERE COD_COMPARENDO=" + codigoinfraccion + " "));
                string estadoIn         = null;
                int    estadoInfraccion = Convert.ToInt32(lineas.Tables[0].Rows[i].ItemArray[3].ToString());
                estadoIn = DBFunctions.SingleData("Select DESC_ESTACOMPA from DBXSCHEMA.TESTADO_COMPARENDO WHERE COD_ESTACOMPA=" + estadoInfraccion + " ");
                string nombreco = DBFunctions.SingleData("select MNIT.MNIT_NOMBRES CONCAT ' ' CONCAT coalesce(MNIT.MNIT_NOMBRE2,'') CONCAT ' ' CONCAT MNIT.MNIT_APELLIDOS CONCAT ' 'CONCAT coalesce(MNIT.MNIT_APELLIDO2,'') AS NOMBRE FROM DBXSCHEMA.MNIT MNIT WHERE MNIT.MNIT_NIT='" + lineas.Tables[0].Rows[i].ItemArray[2].ToString() + "' ");


                //Vamos a crear una fila para nuestro DataTable resultado, que almacene los resultados de las operaciones anteriores
                DataRow fila;

                fila = resultado.NewRow();

                string ValorFormato = null;
                ValorFormato = String.Format("{0:C}", valorcomparendo);



                fila["FECHA"]         = lineas.Tables[0].Rows[i].ItemArray[0].ToString();
                fila["NUMCOMPARENDO"] = lineas.Tables[0].Rows[i].ItemArray[4].ToString();
                fila["INFRACCION"]    = infraccion.ToString();
                fila["VALOR"]         = ValorFormato.ToString();
                fila["CONDUCTOR"]     = nombreco.ToString();
                fila["ESTADO"]        = estadoIn.ToString();


                resultado.Rows.Add(fila);
            }

            //fin sentencia FOR
            Grid.DataSource = resultado;
            Grid.DataBind();
            StringBuilder  SB     = new StringBuilder();
            StringWriter   SW     = new StringWriter(SB);
            HtmlTextWriter htmlTW = new HtmlTextWriter(SW);

            tabPreHeader.RenderControl(htmlTW);
            Grid.RenderControl(htmlTW);
            tabFirmas.RenderControl(htmlTW);
            string strRep;

            strRep = SB.ToString();
            Session.Clear();
            Session["Rep"]      = strRep;
            toolsHolder.Visible = true;
        }
Example #43
0
        protected void  generar(Object Sender, EventArgs e)
        {
            string [] pr = new string[2];
            pr[0] = pr[1] = "";
            Press frontEnd = new Press(new DataSet(), reportTitle);

            frontEnd.PreHeader(tabPreHeader, Grid.Width, pr);
            frontEnd.Firmas(tabFirmas, Grid.Width);
            lb.Text = "";


            ///////////////////////////////////////////////////////
            this.PrepararTabla();
            lineas = new DataSet();
            string fecha  = Convert.ToDateTime(FechaInicio.Text).ToString("yyyy-MM-dd");
            string fecha1 = Convert.ToDateTime(FechaFinal.Text).ToString("yyyy-MM-dd");

            try
            {
                DBFunctions.Request(lineas, IncludeSchema.NO, "select distinct mbus.mbus_numero as NUMEROBUS,drut.mcat_placa as PLACA,tciu.tciu_nombre as CIUDADORIGEN,tciu1.tciu_nombre as CIUDADDESTINO,mrut.mrut_valor as VALOR,drut.drut_horasal as HORASALIDA,drut.drut_fecha as FECHA,drut.drut_codigo as CODIGORUTA,drut.drut_planilla as NUMEROPLANILLA,drut.drut_codrelevante as RELEVANTE from dbxschema.druta drut,dbxschema.druta drut1,dbxschema.dtiquete dtiq,dbxschema.mruta mrut, dbxschema.tciudad tciu,dbxschema.tciudad tciu1,dbxschema.tciudad tciu2,dbxschema.mbusafiliado mbus where drut.drut_fecha between '" + fecha + "' and '" + fecha1 + "' and  drut.drut_codigo=drut.drut_codigo and drut.mrut_codigo=mrut.mrut_codigo and mrut.tciu_cod=tciu.tciu_codigo and mrut.tciu_coddes=tciu1.tciu_codigo and mbus.mcat_placa=drut.mcat_placa and tciu.tciu_nombre=(select tciu.TCIU_nombre from dbxschema.MOFICINA mofi,dbxschema.tciudad tciu where mofi_codigo='" + ddlagencia.SelectedValue + "'and tciu.tciu_codigo=mofi.tciu_codigo)order by drut.drut_fecha,tciu1.tciu_nombre");
            }
            catch (Exception t)
            {
                Response.Write("<script language:javascript>alert('No se Encuentra Ningun Reporte De esta Bus'); </script>" + t.Message);
            }
            for (int i = 0; i < lineas.Tables[0].Rows.Count; i++)

            {
                //Vamos a crear una fila para nuestro DataTable resultado, que almacene los resultados de las operaciones anteriores
                string lineas1   = DBFunctions.SingleData("Select count (*) from DBXSCHEMA.DTIQUETE where  drut_codigo=" + lineas.Tables[0].Rows[i][7].ToString() + "");
                string lineas2   = DBFunctions.SingleData("Select count(*)from dbxschema.dtiquete where drut_codigo=" + lineas.Tables[0].Rows[i].ItemArray[7].ToString() + " and test_codigo='RS'");
                int    puestosre = 0;
                int    puestos   = 0;
                if (lineas2.Length == 0)
                {
                    puestosre = 0;
                    puestos   = Convert.ToInt32(lineas1);
                }
                else
                {
                    puestos   = Convert.ToInt32(lineas1);
                    puestosre = Convert.ToInt32(lineas2);
                }
                string capacidad      = DBFunctions.SingleData("SELECT pcat.pcat_capacidad FROM dbxschema.pcatalogovehiculo pcat,dbxschema.druta druta,dbxschema.mruta mruta,dbxschema.mbusafiliado mbus,dbxschema.mcatalogovehiculo mcat WHERE druta.drut_codigo=" + lineas.Tables[0].Rows[i][7].ToString() + " and druta.mrut_codigo=mruta.mrut_codigo and druta.mcat_placa=mbus.mcat_placa and mbus.mcat_placa=mcat.mcat_placa and pcat.pcat_codigo=mcat.pcat_codigo");
                string disponibilidad = ((System.Convert.ToInt32(capacidad)) - (System.Convert.ToInt32(DBFunctions.SingleData("SELECT COUNT(*) FROM dpuestoruta WHERE drut_codigo=" + lineas.Tables[0].Rows[i][7].ToString() + " AND (test_codigo<>'LI')").Trim()))).ToString();


                DataRow fila;
                fila = resultado.NewRow();
                fila["NUMERO BUS"]          = lineas.Tables[0].Rows[i].ItemArray[0].ToString();
                fila["PLACA"]               = lineas.Tables[0].Rows[i].ItemArray[1].ToString();
                fila["ORIGEN"]              = lineas.Tables[0].Rows[i].ItemArray[2].ToString();
                fila["DESTINO"]             = lineas.Tables[0].Rows[i].ItemArray[3].ToString();
                fila["VALOR"]               = lineas.Tables[0].Rows[i].ItemArray[4].ToString();
                fila["HORA SALIDA"]         = lineas.Tables[0].Rows[i].ItemArray[5].ToString();
                fila["FECHA"]               = lineas.Tables[0].Rows[i].ItemArray[6].ToString();
                fila["CODIGO RUTA"]         = lineas.Tables[0].Rows[i].ItemArray[7].ToString();
                fila["NUMERO PLANILLA"]     = lineas.Tables[0].Rows[i].ItemArray[8].ToString();
                fila["RELEVANTE"]           = lineas.Tables[0].Rows[i].ItemArray[9].ToString();
                fila["NUMERO DE PASAJEROS"] = puestos - puestosre;
                fila["DISPONIBLES"]         = disponibilidad;
                fila["TOTAL"]               = puestos * Convert.ToDouble(lineas.Tables[0].Rows[i].ItemArray[4]);
                resultado.Rows.Add(fila);
            }

            //fin sentencia FOR
            Grid.DataSource = resultado;
            Grid.DataBind();
            StringBuilder  SB     = new StringBuilder();
            StringWriter   SW     = new StringWriter(SB);
            HtmlTextWriter htmlTW = new HtmlTextWriter(SW);

            tabPreHeader.RenderControl(htmlTW);
            Grid.RenderControl(htmlTW);
            tabFirmas.RenderControl(htmlTW);
            string strRep;

            strRep = SB.ToString();
            Session.Clear();
            Session["Rep"]      = strRep;
            toolsHolder.Visible = true;
        }
Example #44
0
		public override string GetDesignTimeHtml() 
		{
			StringWriter sw = new StringWriter();
			HtmlTextWriter writer = new HtmlTextWriter(sw);

			Table menu = new Table();				
			menu.CellSpacing = menuInstance.ItemSpacing;
			menu.CellPadding = menuInstance.ItemPadding;
			
			// Display the Menu based on its specified Layout
			if (menuInstance.Layout == MenuLayout.Vertical)
			{
				for (int i = 1; i <= 5; i++)
				{
					TableRow tr = new TableRow();
					TableCell td = new TableCell();
					td.ApplyStyle(menuInstance.UnselectedMenuItemStyle);
					// The style is overwritten by anything specifically set in menuitem
					if (menuInstance.BackColor != Color.Empty) 
						td.BackColor = menuInstance.BackColor;
					if (menuInstance.Font != null)
						td.Font.CopyFrom(menuInstance.Font);
					if (menuInstance.ForeColor != Color.Empty)
						td.ForeColor = menuInstance.ForeColor;
					if (menuInstance.Height != Unit.Empty)
						td.Height = menuInstance.Height;
					if (menuInstance.Width != Unit.Empty)
						td.Width = menuInstance.Width;
					if (menuInstance.CssClass != String.Empty)
						td.CssClass = menuInstance.CssClass;
					else if	(menuInstance.DefaultCssClass != String.Empty)
						td.CssClass = menuInstance.DefaultCssClass;
					if (menuInstance.BorderColor != Color.Empty)
						td.BorderColor = menuInstance.BorderColor;
					if (menuInstance.BorderStyle != BorderStyle.NotSet)
						td.BorderStyle = menuInstance.BorderStyle;
					if (menuInstance.BorderWidth != Unit.Empty)
						td.BorderWidth = menuInstance.BorderWidth;						
					td.Text = "Menu Item " + i.ToString();
					tr.Cells.Add(td);
					menu.Rows.Add(tr);
				}
			}
			else
			{
				TableRow tr = new TableRow();
				for (int i = 1; i <= 5; i++)
				{						
					TableCell td = new TableCell();
					td.ApplyStyle(menuInstance.UnselectedMenuItemStyle);
					// The style is overwritten by anything specifically set in menuitem
					if (menuInstance.BackColor != Color.Empty) 
						td.BackColor = menuInstance.BackColor;
					if (menuInstance.Font != null)
						td.Font.CopyFrom(menuInstance.Font);
					if (menuInstance.ForeColor != Color.Empty)
						td.ForeColor = menuInstance.ForeColor;
					if (menuInstance.Height != Unit.Empty)
						td.Height = menuInstance.Height;
					if (menuInstance.Width != Unit.Empty)
						td.Width = menuInstance.Width;
					if (menuInstance.CssClass != String.Empty)
						td.CssClass = menuInstance.CssClass;
					else if	(menuInstance.DefaultCssClass != String.Empty)
						td.CssClass = menuInstance.DefaultCssClass;
					if (menuInstance.BorderColor != Color.Empty)
						td.BorderColor = menuInstance.BorderColor;
					if (menuInstance.BorderStyle != BorderStyle.NotSet)
						td.BorderStyle = menuInstance.BorderStyle;
					if (menuInstance.BorderWidth != Unit.Empty)
						td.BorderWidth = menuInstance.BorderWidth;
					td.Text = "Menu Item " + i.ToString();
					tr.Cells.Add(td);						
				}
				menu.Rows.Add(tr);
			}

			menu.RenderControl(writer);
			return sw.ToString();
		}
Example #45
0
        private void RenderCollection(HtmlTextWriter writer,
            NameValueCollection collection, string id, string title)
        {
            Debug.Assert(writer != null);
            Debug.AssertStringNotEmpty(id);
            Debug.AssertStringNotEmpty(title);

            //
            // If the collection isn't there or it's empty, then bail out.
            //

            if (collection == null || collection.Count == 0)
                return;

            //
            // Surround the entire section with a <div> element.
            //

            writer.AddAttribute(HtmlTextWriterAttribute.Id, id);
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            //
            // Write out the table caption.
            //

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "table-caption");
            writer.RenderBeginTag(HtmlTextWriterTag.P);
            this.HtmlEncode(title, writer);
            writer.RenderEndTag(); // </p>
            writer.WriteLine();

            //
            // Some values can be large and add scroll bars to the page
            // as well as ruin some formatting. So we encapsulate the
            // table into a scrollable view that is controlled via the
            // style sheet.
            //

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "scroll-view");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            //
            // Create a table to display the name/value pairs of the
            // collection in 2 columns.
            //

            Table table = new Table();
            table.CellSpacing = 0;

            //
            // Create the header row and columns.
            //

            TableRow headRow = new TableRow();

            TableHeaderCell headCell;

            headCell = new TableHeaderCell();
            headCell.Wrap = false;
            headCell.Text = "Name";
            headCell.CssClass = "name-col";

            headRow.Cells.Add(headCell);

            headCell = new TableHeaderCell();
            headCell.Wrap = false;
            headCell.Text = "Value";
            headCell.CssClass = "value-col";

            headRow.Cells.Add(headCell);

            table.Rows.Add(headRow);

            //
            // Create a row for each entry in the collection.
            //

            string[] keys = collection.AllKeys;
            Array.Sort(keys, StringComparer.InvariantCulture);

            for (int keyIndex = 0; keyIndex < keys.Length; keyIndex++)
            {
                string key = keys[keyIndex];

                TableRow bodyRow = new TableRow();
                bodyRow.CssClass = keyIndex % 2 == 0 ? "even-row" : "odd-row";

                TableCell cell;

                //
                // Create the key column.
                //

                cell = new TableCell();
                cell.Text = HtmlEncode(key);
                cell.CssClass = "key-col";

                bodyRow.Cells.Add(cell);

                //
                // Create the value column.
                //

                cell = new TableCell();
                cell.Text = HtmlEncode(collection[key]);
                cell.CssClass = "value-col";

                bodyRow.Cells.Add(cell);

                table.Rows.Add(bodyRow);
            }

            //
            // Write out the table and close container tags.
            //

            table.RenderControl(writer);

            writer.RenderEndTag(); // </div>
            writer.WriteLine();

            writer.RenderEndTag(); // </div>
            writer.WriteLine();
        }
Example #46
0
        protected override void Render(HtmlTextWriter w)
        {
            try
            {
                EnsureChildControls();

                Table t = new Table();
                t.BorderWidth = 0;
                t.CellPadding = 0;
                t.CellSpacing = 0;

                TableRow r = null;
                TableCell c = null;

                r = new TableRow();
                c = new TableCell();
                c.Controls.Add(gv);
                r.Cells.Add(c);
                t.Rows.Add(r);

                t.RenderControl(w);
            }
            catch (Exception ex)
            {
                UWeb.Error(w, ex);
            }
        }
Example #47
0
        //public
        /// <summary> 
        /// Render this control to the output parameter specified.
        /// </summary>
        /// <param name="output"> The HTML writer to write out to </param>
        protected override void Render(HtmlTextWriter output)
        {
            NdiMenuItem item0 =
            new NdiMenuItem(0, "Szabadszöveges keresés", "Szabadszöveges", "SearchFreetext.aspx", "_images/searchFreeTextS.gif",
                        "_images/searchFreeTextL.gif");
              NdiMenuItem item1 =
            new NdiMenuItem(1, "Kulcsszavas keresés", "Kulcsszavas", "SearchKeyword.aspx", "_images/searchKexWordS.gif",
                        "_images/searchKexWordL.gif");
              NdiMenuItem item2 =
            new NdiMenuItem(2, "Tematikus keresés", "Tematikus", "SearchByQuestionForm.aspx", "_images/searchQuestionFormS.gif",
                        "_images/searchQuestionFormL.gif");
              NdiMenuItem item3 =
            new NdiMenuItem(3, "Megyék szerinti keresés", "Megyék szerint", "SearchMap.aspx", "_images/searchMapS.gif",
                        "_images/searchMapL.gif");
              NdiMenuItem item4 =
            new NdiMenuItem(4, "Szervezetek listája", "Szervezetek", "OrganisationList.aspx", "_images/searchOrganisationS.gif",
                        "_images/searchOrganisationL.gif");
              NdiMenuItem item5 =
            new NdiMenuItem(5, "Programok listája", "Programok", "ProgramList.aspx", "_images/searchProgramS.gif",
                        "_images/searchProgramL.gif");
              NdiMenuItem item6 =
            new NdiMenuItem(6, "Szakemberek listája", "Szakemberek", "ExpertList.aspx", "_images/searchExpertS.gif",
                        "_images/searchExpertL.gif");

              Table table = new Table();
              table.CellPadding = 0;
              table.CellSpacing = 0;
              table.CssClass = "almenu";
              TableRow row1 = new TableRow();
              TableRow row2 = new TableRow();
              TableCell cell0 = CreateCell(item0);

              TableCell cell2 = CreateCell(item2);
              TableCell cell3 = CreateCell(item3);
              TableCell cell4 = CreateCell(item4);
              TableCell cell5 = CreateCell(item5);
              TableCell cell6 = CreateCell(item6);
              table.Rows.Add(row2);
              table.Rows.Add(row1);
              if (item0.Index == m_selectedindex)
            row1.Cells.Add(cell0);
              else
            row2.Cells.Add(cell0);

              // A keyword menu configból jön
              if (GetMenuVisibility("SearchKeywordMenu.Visibility"))
              {
            TableCell cell1 = CreateCell(item1);
            if (item1.Index == m_selectedindex)
              row1.Cells.Add(cell1);
            else
              row2.Cells.Add(cell1);
              }
              if (item2.Index == m_selectedindex)
            row1.Cells.Add(cell2);
              else
            row2.Cells.Add(cell2);
              if (item3.Index == m_selectedindex)
            row1.Cells.Add(cell3);
              else
            row2.Cells.Add(cell3);
              if (item4.Index == m_selectedindex)
            row1.Cells.Add(cell4);
              else
            row2.Cells.Add(cell4);
              if (item5.Index == m_selectedindex)
            row1.Cells.Add(cell5);
              else
            row2.Cells.Add(cell5);

              if (Context != null && Context.User != null && Context.User.Identity != null && Context.User.Identity.IsAuthenticated)
              {
            if (item6.Index == m_selectedindex)
              row1.Cells.Add(cell6);
            else
              row2.Cells.Add(cell6);
              }
              if(row1.Cells != null && row1.Cells.Count> 0 && row2.Cells != null && row2.Cells.Count > 0)
              {
            row1.Cells[0].ColumnSpan = row2.Cells.Count;

              }
              table.Width = Unit.Percentage(100);

              table.RenderControl(output);
        }
        private void RenderCollection(HtmlTextWriter w, NameValueCollection c, string id, string title)
        {
            if (c == null || c.Count == 0) return;

            w.AddAttribute(HtmlTextWriterAttribute.Id, id);
            w.RenderBeginTag(HtmlTextWriterTag.Div);

            w.AddAttribute(HtmlTextWriterAttribute.Class, "table-caption");
            w.RenderBeginTag(HtmlTextWriterTag.P);
            this.Server.HtmlEncode(title, w);
            w.RenderEndTag(); // </p>
            w.WriteLine();

            w.AddAttribute(HtmlTextWriterAttribute.Class, "scroll-view");
            w.RenderBeginTag(HtmlTextWriterTag.Div);

            Table table = new Table();
            table.CellSpacing = 0;

            string[] keys = c.AllKeys;
            Array.Sort(keys, Comparer.DefaultInvariant);
            int i = 0;

            foreach (var key in keys)
            {
                string value = c[key];

                if (!String.IsNullOrEmpty(value) && !IsHidden(key))
                {

                    bool unimportant = IsUnimportant(key);
                    string matchingKeys = "";

                    if (!unimportant)
                    {
                        matchingKeys = GetMatchingKeys(c, value);
                        if (matchingKeys != null)
                        {
                            _hidden_keys += matchingKeys.Replace(", ", "|") + "|";
                        }
                    }

                    TableRow bodyRow = new TableRow();

                    if (unimportant)
                        bodyRow.CssClass = "unimportant-row";
                    else
                    {
                        i++;
                        bodyRow.CssClass = i % 2 == 0 ? "even-row" : "odd-row";
                    }

                    TableCell cell;

                    // key
                    cell = new TableCell();
                    if (!String.IsNullOrEmpty(matchingKeys))
                        cell.Text = Server.HtmlEncode(matchingKeys);
                    else
                        cell.Text = Server.HtmlEncode(key);
                    cell.CssClass = "key-col";
                    bodyRow.Cells.Add(cell);

                    // value
                    cell = new TableCell();
                    cell.Text = PrepareCell(value);
                    cell.CssClass = "value-col";
                    bodyRow.Cells.Add(cell);

                    table.Rows.Add(bodyRow);
                }

            }

            table.RenderControl(w);

            w.RenderEndTag(); // </div>
            w.WriteLine();
            w.RenderEndTag(); // </div>
            w.WriteLine();
        }
        /// <summary>
        /// Parses out the survey HTML for use in an email or printing.
        /// </summary>
        /// <param name="responseHeaderId">The response header id.</param>
        /// <param name="title">The title.</param>
        /// <param name="displayName">The display name.</param>
        /// <returns>
        /// A string containing table based html that represents a survey.
        /// </returns>
        private string GenerateTableBasedSurvey(int responseHeaderId, string title, string displayName)
        {
            var builder = new StringBuilder();
            string body = this.Localize("SurveyCompleted_Body.Text");
            if (body != null)
            {
                body = body.Replace(Utility.UserNameMarker, displayName);
                body = body.Replace(Utility.SurveyInformationMarker, title);

                var survey = new SurveyRepository().LoadReadOnlySurvey(responseHeaderId, this.ModuleId);
                var table = new Table();
                var sb = new StringBuilder();
                var writer = new HtmlTextWriter(new StringWriter(sb));
                survey.Render(table, new DnnLocalizer(this.LocalResourceFile));
                table.RenderControl(writer);

                body = body.Replace(Utility.SurveyTableMarker, sb.ToString());
                builder.Append(body);
            }

            ////Because the output of the controls are type "input" the disabled, checked and selected properties must be changed
            ////to just disabled, checked and selected to be recognized by certain email clients i.e. Hotmail.
            return
                    builder.ToString().Replace('"', '\'').Replace(Environment.NewLine, string.Empty).Replace("\t", string.Empty).Replace(
                            "='selected'", string.Empty).Replace("='disabled'", string.Empty).Replace("='checked'", string.Empty);
        }
Example #50
0
    protected void btn_export_Click(object sender, EventArgs e)
    {
        DataView view = new DataView();

        view.Table = (DataTable)this.ViewState["lista"];
        if (view.Count == 0)
        {
            utils.ShowMessage2(this, "exportar", "warn_sinFilas"); return;
        }
        view.Table.Columns.Remove(view.Table.Columns["ID_SOLICITUDANDEN"]);
        view.Table.Columns.Remove(view.Table.Columns["USUA_ID"]);
        view.Table.Columns.Remove(view.Table.Columns["ORDEN"]);
        view.Table.Columns.Remove(view.Table.Columns["ID_ESTADOANDEN"]);
        view.Table.Columns.Remove(view.Table.Columns["ESTADOANDEN"]);
        view.Table.Columns.Remove(view.Table.Columns["ID_ESTADOSOLICITUD"]);
        view.Table.Columns.Remove(view.Table.Columns["SOLI_FH_CREACION_2"]);
        view.Table.Columns.Remove(view.Table.Columns["FECHA_RESERVA_ANDEN_2"]);
        view.Table.Columns.Remove(view.Table.Columns["FECHA_PUESTA_ANDEN_2"]);
        view.Table.Columns.Remove(view.Table.Columns["ID_TRANSPORTISTA"]);
        view.Table.Columns.Remove(view.Table.Columns["PLAY_ID"]);
        view.Table.Columns.Remove(view.Table.Columns["PLAYA"]);
        view.Table.Columns.Remove(view.Table.Columns["ID_LUGAR"]);
        GridView gv = new GridView();

        gv.DataSource = view;
        gv.DataBind();

        string fileName = "reporte_Carga.xls";

        PrepareControlForExport(gv);
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.AddHeader("Content-type", "application / xls");

        HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));
        HttpContext.Current.Response.Charset = "";
        HttpContext.Current.Response.Cache.SetCacheability(System.Web.HttpCacheability.Public);
        HttpContext.Current.Response.ContentType = "application/ms-excel";
        try
        {
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    System.Web.UI.WebControls.Table table = new System.Web.UI.WebControls.Table();
                    table.GridLines = gv.GridLines;

                    if (gv.HeaderRow != null)
                    {
                        PrepareControlForExport(gv.HeaderRow);
                        table.Rows.Add(gv.HeaderRow);
                    }

                    foreach (GridViewRow row in gv.Rows)
                    {
                        PrepareControlForExport(row);
                        table.Rows.Add(row);
                    }

                    if (gv.FooterRow != null)
                    {
                        PrepareControlForExport(gv.FooterRow);
                        table.Rows.Add(gv.FooterRow);
                    }

                    gv.GridLines = GridLines.Both;
                    table.RenderControl(htw);
                    HttpContext.Current.Response.Write(sw.ToString());
                    HttpContext.Current.Response.End();
                }
            }
        }
        catch (HttpException ex)
        {
            throw ex;
        }
    }
Example #51
0
 public override string GetDesignTimeHtml()
 {
     StringWriter sw = new StringWriter();
     HtmlTextWriter htw = new HtmlTextWriter(sw);
     Table t = new Table();
     t.BorderColor = Color.Navy;
     t.BackColor =  ColorTranslator.FromHtml("#B6C9E7");
     t.BorderStyle = BorderStyle.Solid;
     TableRow tr = new TableRow();
     tr.Width = 120;
     tr.Height = 150;
     TableCell td = new TableCell();
     td.Text = string.Format("<strong>ScottWater</strong><br>Book Control<br>{0}",bc.ID);
     td.VerticalAlign = VerticalAlign.Middle;
     td.HorizontalAlign = HorizontalAlign.Center;
     tr.Cells.Add(td);
     t.Rows.Add(tr);
     t.RenderControl(htw);
     return sw.ToString();
 }
 protected void ShowRequests(IList data)
 {
     Table t = new Table {
         CellPadding = 0,
         CellSpacing = 0,
         Width = Unit.Percentage(100.0)
     };
     AddCell(AddRow(t), System.Web.SR.GetString("Trace_Application_Trace"));
     string applicationPath = this._request.ApplicationPath;
     int length = applicationPath.Length;
     AddCell(AddRow(t), "<h2>" + HttpUtility.HtmlEncode(applicationPath.Substring(1)) + "<h2><p>");
     AddCell(AddRow(t), "[ <a href=\"Trace.axd?clear=1\" class=\"link\">" + System.Web.SR.GetString("Trace_Clear_Current") + "</a> ]");
     string text = "&nbsp";
     if (HttpRuntime.HasAppPathDiscoveryPermission())
     {
         text = System.Web.SR.GetString("Trace_Physical_Directory") + this._request.PhysicalApplicationPath;
     }
     TableCell cell = AddCell(AddRow(t), text);
     t.RenderControl(this._writer);
     t = new Table {
         CellPadding = 0,
         CellSpacing = 0,
         Width = Unit.Percentage(100.0)
     };
     TableRow trow = AddRow(t);
     cell = AddHeaderCell(trow, "<h3><b>" + System.Web.SR.GetString("Trace_Requests_This") + "</b></h3>");
     cell.ColumnSpan = 5;
     cell.CssClass = "alt";
     cell.HorizontalAlign = HorizontalAlign.Left;
     cell = AddHeaderCell(trow, System.Web.SR.GetString("Trace_Remaining") + " " + HttpRuntime.Profile.RequestsRemaining.ToString(NumberFormatInfo.InvariantInfo));
     cell.CssClass = "alt";
     cell.HorizontalAlign = HorizontalAlign.Right;
     trow = AddRow(t);
     trow.HorizontalAlign = HorizontalAlign.Left;
     trow.CssClass = "subhead";
     AddHeaderCell(trow, System.Web.SR.GetString("Trace_No"));
     AddHeaderCell(trow, System.Web.SR.GetString("Trace_Time_of_Request"));
     AddHeaderCell(trow, System.Web.SR.GetString("Trace_File"));
     AddHeaderCell(trow, System.Web.SR.GetString("Trace_Status_Code"));
     AddHeaderCell(trow, System.Web.SR.GetString("Trace_Verb"));
     AddHeaderCell(trow, "&nbsp");
     bool flag = true;
     for (int i = 0; i < data.Count; i++)
     {
         DataSet set = (DataSet) data[i];
         trow = AddRow(t);
         if (flag)
         {
             trow.CssClass = "alt";
         }
         AddCell(trow, (i + 1).ToString(NumberFormatInfo.InvariantInfo));
         AddCell(trow, (string) set.Tables["Trace_Request"].Rows[0]["Trace_Time_of_Request"]);
         AddCell(trow, ((string) set.Tables["Trace_Request"].Rows[0]["Trace_Url"]).Substring(length));
         AddCell(trow, set.Tables["Trace_Request"].Rows[0]["Trace_Status_Code"].ToString());
         AddCell(trow, (string) set.Tables["Trace_Request"].Rows[0]["Trace_Request_Type"]);
         TableCell cell2 = AddCell(trow, string.Empty);
         HtmlAnchor child = new HtmlAnchor {
             HRef = "Trace.axd?id=" + i,
             InnerHtml = "<nobr>" + System.Web.SR.GetString("Trace_View_Details")
         };
         child.Attributes["class"] = "link";
         cell2.Controls.Add(child);
         flag = !flag;
     }
     t.RenderControl(this._writer);
 }