using BLL;
using System;
using NPOI.XSSF.UserModel;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;

namespace FineUIPro.Web.Design
{
    public partial class IssuedNoticeFlow : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string noticeId = Request.Params["designNoticeId"];
                var notice = BLL.DesignInputService.GetDesignNotice(noticeId);
                lbMutualIssuedNo.Text = notice.MutualIssuedNo;
                BindGrid();
            }
        }

        private void BindGrid()
        {
            string strSql = @"SELECT flow.NoticeFlowId,flow.SubmitDate,flow.HandleState,flow.HandleIdea,u.UserName AS SubmitMan,
                                     (CASE WHEN flow.SubmitStep='提出人' THEN 'Issued Person' 
		                                   WHEN flow.SubmitStep='接收人' THEN 'Received Person'
			                               WHEN flow.SubmitStep='项目经理' THEN 'Project Manager' END) AS SubmitStep
                                FROM dbo.Design_NoticeFlow flow
                                LEFT JOIN dbo.Sys_User u ON u.UserId = flow.SubmitMan
                                WHERE flow.DesignNoticeId=@DesignNoticeId
                                ORDER BY flow.SubmitDate";
            List<SqlParameter> listStr = new List<SqlParameter>();
            listStr.Add(new SqlParameter("@DesignNoticeId", Request.Params["designNoticeId"]));
           
            SqlParameter[] parameter = listStr.ToArray();
            DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter);
            // 2.获取当前分页数据
            //var table = this.GetPagedDataTable(Grid1, tb1);
            
            Grid1.DataSource = dt;
            Grid1.DataBind();
        }

        protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
        {
            BindGrid();
        }
    }
}