using System;
using System.Linq;
using Dapper;
using System.Collections.Generic;
using Models;
using Syncfusion.XlsIO;
using Syncfusion.EJ.Export;
public partial class ProjectApproval : BandPage
{
#region Sql
private readonly string GetApprovals = @"
select top 50
t.Approval_Ticket_ID,h.Approval_Ticket_History_ID, tt.Name [type], h.Approval_Stage_Date [action_date], c.Forename + ' ' + c.Surname [ActionedBy],
CASE h.Approval_Action
WHEN '1' THEN 'Approved'
WHEN '2' THEN 'Rejected'
WHEN '3' THEN 'Delegated to ' + del.Forename + ' ' + del.surname
ELSE 'Other'
END [Action],
t.Created_Date [ApprovalCreated],t.name [description],wa.EXT_Workpackage_ID,d.EXT_Purchase_Requisition_Form_Data_ID,
wp.Workpackage_Code,d.po_number
from Approval_Ticket_History h
LEFT JOIN Approval_Ticket t on h.Approval_Ticket_ID=t.Approval_Ticket_ID
LEFT JOIN Approval_Ticket_Type tt on t.Approval_Ticket_Type_ID=tt.Approval_Ticket_Type_ID
LEFT JOIN Contact c on h.Contact_ID =c.Contact_ID
LEFT JOIN Contact del on h.Delegate_ID =del.Contact_ID
LEFT JOIN EXT_Workpackage_Approval wa on t.Approval_Ticket_ID=wa.Approval_Ticket_ID
LEFT JOIN EXT_Workpackage wp on wa.EXT_Workpackage_ID=wp.EXT_Workpackage_ID
LEFT JOIN EXT_Purchase_Requisition_Form_Data d on t.Approval_Ticket_ID=d.approval_ticket
where
t.Entity_Class_ID=3 and t.Entity_Identifier=@Entity
order by h.Approval_Stage_Date desc";
#endregion Sql
public IEnumerable
{
using (var connection = ConnectionService.CreateConnection())
{
var approvals = connection.Query
if (hideComplete)
{
approvals = approvals.ToList();
}
return approvals;
}
}
protected void Grid_ServerExcelExporting(object sender, Syncfusion.JavaScript.Web.GridEventArgs e)
{
BindGrid();
new ExcelExport().Export(Grid.Model, Grid.DataSource, "Export.xlsx", ExcelVersion.Excel2010, false, false, ExportTheme.BootstrapTheme);
}
protected void hideComplete_Change(object Sender, Syncfusion.JavaScript.Web.CheckBoxEventArgs e)
{
BindGrid();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
hideComplete.Checked = false;
BindGrid();
}
}
private void BindGrid()
{
Grid.DataSource = GetApprovalDetails(hideComplete.Checked);
Grid.DataBind();
}
}
public IEnumerable GetApprovalDetails(bool hideComplete)
{
using (var connection = ConnectionService.CreateConnection())
{
var approvals = connection.Query(GetApprovals, new { Entity = Entity.EntityID });
if (hideComplete)
{
approvals = approvals.ToList();
}
return approvals.ToList();
}
} |