Inheritance: System.Web.UI.WebControls.CompositeDataBoundControl, ICallbackEventHandler, ICallbackContainer, IPostBackEventHandler, IPostBackContainer
        protected void btnExcel_Click(object sender, EventArgs e)
        {
            //Create a dummy GridView
            GridView GridView1 = new GridView();
            GridView1.AllowPaging = false;
            GridView1.DataSource = BindGridView();
            GridView1.DataBind();

            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition",
             "attachment;filename=" + DateTime.Now.Year + "-Newly_Hired" + ".xls");
            Response.Charset = "";
            Response.ContentType = "application/vnd.ms-excel";
            StringWriter sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                //Apply text style to each Row
                GridView1.Rows[i].Attributes.Add("class", "textmode");
            }
            GridView1.RenderControl(hw);

            //style to format numbers to string
            string style = @"<style> .textmode { mso-number-format:\@; } </style>";
            Response.Write(style);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
        }
        protected void AddRepairsNewEmptyFix(GridView grdView)
        {
            if (grdRepairs.Rows.Count == 0)
            {
                int companyId = Int32.Parse(hdfCompanyId.Value);
                PointRepairsTDS.RepairDetailsDataTable dt = new PointRepairsTDS.RepairDetailsDataTable();
                dt.AddRepairDetailsRow(-1, "PL-A", "Temp", "", DateTime.Now, "", "", 0, "", "", "", "", DateTime.Now, "", "", DateTime.Now, "", false, false, "", false, companyId, false, "", "", "", DateTime.Now);
                Session["pointRepairsRepairsTempDummy"] = dt;
                SetFilter("Type='Temp' AND Deleted = 0");
                grdRepairs.DataBind();
            }

            // normally executes at all postbacks
            if (grdRepairs.Rows.Count == 1)
            {
                PointRepairsTDS.RepairDetailsDataTable dt = (PointRepairsTDS.RepairDetailsDataTable)Session["pointRepairsRepairsTempDummy"];
                if (dt != null)
                {
                    grdRepairs.Rows[0].Visible = false;
                    grdRepairs.Rows[0].Controls.Clear();

                    Session.Remove("pointRepairsRepairsTempDummy");
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            GridView grid = new GridView();
            DataTable dt = new DataTable();
            List<Usuario> lista = new List<Usuario>();
            UsuarioBL uBL = new UsuarioBL();
            lista = uBL.buscaUsuariosEmpresa(Convert.ToInt16(Session["empresa"].ToString()));

            DataColumn c1 = new DataColumn("Email", Type.GetType("System.String"));
            DataColumn c2 = new DataColumn("Nome", Type.GetType("System.String"));
            DataColumn c3 = new DataColumn("Empresa", Type.GetType("System.String"));
            DataColumn c4 = new DataColumn("Licença", Type.GetType("System.String"));
            DataColumn c5 = new DataColumn("editar", Type.GetType("System.String"));

            dt.Columns.Add(c1);
            dt.Columns.Add(c2);
            dt.Columns.Add(c3);
            dt.Columns.Add(c4);
            dt.Columns.Add(c5);

            foreach (Usuario u in lista)
            {
                DataRow dr = dt.NewRow();
                dr["Email"] = u.email.ToString();
                dr["Nome"] = u.nome.ToString();
                dr["Empresa"] = u.idEmpresa.ToString();
                dr["Licença"] = u.dataFimLicenca.ToShortDateString();
                dr["editar"] = "~/EditarUsuario.aspx?user_mail=" + u.email.ToString();
                dt.Rows.Add(dr);
            }
            gridUsuarios.DataSource = dt.Copy();
            gridUsuarios.DataBind();
        }
        public static long Add(string book, DateTime valueDate, string partyCode, int priceTypeId, GridView grid, string referenceNumber, string statementReference)
        {
            MixERP.Net.Common.Models.Transactions.StockMasterModel stockMaster = new MixERP.Net.Common.Models.Transactions.StockMasterModel();
            Collection<MixERP.Net.Common.Models.Transactions.StockMasterDetailModel> details = new Collection<MixERP.Net.Common.Models.Transactions.StockMasterDetailModel>();
            long nonGlStockMasterId = 0;

            stockMaster.PartyCode = partyCode;
            stockMaster.PriceTypeId = priceTypeId;

            if(grid != null)
            {
                if(grid.Rows.Count > 0)
                {
                    foreach(GridViewRow row in grid.Rows)
                    {
                        MixERP.Net.Common.Models.Transactions.StockMasterDetailModel detail = new MixERP.Net.Common.Models.Transactions.StockMasterDetailModel();

                        detail.ItemCode = row.Cells[0].Text;
                        detail.Quantity = MixERP.Net.Common.Conversion.TryCastInteger(row.Cells[2].Text);
                        detail.UnitName = row.Cells[3].Text;
                        detail.Price = MixERP.Net.Common.Conversion.TryCastDecimal(row.Cells[4].Text);
                        detail.Discount = MixERP.Net.Common.Conversion.TryCastDecimal(row.Cells[6].Text);
                        detail.TaxRate = MixERP.Net.Common.Conversion.TryCastDecimal(row.Cells[8].Text);
                        detail.Tax = MixERP.Net.Common.Conversion.TryCastDecimal(row.Cells[9].Text);

                        details.Add(detail);
                    }
                }
            }

            nonGlStockMasterId = MixERP.Net.DatabaseLayer.Transactions.NonGLStockTransaction.Add(book, valueDate, MixERP.Net.BusinessLayer.Helpers.SessionHelper.OfficeId(), MixERP.Net.BusinessLayer.Helpers.SessionHelper.UserId(), MixERP.Net.BusinessLayer.Helpers.SessionHelper.LogOnId(), referenceNumber, statementReference, stockMaster, details);
            return nonGlStockMasterId;
        }
Example #5
0
        /// <summary>
        ///  gridview显示title的方法
        /// </summary>
        /// Copyright (c) 
        /// 创 建 人:王好([email protected])
        /// 创建日期:2012年2月1日
        /// 修 改 人:王好
        /// 修改日期:
        /// 版 本: 
        /// <param name="gv"></param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public static string CreateTitle(GridView gv, bool flag = false)
        {
            if (!flag)
            {
                return "没有找到相关的信息";
            }
            else
            {
                StringBuilder strHtmlStream = new StringBuilder("");

                //根据gv创建title
                string tb = string.Format(@"<table class='{0}' cellspacing='{1}'  border='0'  style='border-collapse:collapse;'>"
                                                     , "gridviewEmptyTableStyle", gv.CellSpacing);
                strHtmlStream.Append(tb + "<tr class='" + gv.HeaderStyle.CssClass + "'>");
                for (int index = 0; index < gv.Columns.Count; index++)
                {
                    strHtmlStream.Append("<td >");
                    strHtmlStream.Append(gv.Columns[index].HeaderText.ToString());//文字
                    strHtmlStream.Append("</td>");
                }
                //结尾
                strHtmlStream.Append(string.Format("</tr><tr><td colspan='{0}'>没有找到相关的信息</td></tr></table>", gv.Columns.Count));
                // 返回字符串脚本



                return strHtmlStream.ToString();
            }






        }
Example #6
0
        public static long Add(DateTime valueDate, string referenceNumber, int costCenterId, GridView grid)
        {
            Collection<MixERP.Net.Common.Models.Transactions.TransactionDetailModel> details = new Collection<MixERP.Net.Common.Models.Transactions.TransactionDetailModel>();
            long transactionMasterId = 0;

            if(grid != null)
            {
                if(grid.Rows.Count > 0)
                {
                    foreach(GridViewRow row in grid.Rows)
                    {
                        MixERP.Net.Common.Models.Transactions.TransactionDetailModel detail = new MixERP.Net.Common.Models.Transactions.TransactionDetailModel();
                        detail.AccountCode = row.Cells[0].Text;
                        detail.CashRepositoryName = row.Cells[2].Text;
                        detail.StatementReference = row.Cells[3].Text.Replace("&nbsp;", " ").Trim();
                        detail.Debit = MixERP.Net.Common.Conversion.TryCastDecimal(row.Cells[4].Text);
                        detail.Credit = MixERP.Net.Common.Conversion.TryCastDecimal(row.Cells[5].Text);

                        details.Add(detail);
                    }
                }
            }

            transactionMasterId = MixERP.Net.DatabaseLayer.Transactions.Transaction.Add(valueDate, MixERP.Net.BusinessLayer.Helpers.SessionHelper.GetOfficeId(), MixERP.Net.BusinessLayer.Helpers.SessionHelper.GetUserId(), MixERP.Net.BusinessLayer.Helpers.SessionHelper.GetLogOnId(), costCenterId, referenceNumber, details);
            MixERP.Net.DatabaseLayer.Transactions.Verification.CallAutoVerification(transactionMasterId);
            return transactionMasterId;
        }
Example #7
0
 /// <summary>
 /// GridView合并行,
 /// </summary>
 /// <param name="gv">GridView</param>
 /// <param name="startCol">开始列</param>
 /// <param name="endCol">结束列</param>
 public void MergeRow(GridView gv, int startCol, int endCol)
 {
     RowArg init = new RowArg()
     {
         StartRowIndex = 0,
         EndRowIndex = gv.Rows.Count - 2
     };
     for (int i = startCol; i < endCol + 1; i++)
     {
         if (i > 0)
         {
             List<RowArg> list = new List<RowArg>();
             //从第二列开始就要遍历前一列
             TraversesPrevCol(gv, i - 1, list);
             foreach (var item in list)
             {
                 MergeRowCol(gv, i, item.StartRowIndex, item.EndRowIndex);
             }
         }
         //合并开始列的行
         else
         {
             MergeRowCol(gv, i, init.StartRowIndex, init.EndRowIndex);
         }
     }
 }
        protected void ChecklistRulesInformationEmptyFix(GridView grdChecklistRulesInformation)
        {
            if (grdChecklistRulesInformation.Rows.Count == 0)
            {
                DateTime lastService = new DateTime();
                DateTime nextDue = new DateTime();
                UnitInformationTDS.ChecklistDetailsDataTable dt = new UnitInformationTDS.ChecklistDetailsDataTable();
                dt.AddChecklistDetailsRow(0, "", "", lastService, nextDue, false, "Unknown", false);
                Session["unitsChecklistRulesEditDummy"] = dt;

                grdChecklistRulesInformation.DataBind();
            }

            // normally executes at all postbacks
            if (grdChecklistRulesInformation.Rows.Count == 1)
            {
                UnitInformationTDS.ChecklistDetailsDataTable dt = (UnitInformationTDS.ChecklistDetailsDataTable)Session["unitsChecklistRulesEditDummy"];
                if (dt != null)
                {
                    // hide row
                    grdChecklistRulesInformation.Rows[0].Visible = false;
                    grdChecklistRulesInformation.Rows[0].Controls.Clear();
                }
            }
        }
Example #9
0
        public static void UpdateAdminRoomGrid(GridView gv)
        {
            if (superRoomList.Count == 0)
            {
                return;
            }

            if (gv.Rows.Count != superRoomList.Count)
            {
                return;
            }

            for (var i = 0; i < superRoomList.Count; i++)
            {
                var r = superRoomList[i];
                gv.Rows[i].Cells[0].Text = r.Name;
                gv.Rows[i].Cells[1].Text = r.MaxParticipants.ToString();

                var s = string.Empty;
                int j;
                for (j = 0; j < r.Inventories.Count() - 1; j++)
                {
                    s += r.Inventories[j].ProductName + ", ";
                }

                if (r.Inventories.Count() != 0)
                {
                    s += r.Inventories[j].ProductName;
                }

                gv.Rows[i].Cells[2].Text = s;
            }
        }
 /// <summary> 
 /// 合并GridView中某列相同信息的行(单元格) 
 /// </summary> 
 /// <param name="GridView1">GridView</param> 
 /// <param name="cellNum">第几列</param>
 public static void GroupRows(GridView GridView1, int cellNum)
 {
     int i = 0, rowSpanNum = 1;
     while (i < GridView1.Rows.Count - 1)
     {
         GridViewRow gvr = GridView1.Rows[i];
         for (++i; i < GridView1.Rows.Count; i++)
         {
             GridViewRow gvrNext = GridView1.Rows[i];
             if (gvr.Cells[cellNum].Text == gvrNext.Cells[cellNum].Text)
             {
                 gvrNext.Cells[cellNum].Visible = false;
                 rowSpanNum++;
             }
             else
             {
                 gvr.Cells[cellNum].RowSpan = rowSpanNum;
                 rowSpanNum = 1;
                 break;
             }
             if (i == GridView1.Rows.Count - 1)
             {
                 gvr.Cells[cellNum].RowSpan = rowSpanNum;
             }
         }
     }
 }
Example #11
0
 public List<int> SyncDepartmentIDs(GridView gv, List<int> DepartmentIDs)
 {
     for (int i = 0; i < gv.Rows.Count; i++)
     {
         bool isChecked = ((CheckBox)gv.Rows[i].FindControl("CheckOne")).Checked;
         if (isChecked)  // Add to filter list
         {
             //int DepartmentID = (int)gv.DataKeys[i].Value;
             int DepartmentID = int.Parse(gv.Rows[i].Cells[1].Text);
             DepartmentIDs.Add(DepartmentID);
         }
         else    // Remove from filter list
         {
             //int DepartmentID = (int)gv.DataKeys[i].Value;
             int DepartmentID = int.Parse(gv.Rows[i].Cells[1].Text);
             for (int k = 0; k < DepartmentIDs.Count; k++)
             {
                 if (DepartmentIDs[k] == DepartmentID)
                 {
                     DepartmentIDs.RemoveAt(k);
                 }
             }
         }
     }
     return DepartmentIDs;
 }
Example #12
0
 internal static void Show(GridView ListTests, string UserName)
 {
     SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString);
     string str = "select d.Discipline_name, c.categories_name, t.name, ct.points, ct.dateComplite " +
         " from Complite_test as ct inner join test as t on ct.test_id = t.test_id " +
         " inner join Categories as c on c.cat_id = t.cat_id " +
         " inner join discipline as d on d.discipline_id = c.discipline_id " +
         " inner join users as u on u.user_id = ct.user_id where u.login = @login";
     SqlCommand cmd = new SqlCommand(str, con);
     cmd.Parameters.AddWithValue("login", UserName);
     try
     {
         con.Open();
         SqlDataSource ds = new SqlDataSource(con.ConnectionString, str);
         Parameter p = new Parameter("login", System.Data.DbType.String, UserName);
         ds.SelectParameters.Add(p);
         ListTests.DataSource = ds;
         ListTests.DataBind();
     }
     catch (Exception)
     {
         throw new ApplicationException("Не удается отобразить список завершенных тестов");
     }
     finally {
         con.Close();
     }
 }
Example #13
0
        /// <summary>
        /// Sets the sort image states.
        /// </summary>
        /// <param name="gridView">The grid view.</param>
        /// <param name="row">The row.</param>
        /// <param name="columnStartIndex"> </param>
        /// <param name="sortField">The sort field.</param>
        /// <param name="sortAscending">if set to <c>true</c> [sort ascending].</param>
        public static void SetSortImageStates(GridView gridView, GridViewRow row,int columnStartIndex, string sortField, bool sortAscending)
        {
            for (var i = columnStartIndex; i < row.Cells.Count; i++)
            {
                var tc = row.Cells[i];
                if (!tc.HasControls()) continue;

                // search for the header link  
                var lnk = tc.Controls[0] as LinkButton;
                if (lnk == null) continue;

                // initialize a new image
                var img = new Image
                {
                    ImageUrl = string.Format("~/images/{0}.png", (sortAscending ? "bullet_arrow_up" : "bullet_arrow_down")),
                    CssClass = "icon"
                };

                // setting the dynamically URL of the image
                // checking if the header link is the user's choice
                if (sortField == lnk.CommandArgument)
                {
                    // adding a space and the image to the header link
                    //tc.Controls.Add(new LiteralControl(" "));
                    tc.Controls.Add(img);
                }
            }
        }
        public void ExportClientsListToExcel()
        {
            var grid = new System.Web.UI.WebControls.GridView();
            string[] ClientsList={"mike","jonh","vladimit"};
            grid.DataSource = /*from d in dbContext.diners
                              where d.user_diners.All(m => m.user_id == userID) && d.active == true */
                              from d in ClientsList
                              select new
                              {
                                  FirstName = d
                              };

            grid.DataBind();

            Response.ClearContent();
            Response.AddHeader("content-disposition", "attachment; filename=Exported_Diners.xls");
            Response.ContentType = "application/excel";
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            grid.RenderControl(htw);

            Response.Write(sw.ToString());

            Response.End();
        }
        protected override void CreateChildControls()
        {
            //create new gridview object
            _gridView = new GridView
            {
                ID = string.Format("{0}_gridView", base.ID),
                AutoGenerateColumns = false
            };

            //Create Custom Field
            var customField = new TemplateField
            {
                HeaderTemplate = new SetTemplate(DataControlRowType.Header, "Name"),
                ItemTemplate = new SetTemplate(DataControlRowType.DataRow)
            };

            //Add custom field to gridview column
            _gridView.Columns.Add(customField);

            //Set test data list to datasource
            _gridView.DataSource = _list;

            //Bind gridview
            _gridView.DataBind();

            //Add gridview to composite control
            Controls.Add(_gridView);
        }
        public ActionResult ViewCards(CardInput cardInput)
        {
            if (ModelState.IsValid)
            {
                CardGenerator cardGenerator = new CardGenerator(cardInput.GeneratingDate, cardInput.NumberOfCards);
                List<Card> CardList = cardGenerator.GetCardsList();
                CardDAO cardDAO = new CardDAO();
                if (!cardDAO.ISExsistCardDate(CardList[0].CardNumber))
                {
                    GridView gridView = new GridView();
                    gridView.DataSource = CardList;
                    gridView.DataBind();
                    Session["CardsListEXCEL"] = gridView;
                    Session["CardsList"] = CardList;

                    return View(CardList);
                }
                else
                {
                    ModelState.AddModelError("", "You have already generated cards on this date, so choose aonther date. ");
                    return View("ShowCards");

                }

            }
            else
            {
                ModelState.AddModelError("", "Card List is not available");
                return View("ShowCards");
            }
        }
 /// <summary>
 /// 合并GridView中某列相同信息的行(单元格)
 /// </summary>
 /// <param name="GridView1"></param>
 /// <param name="cellNum"></param>
 public static void GroupCol(GridView gridView, int cols)
 {
     if (gridView.Rows.Count < 1 || cols > gridView.Rows[0].Cells.Count - 1)
         {
             return;
         }
         TableCell oldTc = gridView.Rows[0].Cells[cols];
         for (int i = 1; i < gridView.Rows.Count; i++)
         {
             TableCell tc = gridView.Rows[i].Cells[cols];
             if (oldTc.Text == tc.Text)
             {
                 tc.Visible = false;
                 if (oldTc.RowSpan == 0)
                 {
                     oldTc.RowSpan = 1;
                 }
                 oldTc.RowSpan++;
                 oldTc.VerticalAlign = VerticalAlign.Middle;
             }
             else
             {
                 oldTc = tc;
             }
         }
 }
Example #18
0
        /// <summary>
        /// Sets the sort image states.
        /// </summary>
        /// <param name="gridView">The grid view.</param>
        /// <param name="row">The row.</param>
        /// <param name="sortField">The sort field.</param>
        /// <param name="sortAscending">if set to <c>true</c> [sort ascending].</param>
        public static void SetSortImageStates(GridView gridView, GridViewRow row,int columnStartIndex, string sortField, bool sortAscending)
        {
            for (int i = columnStartIndex; i < row.Cells.Count; i++)
            {
                TableCell tc = row.Cells[i];
                if (tc.HasControls())
                {
                    // search for the header link
                    LinkButton lnk = (LinkButton)tc.Controls[0];
                    if (lnk != null)
                    {
                        // initialize a new image
                        System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
                        // setting the dynamically URL of the image
                        img.ImageUrl = "~/images/" + (sortAscending ? "bullet_arrow_up" : "bullet_arrow_down") + ".png";
                        img.CssClass = "icon";
                        // checking if the header link is the user's choice
                        if (sortField == lnk.CommandArgument)
                        {
                            // adding a space and the image to the header link
                            //tc.Controls.Add(new LiteralControl(" "));
                            tc.Controls.Add(img);
                        }

                    }
                }
            }
        }
Example #19
0
        /// <summary>
        /// Sets the pager button states.
        /// </summary>
        /// <param name="gridView">The grid view.</param>
        /// <param name="gvPagerRow">The gv pager row.</param>
        /// <param name="page">The page.</param>
        public static void SetPagerButtonStates(GridView gridView, GridViewRow gvPagerRow, Page page)
        {
            int pageIndex = gridView.PageIndex;
            int pageCount = gridView.PageCount;

            ImageButton btnFirst = (ImageButton)gvPagerRow.FindControl("btnFirst");
            ImageButton btnPrevious = (ImageButton)gvPagerRow.FindControl("btnPrevious");
            ImageButton btnNext = (ImageButton)gvPagerRow.FindControl("btnNext");
            ImageButton btnLast = (ImageButton)gvPagerRow.FindControl("btnLast");

            btnFirst.Enabled = btnPrevious.Enabled = (pageIndex != 0);
            btnNext.Enabled = btnLast.Enabled = (pageIndex < (pageCount - 1));

            DropDownList ddlPageSelector = (DropDownList)gvPagerRow.FindControl("ddlPages");
            ddlPageSelector.Items.Clear();
            for (int i = 1; i <= gridView.PageCount; i++)
            {
                ddlPageSelector.Items.Add(i.ToString());
            }

            ddlPageSelector.SelectedIndex = pageIndex;

            Label lblPageCount = (Label)gvPagerRow.FindControl("lblPageCount");
            lblPageCount.Text = pageCount.ToString();

            //ddlPageSelector.SelectedIndexChanged += delegate
            //{
            //    gridView.PageIndex = ddlPageSelector.SelectedIndex;
            //    gridView.DataBind();
            //};
        }
        public ActionResult ViewBalanceSheet(BalanceSheetInput balanceSheet)
        {
            if (ModelState.IsValid)
            {
                TimeSpan timeSpan = (balanceSheet.MonthEnd - balanceSheet.MonthStart);
                if (timeSpan.Days >= 0)
                {
                    BalanceSheetDAO BalanceSheetDAO = new BalanceSheetDAO();
                    List<BalanceSheet> BalanceSheetList = BalanceSheetDAO.GetMonthlyBaanceSheet(balanceSheet.MonthStart, balanceSheet.MonthEnd, balanceSheet.UnitPrice).ToList();

                    GridView gridView = new GridView();
                    gridView.DataSource = BalanceSheetList;
                    gridView.DataBind();
                    Session["BalanceSheet"] = gridView;

                    return View(BalanceSheetList);
                }
                else
                {
                    ModelState.AddModelError("", "Please Select a valid range with correct dates");
                    return View("ShowBalanceSheet");
                }
            }
            else
            {
                ModelState.AddModelError("", "Balance Sheet is not available");
                return View("ShowBalanceSheet");

            }
        }
        /// <summary>
        /// Sorts the records in the specified <see cref="GridView"/>.
        /// </summary>
        /// <param name="action">The 'Sorting' <see cref="GridAction"/> to perform.</param>
        /// <param name="view">The <see cref="GridView"/> to sort.</param>
        /// <param name="p">The parameters used for sorting.</param>
        public void HandleService(GridAction action, GridView view, params object[] p)
        {
            if (view == null) return;
            if (!view.AllowSorting) return;
            if (action != GridAction.Sorting) return;

            // Handle sorting
            GridViewSortEventArgs args = p[0] as GridViewSortEventArgs;
            if (args == null) return;

            if (args.SortExpression == LastExpression)
            {
                SortAscending = !SortAscending;
            }
            else
            {
                SortAscending = true;
                LastExpression = args.SortExpression;
            }

            args.SortDirection = SortDirection;

            if (view.DataSource is IDomainCollection)
            {
                IDomainCollection col = (IDomainCollection)view.DataSource;

                col.Sort(args.SortExpression, (args.SortDirection == SortDirection.Ascending) ? SortOrder.Ascending : SortOrder.Descending);

                view.DataSource = col;
            }

            view.DataBind();
        }
Example #22
0
 public void BuscarPublicacion(GridView GridView1, string SearchWord, int id_usr)
 {
     String strConnString = ConfigurationManager.ConnectionStrings["ConexionRedSocial"].ConnectionString;
     SqlConnection con = new SqlConnection(strConnString);
     SqlCommand cmd = new SqlCommand();
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.CommandText = "BuscarPublicacion";
     cmd.Parameters.Add("@id_usr", SqlDbType.Int).Value = id_usr;
     cmd.Parameters.Add("@SearchWord", SqlDbType.Text).Value = SearchWord.Trim();
     cmd.Connection = con;
     try
     {
         con.Open();
         GridView1.EmptyDataText = "No hay productos publicados que se ajusten a tu busqueda. Intentá de nuevo.";
         GridView1.DataSource = cmd.ExecuteReader();
         GridView1.DataBind();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         con.Close();
         con.Dispose();
     }
 }
Example #23
0
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     Grid = Parent.Parent.Parent.Parent as GridView;
     Row = Parent.Parent as GridViewRow;
     Grid.DataBound += new EventHandler(Grid_DataBound);
 }
Example #24
0
        public static void UpdateRoomInventoryGrid(GridView gv)
        {
            if (roomInventoryList.Count + editRoom.Inventories.Count() == 0 || roomInventoryList.Count + editRoom.Inventories.Count() != gv.Rows.Count)
            {
                return;
            }

            int i;
            for (i = 0; i < editRoom.Inventories.Count(); i++)
            {
                var row = gv.Rows[i];
                var inventory = editRoom.Inventories[i];
                row.BackColor = Color.LightGray;
                row.Cells[0].Text = inventory.ProductName;
                row.Cells[1].Text = inventory.InventoryType.Type;
                row.Cells[2].Text = inventory.Status;
            }

            if (i > 0)
            {
                gv.Rows[i - 1].CssClass = "BorderRow";
            }

            for (var j = i; j - i < roomInventoryList.Count; j++)
            {
                var row = gv.Rows[j];
                var inventory = roomInventoryList[j - i];
                row.Cells[0].Text = inventory.ProductName;
                row.Cells[1].Text = inventory.InventoryType.Type;
                row.Cells[2].Text = inventory.Status;
            }
        }
Example #25
0
 private void BindItemData(GridView itemsview, int TopicID)
 {
     DataTable table = (DataTable) this.ViewState["dtcount"];
     DataRow[] rowArray = table.Select("TopicID=" + TopicID);
     object obj2 = table.Compute("sum(SubmitNum)", "TopicID=" + TopicID);
     int num = 0;
     if (obj2.ToString() != "")
     {
         num = int.Parse(obj2.ToString());
     }
     ArrayList list = new ArrayList();
     for (int i = 0; i < rowArray.Length; i++)
     {
         string str = rowArray[i]["Name"].ToString();
         int num3 = int.Parse(rowArray[i]["SubmitNum"].ToString());
         OptionList list2 = new OptionList {
             name = str,
             count = num3.ToString(),
             totalcount = num.ToString()
         };
         list.Add(list2);
     }
     itemsview.DataSource = list;
     itemsview.DataBind();
 }
Example #26
0
        public void ExportToExcel(DataTable dataTable, HttpResponse response)
        {
            // Create a dummy GridView
            GridView GridView1 = new GridView();
            GridView1.AllowPaging = false;
            GridView1.DataSource = dataTable;
            GridView1.DataBind();
            response.Clear();
            response.Buffer = true;
            response.AddHeader("content-disposition", "attachment;filename=DataTable.xls");
            response.Charset = "";
            response.ContentType = "application/vnd.ms-excel";
            StringWriter sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            for (int i = 0; (i
                        <= (GridView1.Rows.Count - 1)); i++)
            {
                // Apply text style to each Row
                GridView1.Rows[i].Attributes.Add("class", "textmode");
            }

            GridView1.RenderControl(hw);
            // style to format numbers to string
            string style = "<style> .textmode{mso-number-format:\\@;}</style>";
            response.Write(style);
            response.Output.Write(sw.ToString());
            response.Flush();
            response.End();
        }
Example #27
0
        protected void btnDownload_Click(object sender, ImageClickEventArgs e)
        {
            Response.Clear();

            Response.AddHeader("content-disposition", "attachment; filename=Baogia.xls");

            Response.Charset = "";

            Response.ContentType = "application/vnd.xls";

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

            System.Web.UI.HtmlTextWriter htmlWrite =
            new HtmlTextWriter(stringWrite);

            DataSet dts = new DataSet();
            SqlDataAdapter adt = new SqlDataAdapter();
            SqlCommand comm = new SqlCommand("Export_to_Excel", objConn.SqlConn());
            comm.CommandType = CommandType.StoredProcedure;
            comm.Connection.Open();
            adt.SelectCommand = comm;
            adt.Fill(dts);

            GridView g = new GridView();
            g.DataSource = dts;
            g.DataBind();

            g.RenderControl(htmlWrite);

            Response.Write(stringWrite.ToString());

            Response.End();
        }
Example #28
0
 public static void GroupCol(GridView gridView, int cols, int sRow, int eRow)
 {
     checked
     {
         bool flag = gridView.Rows.Count < 1 || cols > gridView.Columns.Count - 1;
         if (!flag)
         {
             TableCell tableCell = gridView.Rows[sRow].Cells[cols];
             int arg_50_0 = 1;
             int num = eRow - sRow - 1;
             int num2 = arg_50_0;
             while (true)
             {
                 int arg_B4_0 = num2;
                 int num3 = num;
                 if (arg_B4_0 > num3)
                 {
                     break;
                 }
                 TableCell tableCell2 = gridView.Rows[sRow + num2].Cells[cols];
                 tableCell2.Visible = false;
                 flag = (tableCell.RowSpan == 0);
                 if (flag)
                 {
                     tableCell.RowSpan = 1;
                 }
                 TableCell tableCell3 = tableCell;
                 tableCell3.RowSpan++;
                 tableCell.VerticalAlign = VerticalAlign.Middle;
                 num2++;
             }
         }
     }
 }
Example #29
0
 public static void SetGridViewCheckState(GridView gv, FiltersModel filtersModel, string filterName)
 {
     if (filtersModel == null)
         return;
     switch (filterName)
     {
         case "Department":
             SetGridViewCheckStateChild(gv, filtersModel, filtersModel.DepartmentFilter);
             break;
         case "Section":
             SetGridViewCheckStateChild(gv, filtersModel, filtersModel.SectionFilter);
             break;
         case "Company":
             SetGridViewCheckStateChild(gv, filtersModel, filtersModel.CompanyFilter);
             break;
         case "Location":
             SetGridViewCheckStateChild(gv, filtersModel, filtersModel.LocationFilter);
             break;
         case "Shift":
             SetGridViewCheckStateChild(gv, filtersModel, filtersModel.ShiftFilter);
             break;
         case "Division":
             SetGridViewCheckStateChild(gv, filtersModel, filtersModel.DivisionFilter);
             break;
         case "Employee":
             SetGridViewCheckStateChild(gv, filtersModel, filtersModel.EmployeeFilter);
             break;
         case "Crew":
             SetGridViewCheckStateChild(gv, filtersModel, filtersModel.CrewFilter);
             break;
         case "Type":
             SetGridViewCheckStateChild(gv, filtersModel, filtersModel.TypeFilter);
             break;
     }
 }
 public virtual void Init (PortalModuleBase module, GridView gridView, HyperLink addButton, int pageSize)
 {
     Grid = gridView;
     Grid.PageSize = pageSize;
     AddButton = addButton;
     AddButton.NavigateUrl = Utils.EditUrl (module, EditKey);
 }
Example #31
0
 public GridViewHelper(System.Web.UI.WebControls.GridView grd, bool useFooterForGeneralSummaries, SortDirection groupSortDirection)
 {
     this.mGrid               = grd;
     this.useFooter           = useFooterForGeneralSummaries;
     this.groupSortDir        = groupSortDirection;
     this.mGeneralSummaries   = new List <GridViewSummary>();
     this.mGroups             = new List <GridViewGroup>();
     this.mGrid.RowDataBound += new GridViewRowEventHandler(RowDataBoundHandler);
 }
Example #32
0
        private void lkbtncancleCheck_Click(object sender, System.EventArgs e)
        {
            int  num  = 0;
            bool flag = true;

            System.Collections.Generic.Dictionary <string, int> dictionary = new System.Collections.Generic.Dictionary <string, int>();
            foreach (System.Web.UI.WebControls.GridViewRow gridViewRow in this.grdAuthorizeProducts.Rows)
            {
                System.Web.UI.WebControls.GridView gridView = gridViewRow.FindControl("grdSkus") as System.Web.UI.WebControls.GridView;
                foreach (System.Web.UI.WebControls.GridViewRow gridViewRow2 in gridView.Rows)
                {
                    System.Web.UI.WebControls.CheckBox checkBox = (System.Web.UI.WebControls.CheckBox)gridViewRow2.FindControl("checkboxCol");
                    System.Web.UI.WebControls.TextBox  textBox  = gridViewRow2.FindControl("txtNum") as System.Web.UI.WebControls.TextBox;
                    if (checkBox != null && checkBox.Checked)
                    {
                        num++;
                        int value;
                        if (!int.TryParse(textBox.Text.Trim(), out value) || int.Parse(textBox.Text.Trim()) <= 0 || textBox.Text.Trim().Contains("."))
                        {
                            flag = false;
                            break;
                        }
                        dictionary.Add((string)gridView.DataKeys[gridViewRow2.RowIndex].Value, value);
                    }
                }
                if (!flag)
                {
                    break;
                }
            }
            if (num == 0)
            {
                this.ShowMsg("请先选择要添加的商品", false);
                return;
            }
            if (!flag)
            {
                this.ShowMsg("数量不能为空,必需为大于零的正整数", false);
                return;
            }
            int num2 = 0;

            foreach (System.Collections.Generic.KeyValuePair <string, int> current in dictionary)
            {
                if (SubsiteSalesHelper.DeletePurchaseShoppingCartItem(current.Key))
                {
                    num2++;
                }
            }
            if (num2 > 0)
            {
                this.ShowMsg(string.Format("成功取消了{0}件商品", num2), true);
                this.BindData();
                return;
            }
            this.ShowMsg("取消商品失败", false);
        }
Example #33
0
 protected void GridView2_RowCreated(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.Header)
     {
         System.Web.UI.WebControls.GridView sn = new System.Web.UI.WebControls.GridView();
         DataTable dT = (DataTable)Session["header_01"];
         tabela.makeHeader(sn, dT, GridView2);
     }
 }
Example #34
0
 protected void grvMergeHeader_RowCreated(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.Header)
     {
         System.Web.UI.WebControls.GridView sn = new System.Web.UI.WebControls.GridView();
         DataTable dT = (DataTable)Session["header_01"];
         makeHeader2(sn, dT);
     }
 } //end of grvMergeHeader_RowCreated
Example #35
0
 protected void naglowekTabeli_gwTabela3(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.Header)
     {
         System.Web.UI.WebControls.GridView sn = new System.Web.UI.WebControls.GridView();
         DataTable dT = (DataTable)Session["header_03"];//tb.naglowek(path, 2);
         tb.makeHeader(sn, dT, gwTabela3);
     }
 }
Example #36
0
 public ColHeaderWithAutoCompleteTbx(System.Web.UI.WebControls.GridView grd, SessionStateFilterAndSortEntities <TEntity> sessVar, string ServiceMethod)
 {
     _sessVar             = sessVar;
     grd.DataBinding     += new EventHandler(grd_DataBinding);
     _serviceMethod       = ServiceMethod;
     CompletionSetCount   = 5;
     CompletionInterval   = 500;
     MinimumPrelfixLength = 1;
 }
        public ColHeaderWithTimeIntervalFilter(System.Web.UI.WebControls.GridView grd, SessionStateFilterAndSortEntities <TEntity> sessVar)
        {
            _sessVar         = sessVar;
            grd.DataBinding += new EventHandler(grd_DataBinding);


            BeginningOfTime = new DateTime(1945, 5, 8);
            EndOfTime       = new DateTime(3000, 1, 1);
        }
Example #38
0
        public GridViewDecorator(System.Web.UI.WebControls.GridView grd, TState state, HttpResponse response, mko.Log.LogServer log)
        {
            Debug.Assert(grd != null && state != null && response != null && log != null, "GridViewDecorator: Konstruktorparameter unvollständig");
            this.grd   = grd;
            this.log   = log;
            this.state = state;

            grd.Sorting          += new System.Web.UI.WebControls.GridViewSortEventHandler(grd_Sorting);
            grd.EmptyDataTemplate = new mkoIt.Asp.GridView.EmptyDataTemplate <TEntity>(state, response);
        }
Example #39
0
 protected void naglowekTabeli_gwTabela3(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.Header)
     {
         System.Web.UI.WebControls.GridView sn = new System.Web.UI.WebControls.GridView();
         string    path = Server.MapPath("\\Template\\obbk.xlsx");
         DataTable dT   = tb.naglowek(path, 3);
         tb.makeHeader(sn, dT, gwTabela3);
     }
 }
Example #40
0
 public static void Format(System.Web.UI.WebControls.GridView obj)
 {
     obj.EmptyDataText                = "Không có dữ liệu";
     obj.CssClass                     = "mGrid";
     obj.PagerStyle.CssClass          = "pgr";
     obj.AlternatingRowStyle.CssClass = "alt";
     obj.AutoGenerateColumns          = false;
     obj.BorderWidth                  = 1;
     obj.BorderColor                  = System.Drawing.Color.Black;
 }
Example #41
0
 protected void naglowekTabeli_gwTabela2(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.Header)
     {
         System.Web.UI.WebControls.GridView sn = new System.Web.UI.WebControls.GridView();
         string    path = Server.MapPath("~\\Template\\" + tenPlikNazwa + ".xlsx");
         DataTable dT   = (DataTable)Session["header_02"];//tb.naglowek(path, 2);
         tb.makeHeader(sn, dT, gwTabela2);
     }
 }
Example #42
0
        /// <summary>
        /// 描述:把DataTable内容导出excel并返回客户端
        /// 时间:2012-10-18
        /// </summary>
        /// <param name="dtData"></param>
        /// <param name="header"></param>
        /// <param name="fileName"></param>
        /// <param name="mergeCellNums">要合并的列索引字典 格式:列索引-合并模式(合并模式 1 合并相同项、2 合并空项、3 合并相同项及空项)</param>
        /// <param name="mergeKey">作为合并项的标记列索引</param>
        public static void DataTable2Excel(System.Data.DataTable dtData, TableCell[] header, string fileName, Dictionary <int, int> mergeCellNums, int?mergeKey)
        {
            System.Web.UI.WebControls.GridView gvExport = null;
            // 当前对话
            System.Web.HttpContext curContext = System.Web.HttpContext.Current;
            // IO用于导出并返回excel文件
            System.IO.StringWriter       strWriter  = null;
            System.Web.UI.HtmlTextWriter htmlWriter = null;

            if (dtData != null)
            {
                // 设置编码和附件格式
                curContext.Response.ContentType     = "application/vnd.ms-excel";
                curContext.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
                curContext.Response.Charset         = "gb2312";
                if (!string.IsNullOrEmpty(fileName))
                {
                    //处理中文名乱码问题
                    fileName = System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8);
                    curContext.Response.AppendHeader("Content-Disposition", ("attachment;filename=" + (fileName.ToLower().EndsWith(".xls") ? fileName : fileName + ".xls")));
                }
                // 导出excel文件
                strWriter  = new System.IO.StringWriter();
                htmlWriter = new System.Web.UI.HtmlTextWriter(strWriter);

                // 重新定义一个无分页的GridView
                gvExport             = new System.Web.UI.WebControls.GridView();
                gvExport.DataSource  = dtData.DefaultView;
                gvExport.AllowPaging = false;
                //优化导出数据显示,如身份证、12-1等显示异常问题
                gvExport.RowDataBound += new System.Web.UI.WebControls.GridViewRowEventHandler(dgExport_RowDataBound);

                gvExport.DataBind();
                //处理表头
                if (header != null && header.Length > 0)
                {
                    gvExport.HeaderRow.Cells.Clear();
                    gvExport.HeaderRow.Cells.AddRange(header);
                }
                //合并单元格
                if (mergeCellNums != null && mergeCellNums.Count > 0)
                {
                    foreach (int cellNum in mergeCellNums.Keys)
                    {
                        MergeRows(gvExport, cellNum, mergeCellNums[cellNum], mergeKey);
                    }
                }

                // 返回客户端
                gvExport.RenderControl(htmlWriter);
                curContext.Response.Clear();
                curContext.Response.Write("<meta http-equiv=\"content-type\" content=\"application/ms-excel; charset=gb2312\"/>" + strWriter.ToString());
                curContext.Response.End();
            }
        }
        /// <summary>
        /// In una gridview ricava l'indice di una colonna boundfield di nome dato
        /// </summary>
        public int GridIndexOfByName(System.Web.UI.WebControls.GridView myGridView, string colName)
        {
            int index = -1;

            foreach (DataControlField field in myGridView.Columns)
            {
                //BoundField
                if (field.GetType().ToString() == "System.Web.UI.WebControls.BoundField")
                {
                    BoundField bf = (BoundField)field;
                    if (bf.DataField == colName)
                    {
                        index = myGridView.Columns.IndexOf(field);
                        break;
                    }
                }
                //TemplateField
                else if (field.GetType().ToString() == "System.Web.UI.WebControls.TemplateField")
                {
                    TemplateField tf = (TemplateField)field;
                    if (tf.ItemTemplate.GetType().ToString() == "System.Web.UI.WebControls.DropDownList")
                    {
                        System.Web.UI.WebControls.DropDownList dropdownField = (System.Web.UI.WebControls.DropDownList)tf.ItemTemplate;
                        if (dropdownField.ID.ToString() == colName)
                        {
                            index = myGridView.Columns.IndexOf(field);
                            break;
                        }
                    }
                    else if (tf.ItemTemplate.GetType().ToString() == "System.Web.UI.CompiledBindableTemplateBuilder")
                    {
                        //Questo ramo non funziona ...!!!
                        System.Web.UI.CompiledBindableTemplateBuilder compiledBindableTemplateBuilder = (System.Web.UI.CompiledBindableTemplateBuilder)tf.ItemTemplate;

                        if (compiledBindableTemplateBuilder.GetType().ToString() == "System.Web.UI.WebControls.TextBox")
                        {
                            //System.Web.UI.WebControls.TextBox textBox = (System.Web.UI.WebControls.TextBox)compiledBindableTemplateBuilder.tf.ItemTemplate;
                            //if (dropdownField.ID.ToString() == colName)
                            //{
                            //    index = myGridView.Columns.IndexOf(field);
                            //    break;
                            //}
                        }

                        if (compiledBindableTemplateBuilder.GetType().ToString() == colName)
                        {
                            index = myGridView.Columns.IndexOf(field);
                            break;
                        }
                    }
                }
            }

            return(index);
        }
Example #44
0
        /**/
        /// <summary>
        /// Add the confirm message to button
        /// Created : GuangMing Chu, 1 1,2007
        /// Modified: GuangMing Chu, 1 1,2007
        /// Modified:
        /// 代码调用:
        ///       UIHelper.AddConfirm(this.Button1, "真的要删了??");
        /// 点确定按钮就会执行事件中的代码,点取消不会
        ///
        /// </summary>
        /// <param name="button">The control, must be a button</param>
        /// <param name="strMsg">The popup message</param>
        public static void AddConfirm(System.Web.UI.WebControls.ImageButton button, string strMsg)
        {
            strMsg = strMsg.Replace("\n", "file://n/");
            strMsg = strMsg.Replace("\r", "file://r/");
            strMsg = strMsg.Replace("\"", "\\\"");
            strMsg = strMsg.Replace("\'", "\\\'");
            button.Attributes.Add("onClick", "return confirm('" + strMsg + "')");
        }

        /**/
        /// <summary>
        /// Add the confirm message to one column of gridview
        /// 代码调用:
        ///         UIHelper myHelp = new UIHelper();
        ///         myHelp.AddConfirm(this.GridView1,1, "ok");
        /// 请使用时注意,此方法的调用必须实例化,调用
        /// </summary>
        /// <param name="grid">The control, must be a GridView</param>
        /// <param name="intColIndex">The column index. It's usually the column which has the "delete" button.</param>
        /// <param name="strMsg">The popup message</param>
        public static void AddConfirm(System.Web.UI.WebControls.GridView grid, int intColIndex, string strMsg)
        {
            strMsg = strMsg.Replace("\n", "file://n/");
            strMsg = strMsg.Replace("\r", "file://r/");
            strMsg = strMsg.Replace("\"", "\\\"");
            strMsg = strMsg.Replace("\'", "\\\'");
            for (int i = 0; i < grid.Rows.Count; i++)
            {
                grid.Rows[i].Cells[intColIndex].Attributes.Add("onclick", "return confirm('" + strMsg + "')");
            }
        }
        /// <summary>
        /// 从GridView的数据生成DataTable
        /// </summary>
        /// <param name="gv">GridView对象</param>
        public static DataTable GridView2DataTable(System.Web.UI.WebControls.GridView gv)
        {
            DataTable     table    = new DataTable();
            int           rowIndex = 0;
            List <string> cols     = new List <string>();

            if (!gv.ShowHeader && gv.Columns.Count == 0)
            {
                return(table);
            }
            GridViewRow headerRow   = gv.HeaderRow;
            int         columnCount = headerRow.Cells.Count;

            for (int i = 0; i < columnCount; i++)
            {
                string text = GetCellText(headerRow.Cells[i]);
                cols.Add(text);
            }
            foreach (GridViewRow r in gv.Rows)
            {
                if (r.RowType == DataControlRowType.DataRow)
                {
                    DataRow row = table.NewRow();
                    int     j   = 0;
                    for (int i = 0; i < columnCount; i++)
                    {
                        string text = GetCellText(r.Cells[i]);
                        if (!string.IsNullOrEmpty(text))
                        {
                            if (rowIndex == 0)
                            {
                                string columnName = cols[i];
                                if (string.IsNullOrEmpty(columnName))
                                {
                                    continue;
                                }
                                if (table.Columns.Contains(columnName))
                                {
                                    continue;
                                }
                                DataColumn dc = table.Columns.Add();
                                dc.ColumnName = columnName;
                                dc.DataType   = typeof(string);
                            }
                            row[j] = text;
                            j++;
                        }
                    }
                    rowIndex++;
                    table.Rows.Add(row);
                }
            }
            return(table);
        }
Example #46
0
    public static void LoadClientPaymentHistoryPage(string search_val, System.Web.UI.WebControls.GridView gv, System.Web.UI.WebControls.Repeater rptPager, int pageIndex, DropDownList ddlPageSize)
    {
        int recordCount = 0;
        int PageSize    = int.Parse(ddlPageSize.SelectedValue);
        SqlClientProvider sqlClientProvider = new SqlClientProvider();
        DataSet           ds = sqlClientProvider.LoadClientPaymentHistoryPage(search_val, pageIndex, PageSize, out recordCount);

        gv.DataSource = ds;
        gv.DataBind();
        LoadClientPaymentHistoryPage(rptPager, recordCount, pageIndex, PageSize);
    }
Example #47
0
    public static void LoadStatesPage(System.Web.UI.WebControls.GridView gv, System.Web.UI.WebControls.Repeater rptPager, int pageIndex, DropDownList ddlPageSize)
    {
        int recordCount = 0;
        int PageSize    = int.Parse(ddlPageSize.SelectedValue);
        SqlStatesProvider sqlStatesProvider = new SqlStatesProvider();
        DataSet           ds = sqlStatesProvider.GetStatesPageWise(pageIndex, PageSize, out recordCount);

        gv.DataSource = ds;
        gv.DataBind();
        statessPaggination(rptPager, recordCount, pageIndex, PageSize);
    }
        public ActionResult Export()
        {
            DataTable dt = ToDataTable(db.EmployeeMsts.ToList());

            if (dt.Rows.Count > 0)
            {
                DataSet ds = new DataSet();
                ds.Tables.Add(dt);
                ds.Tables[0].Columns.Remove("EmployeeID");
                ds.Tables[0].Columns.Remove("Image");

                System.Web.UI.WebControls.GridView gv = new System.Web.UI.WebControls.GridView();
                gv.DataSource = ds;
                gv.DataBind();
                Response.ClearContent();
                Response.Buffer = true;
                Response.AddHeader("content-disposition", "attachment; filename=outage_manager.xls");
                Response.ContentType = "application/ms-excel";
                Response.Charset     = "";

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

                gv.HeaderRow.Style.Add("background-color", "#92D050");

                Table table = new Table();

                TableRow title = new TableRow();
                title.BackColor = Color.Gray;

                TableCell titlecell = new TableCell();
                titlecell.ColumnSpan      = 9;//Should span across all columns
                titlecell.HorizontalAlign = HorizontalAlign.Left;
                titlecell.RowSpan         = 2;


                Label lbl = new Label();
                lbl.Text = "Employee Details";
                lbl.Style.Add("font-size", "medium");
                lbl.Style.Add("font-family", "Arial");
                lbl.Style.Add("font-weight", "bold");

                titlecell.Controls.Add(lbl);
                title.Cells.Add(titlecell);
                table.Rows.Add(title);
                table.RenderControl(htw);

                gv.RenderControl(htw);
                Response.Output.Write(sw.ToString());
                Response.Flush();
                Response.End();
            }
            return(RedirectToAction("Index"));
        }
Example #49
0
 public static void BindGridView(this System.Web.UI.WebControls.GridView gridView, object source, int pageSize, int pageIndex, IEnumerable <int> columnIndexesToHide)
 {
     gridView.DataSource = source;
     gridView.PageSize   = pageSize;
     gridView.PageIndex  = pageIndex;
     gridView.DataBind();
     foreach (var index in columnIndexesToHide)
     {
         gridView.Columns[index].Visible = false;
     }
 }
Example #50
0
 public GridFilterRemoveFilterButton(Page page, System.Web.UI.WebControls.GridView grdAll, string IdBtnRemoveFilter, SessionStateFilterAndSortEntities <TEntity> state)
 {
     _Page   = page;
     _grdAll = grdAll;
     _state  = state;
     if (_grdAll.HeaderRow != null)
     {
         _btnRemoveFilter        = _grdAll.HeaderRow.FindControl(IdBtnRemoveFilter) as Button;
         _btnRemoveFilter.Click += new EventHandler(OnButtonClick);
     }
 }
Example #51
0
 public GridFilterSetFilterButton(Page page, System.Web.UI.WebControls.GridView grdAll, string IdBtnSetFilter)
 {
     _Page   = page;
     _grdAll = grdAll;
     if (_grdAll.HeaderRow != null)
     {
         _btnSetFilter = _grdAll.HeaderRow.FindControl(IdBtnSetFilter) as Button;
         Debug.Assert(_btnSetFilter != null);
         _btnSetFilter.Click += new EventHandler(OnButtonClick);
     }
 }
Example #52
0
 public static int FindColumnIndex(System.Web.UI.WebControls.GridView gridView, string accessibleHeaderText)
 {
     for (int index = 0; index < gridView.Columns.Count; index++)
     {
         if (String.Compare(gridView.Columns[index].AccessibleHeaderText, accessibleHeaderText, true) == 0)
         {
             return(index);
         }
     }
     return(-1);
 }
Example #53
0
        protected void new_object_Click(object sender, EventArgs e)
        {
            Session["created_flag"] = true;
            System.Web.UI.WebControls.ObjectDataSource ods = current_ods();
            System.Web.UI.WebControls.GridView         gv  = current_grid();
            ods.SelectMethod = "GetData";
            ods.SelectParameters.Clear();
            int i = ods.Insert();

            gv.EditIndex = gv.Rows.Count;
            this.DataBind();
        }
Example #54
0
        protected override void CreateChildControls()
        {
            SiteViewer webPart = (SiteViewer)this.WebPartToEdit;

            if (webPart == null)
            {
                return;
            }

            if (ViewState["FirstLoad"] == null || !bool.Parse(ViewState["FirstLoad"].ToString()))
            {
                ViewState["CommingUp"] = webPart.CommingUpLink;
            }

            ViewState["FirstLoad"] = true;

            lblTitle      = new System.Web.UI.WebControls.Label();
            lblTitle.Text = "Comming up link : ";
            Controls.Add(lblTitle);

            txtCommingUpTitle    = new TextBox();
            txtCommingUpTitle.ID = "txtTitle";
            Controls.Add(txtCommingUpTitle);

            txtCommingUpLink    = new TextBox();
            txtCommingUpLink.ID = "txtLink";
            Controls.Add(txtCommingUpLink);

            literalSpace      = new Literal();
            literalSpace.Text = "&nbsp;";
            Controls.Add(literalSpace);

            btnAdd        = new Button();
            btnAdd.ID     = "btnAdd";
            btnAdd.Text   = "Add";
            btnAdd.Click += new EventHandler(btnAdd_Click);
            Controls.Add(btnAdd);

            literalSpace      = new Literal();
            literalSpace.Text = "<br /><br />";
            Controls.Add(literalSpace);

            gridCommingUpLink = new GridView();
            gridCommingUpLink.Style.Add("width", "100%");
            gridCommingUpLink.RowDeleting += new GridViewDeleteEventHandler(gridCommingUpLink_RowDeleting);
            gridCommingUpLink.AutoGenerateDeleteButton = true;

            gridCommingUpLink.DataSource = ViewState["CommingUp"] as List <CommingUpLink>;
            gridCommingUpLink.DataBind();
            Controls.Add(gridCommingUpLink);

            base.CreateChildControls();
        }
    public void fillgrid(System.Web.UI.WebControls.GridView gv, string sql)
    {
        SqlConnection con = new SqlConnection(DBUtil.ConnectionString);

        con.Open();
        DataTable      dt = new DataTable();
        SqlDataAdapter da = new SqlDataAdapter(sql, con);

        da.Fill(dt);
        gv.DataSource = dt;
        gv.DataBind();
    }
Example #56
0
    public static void LoadClientPage(string search_val, System.Web.UI.WebControls.GridView gv, System.Web.UI.WebControls.Repeater rptPager, int pageIndex, DropDownList ddlPageSize, Label lbltotalrecord, int LocationID, DateTime FromDate, DateTime ToDate)
    {
        int recordCount = 0;
        int PageSize    = int.Parse(ddlPageSize.SelectedValue);
        SqlClientProvider sqlClientProvider = new SqlClientProvider();
        DataSet           ds = sqlClientProvider.GetClientPageWise(search_val, pageIndex, PageSize, out recordCount, LocationID, FromDate, ToDate);

        gv.DataSource = ds;
        gv.DataBind();
        lbltotalrecord.Text = "Total Record Found : " + recordCount;
        clientsPaggination(rptPager, recordCount, pageIndex, PageSize);
    }
Example #57
0
 protected void SelectOrDeselectAllGridCheckBox(System.Web.UI.WebControls.GridView gridView, bool makeItSelect, string checkBoxName)
 {
     for (int i = 0; i < gridView.Rows.Count; i++)
     {
         GridViewRow row = gridView.Rows[i];
         if (row.RowType == DataControlRowType.DataRow)
         {
             CheckBox cbxGroupedDiscplines = FindControlById(row, checkBoxName) as CheckBox;
             cbxGroupedDiscplines.Checked = makeItSelect;
         }
     }
 }
 protected void dgvInfo_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow) //如果是数据行
     {
         e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#6699ff' ");
         e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
         GridView grid = sender as GridView; //取当前操作的GridView
         string   code = grid.DataKeys[e.Row.RowIndex].Value.ToString();
         string   name = e.Row.Cells[1].Text;
         ((LinkButton)(e.Row.Cells[grid.Columns.Count - 1].Controls[0])).Attributes.Add("onclick",
                                                                                        "btnSelect_onclick('" + code +
                                                                                        "','" + name + "')");
     }
 }
Example #59
0
        /// <summary>
        /// Clears the child controls of a EntityGridView to make sure all controls are LiteralControls
        /// </summary>
        /// <param name="gridView">Datagrid to be cleared and verified</param>
        protected void ClearChildControls(System.Web.UI.WebControls.GridView gridView)
        {
            for (int i = gridView.Columns.Count - 1; i >= 0; i--)
            {
                if (gridView.Columns[i].GetType().Name == "ButtonColumn" ||
                    gridView.Columns[i].GetType().Name == "CheckBoxField" ||
                    gridView.Columns[i].GetType().Name == "CommandField")
                {
                    gridView.Columns[i].Visible = false;
                }
            }

            this.RecursiveClear(gridView);
        }
Example #60
0
    //GridView
    public void GridView_Bind(System.Web.UI.WebControls.GridView gv, DataSet ds)
    {
        if (ds == null)
        {
            return;
        }
        if (ds.Tables.Count == 0)
        {
            return;
        }

        gv.DataSource = ds.Tables[0].DefaultView;
        gv.DataBind();
    }