using BLL;
using System;
using System.Text;
using AspNet = System.Web.UI.WebControls;
namespace FineUIPro.Web.BoSheng
{
    public partial class BoTrain : PageBase
    {
        /// 
        /// 加载
        /// 
        /// 
        /// 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Funs.DropDownPageSize(this.ddlPageSize);
                //this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
                //this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);                              
                this.GridBind();
            }
        }
        /// 
        /// 获取数据,合并相同行
        /// 
        private void GridBind()
        {
            var getData = BOSHENGService.getTrainListData(this.CurrUser.LoginProjectId, this.txtTrainType.Text.Trim(),this.txtName.Text.Trim(), Grid1);
            Grid1.RecordCount = BOSHENGService.traincount;
            Grid1.DataSource = getData;
            Grid1.DataBind();
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            this.GridBind();
        }
        #region 导出按钮
        /// 导出按钮
        /// 
        /// 
        /// 
        protected void btnOut_Click(object sender, EventArgs e)
        {
            Response.ClearContent();
            string filename = Funs.GetNewFileName();
            Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("培训记录" + filename, Encoding.UTF8) + ".xls");
            Response.ContentType = "application/excel";
            Response.ContentEncoding = Encoding.UTF8;
            this.Grid1.PageSize = this.Grid1.RecordCount;
            this.GridBind();
            Response.Write(GetGridTableHtml(Grid1));
            Response.End();
        }
        #endregion
        #region 分页 排序
        /// 
        /// 改变索引事件
        /// 
        /// 
        /// 
        protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
        {
            this.GridBind();
        }
        /// 
        /// 分页下拉选择事件
        /// 
        /// 
        /// 
        protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue);
            this.GridBind();
        }
        /// 
        /// 
        /// 
        /// 
        /// 
        protected void Grid1_Sort(object sender, GridSortEventArgs e)
        {
            this.GridBind();
        }
        #endregion
        #region 同步培训记录
        /// 
        /// 同步培训记录
        /// 
        /// 
        /// 
        protected void btnRefresh_Click(object sender, EventArgs e)
        {
            BOSHENGMonitorService.AddData(null, null);
        }
        #endregion
    }
}