cs file
public static T GetAllDraftPreliminaryEnquiryByOfficeIDUserIDWithPaging<T>(long officeId, long currentUserID, int pageIndex, int pageSize)
{
try
{
using (var connection = ConnectionManager.Create(ConnectionManager.ConnectTo.CBIConnection))
{
IDbCommand command = new SqlCommand("SSP_GetAllDraftPreliminaryEnquiryByOfficeIDUserIDWithPaging", connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@officeId", SqlDbType.BigInt)
{
Value = officeId
});
command.Parameters.Add(new SqlParameter("@CurrentUserID", SqlDbType.BigInt)
{
Value = currentUserID
});
command.Parameters.Add(new SqlParameter("@PageIndex", SqlDbType.Int)
{
Value = pageIndex
});
command.Parameters.Add(new SqlParameter("@PageSize", SqlDbType.Int)
{
Value = pageSize
});
connection.Open();
return DBHelper.Execute<T>(ref command);
}
}
catch (Exception ex)
{
//DataAccessExceptionHandler.HandleException(ref ex);
}
return default(T);
}
--------------------aspx file
<%@ Page Title="Draft Preliminary Enquiry" Language="C#" MasterPageFile="~/CBILayout.Master" AutoEventWireup="true" EnableEventValidation="false" CodeBehind="DraftPreliminaryEnquiryMigration.aspx.cs" Inherits="CBI.Portal.DraftPreliminaryEnquiryMigration" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style type="text/css">
.RadGrid_Default .rgSelectedRow a {
color: #428bca !important
}
.grid {
overflow: auto;
overflow-x: hidden;
}
.grid table tr td {
word-break: break-all !important;
text-align: left;
letter-spacing: 0;
color: #676767;
opacity: 1;
font-size: small;
padding: 5px !important;
vertical-align: top;
line-height: 15px;
}
.RadGrid_Default .rgHeader {
font: 12px Open Sans !important;
/*font-size: 14px !important;*/
color: #FFFFFF !important;
background: #8E8B8B 0% 0% no-repeat padding-box !important;
}
.checked {
color: red;
display: block;
}
.unchecked {
color: #D6D6D6;
border-color: grey;
display: block;
}
.breakWord120 {
/*max-width: 120px !important;
word-break: break-all !important;
word-wrap: break-word !important;
vertical-align: top;
line-height: 15px;
padding: 7px !important;*/
}
.fileNumberStyle {
/*max-width: 120px !important;
word-break: break-all !important;
word-wrap: break-word !important;
vertical-align: top;
line-height: 15px;
padding: 7px !important;*/
}
.dateStyle {
/*max-width: 120px !important;
word-break: break-all !important;
word-wrap: break-word !important;
vertical-align: top;
line-height: 15px;
padding: 7px !important;*/
}
.legend {
list-style: none;
}
.legend li {
float: left;
margin-right: 10px;
}
.legend span {
border: 1px solid #ccc;
float: left;
width: 12px;
height: 12px;
margin: 2px;
}
.legend .MostImmediate {
background-color: #FE8076;
}
.legend .Immediate {
background-color: #FAA061;
}
.legend .Urgent {
background-color: #FFDC90;
}
.legend .General {
background-color: #FFFFFF;
}
</style>
<script type="text/javascript">
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:UpdatePanel runat="server" ID="frmUpdatePanel" UpdateMode="Conditional">
<ContentTemplate>
<h2 class="heading_b uk-margin-bottom">Draft Preliminary Enquiry List</h2>
<div class="md-card">
<div class="md-card-content" style="padding: 0;">
<div style="border: 1px solid #d5d5d5; padding: 20px;">
<div class="PopupAddButton">
<asp:LinkButton ID="lnkAddNew" runat="server" OnClick="lnkAddNew_Click" ToolTip="Add New" >
<i class="md-icon clndr_add_event material-icons" style="color: #fff; background: #7cb342;"></i>
</asp:LinkButton>
</div>
<div>
<asp:UpdatePanel runat="server" ID="grdDraftPreliminaryEnquiry" UpdateMode="Conditional">
<ContentTemplate>
<telerik:RadAjaxPanel ID="RadAjaxPaneDraftPreliminaryEnquiry" LoadingPanelID="RadAjaxLoadingPanel" runat="server">
<telerik:RadGrid ID="radGrdDraftPreliminaryEnquiry" runat="server" AllowPaging="True" AllowCustomPaging="True" AllowSorting="True" CellSpacing="0" CssClass="uk-table uk-table-hover" HeaderStyle-ForeColor="#FFFFFF" HeaderStyle-BackColor="#8E8B8B" OnPageIndexChanged="radGrdDraftPreliminaryEnquiry_PageIndexChanged" OnPageSizeChanged="radGrdDraftPreliminaryEnquiry_PageSizeChanged" HeaderStyle-Font-Names="Open Sans" OnItemCommand="radGrdDraftPreliminaryEnquiry_ItemCommand" HeaderStyle-Font-Size="Smaller" EnableEmbeddedSkins="True" EnableEmbeddedBaseStylesheet="True">
<MasterTableView AutoGenerateColumns="False" PagerStyle-AlwaysVisible="true" DataKeyNames="preliminaryenquiryID">
<Columns>
<telerik:GridBoundColumn DataField="fileid" HeaderText="File ID" />
<telerik:GridBoundColumn DataField="preliminaryenquiryID" HeaderText="Preliminary Enq ID" />
<telerik:GridBoundColumn DataField="sourceofpe" HeaderText="Source Of PE" />
<telerik:GridBoundColumn DataField="complaintreferencenumber" HeaderText="Comp Ref Num" />
<telerik:GridBoundColumn DataField="penumber" HeaderText="PE Number" />
<telerik:GridBoundColumn DataField="pedate" HeaderText="PE Date" />
<telerik:GridTemplateColumn HeaderText="Action" Visible="true" >
<ItemTemplate>
<asp:UpdatePanel runat="server" ID="editDeleteUpdatePanel">
<ContentTemplate>
<asp:LinkButton ID="lnkgrdDraftPreliminaryEnquirySelect" runat="server" ToolTip="Edit" CommandName="Select" CommandArgument='<%# Eval("preliminaryenquiryid") + ";"+ Eval("fileid") + ";"+ Eval("filetrackingid")%>' Font-Underline="false" > <i class="fa fa-edit"></i>
</asp:LinkButton>
<asp:LinkButton ID="lnkgrdDraftPreliminaryEnquiryDelete" runat="server" ToolTip="Delete" CommandName="Delete" CommandArgument='<%# Eval("preliminaryenquiryid") + ";"+ Eval("fileid") + ";"+ Eval("filetrackingid")%>' OnClientClick="return confirm('Are you sure you want to delete this event?');">
<i class="fa fa-trash"></i>
</asp:LinkButton>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lnkgrdDraftPreliminaryEnquiryDelete" />
</Triggers>
</asp:UpdatePanel>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<PagerStyle AlwaysVisible="True" PageSizes="10,20,50,100" />
</MasterTableView>
</telerik:RadGrid>
<%--<asp:GridView runat="server" ID="grdDraftPreliminaryEnquiry" AutoGenerateColumns="false"
OnRowDataBound="grdDraftPreliminaryEnquiry_RowDataBound"
CssClass="table table-striped" OnRowDeleting="grdDraftPreliminaryEnquiry_RowDeleting" AllowPaging="true" OnPageIndexChanging="grdDraftPreliminaryEnquiry_PageIndexChanging" AllowCustomPaging="true" PageSize="10" DataKeyNames="preliminaryenquiryID" >
<Columns>
<asp:BoundField DataField="fileid" HeaderText="File ID" />
<asp:BoundField DataField="preliminaryenquiryID" HeaderText="preliminary enq ID" />
<asp:BoundField DataField="sourceofpe" HeaderText="source of pe" />
<asp:BoundField DataField="complaintreferencenumber" HeaderText="Comp ref num" />
<%-- <telerik:GridBoundColumn DataField="referencefilenumber" HeaderText="Ref File No." />
<asp:BoundField DataField="penumber" HeaderText="pe number" />
<asp:BoundField DataField="pedate" HeaderText="PE Date" />
<%--<telerik:GridBoundColumn DataField="referencetype" HeaderText="reference type" />
<asp:BoundField DataField="referenceid" HeaderText="reference ID" />
<%--<telerik:GridBoundColumn DataField="createdby" HeaderText="created by" />
<asp:TemplateField HeaderText="Select" Visible="true" >
<ItemTemplate>
<asp:LinkButton ID="lnkgrdDraftPreliminaryEnquirySelect" runat="server" CssClass="btn btn-danger" ToolTip="Select" CommandName="Select" Text="Select" CausesValidation="false" CommandArgument='<%# Eval("preliminaryenquiryid") + ";"+ Eval("fileid")%>' OnClick="lnkgrdDraftPreliminaryEnquirySelect_Click" > </asp:LinkButton>
<%--<asp:LinkButton ID="lnkgrdDraftPreliminaryEnquiryDelete" runat="server" CssClass="btn btn-danger" ToolTip="delete" CausesValidation="false" CommandName="delete" >Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings Mode="NumericFirstLast" PageButtonCount="4" FirstPageText="First" LastPageText="Last"/>
</asp:GridView>--%>
</telerik:RadAjaxPanel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</div>
</div>
<div class="modal fade" id="ManageStatementDelete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;z-index:9999">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
Confirmation
</div>
<div class="modal-body">
<asp:HiddenField runat="server" ID="hdnpreliminaryEnquiryDeleteId" ClientIDMode="Static" Visible="false"></asp:HiddenField>
<div id="divManageStatementDelete" style="display: block;">
Are you sure want to Delete?
</div>
</div>
<div class="modal-footer">
<asp:Button ID="btnDelete" runat="server" CssClass="btn btn-secondary" Text="Yes" data-dismiss="modal" CausesValidation="false" UseSubmitBehavior="false" OnClick="btnDelete_Click"></asp:Button>
<asp:Button ID="btnCancel" runat="server" CssClass="btn btn-primary" data-bs-dismiss="modal" Text="No"></asp:Button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function OpenManageStatementDeleteModal() {
debugger;
//var div = document.getElementById('divManageStatementDelete');
//div.style.display = 'block';
$("#ManageStatementDelete").modal("show");
}
</script>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
-------------------------aspx.cs
using CBI.Framework.Cryptology;
using CBI.Framework.Enums;
using CBI.Framework.Service.Helper;
using CBI.Interfaces;
using CBI.Portal.Helper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
namespace CBI.Portal
{
public partial class DraftPreliminaryEnquiryMigration : PageBase
{
public long ReferenceId
{
get { return Convert.ToInt64(ViewState["ReferenceId"]); }
set { ViewState["ReferenceId"] = value; }
}
public long ReferenceType
{
get { return Convert.ToInt64(ViewState["ReferenceType"]); }
set { ViewState["ReferenceType"] = value; }
}
public long PreliminaryEnquiryId
{
get { return Convert.ToInt64(ViewState["PreliminaryEnquiryId"]); }
set { ViewState["PreliminaryEnquiryId"] = value; }
}
public long RefTypePE
{
get { return Convert.ToInt64(ViewState["RefTypePE"]); }
set { ViewState["RefTypePE"] = value; }
}
//public string referencePENumber
//{
// get { return hdnPENumber.Value; }
// set { hdnPENumber.Value = value; }
//}
public long FileID
{
get { return Convert.ToInt32(ViewState["FileID"]); }
set { ViewState["FileID"] = value; }
}
public long FileTrackingID
{
get { return Convert.ToInt32(ViewState["FileTrackingID"]); }
set { ViewState["FileTrackingID"] = value; }
}
public Boolean isReferenceFile = false;
protected void Page_Load(object sender, EventArgs e)
{
try
{
{
}
if (!IsPostBack)
{
LoadDraftPreliminaryEnquiry(0, 10);
}
}
catch (Exception ex)
{
ProcessException(ex);
}
}
public void LoadDraftPreliminaryEnquiry(int pageNumber, int pageSize)
{
try
{
DataSet ds = new DataSet();
using (var client = ServiceClient<IPreliminaryEnquiryManager>.Create(ObjectConstants.PreliminaryEnquiryManager))
{
ds = client.Instance.GetAllDraftPreliminaryEnquiryByOfficeIDUserIDWithPaging(CurrentUser.OfficeId, CurrentUser.UserId, pageNumber, pageSize);
}
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
var totalRowsCount = Convert.ToInt32(ds.Tables[1].Rows[0]["TotalRowCount"]);
radGrdDraftPreliminaryEnquiry.VirtualItemCount = totalRowsCount;
}
}
radGrdDraftPreliminaryEnquiry.DataSource = ds;
radGrdDraftPreliminaryEnquiry.DataBind();
}
catch (Exception ex)
{
ProcessException(ex);
}
}
protected void grdDraftPreliminaryEnquiry_SelectedIndexChanged(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('selected index change');", true);
}
protected void grdDraftPreliminaryEnquiry_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
// get the categoryID of the clicked row
int preliminaryEnquiryID = Convert.ToInt32(e.Values["preliminaryenquiryID"]);
// Delete the record
//DeleteRecord(categoryID);
// Insert Operation Logs
bool Isdelete = false;
if (!string.IsNullOrEmpty(preliminaryEnquiryID.ToString()))
{
using (var client = ServiceClient<IPreliminaryEnquiryManager>.Create(ObjectConstants.PreliminaryEnquiryManager))
{
Isdelete = client.Instance.DeletePreliminaryEnquiryByPreliminaryEnquiryID(Convert.ToInt64(preliminaryEnquiryID));
}
if (Isdelete)
{
LoadDraftPreliminaryEnquiry(radGrdDraftPreliminaryEnquiry.CurrentPageIndex, 10);
ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('" + preliminaryEnquiryID + "Deleted ');", true);
string bodyMessage = (Isdelete) ? PageUtils.GetResourceValue("Common", "resDeleted") : "";
SetFadeMesssage(bodyMessage);
}
}
}
protected void radGrdDraftPreliminaryEnquiry_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == "Select")
{
string[] commandArgs = e.CommandArgument.ToString().Split(new char[] { ';' });
//int index = Convert.ToInt32(e.CommandArgument);
//GridViewRow row = grdDraftPreliminaryEnquiry.Rows[5];
//row.BackColor = Color.Yellow;
int preliminaryEnquiryID = Convert.ToInt32(commandArgs[0]);
//FileID = Convert.ToInt32(commandArgs[1]);
//Session[Constants.FileID] = FileID;
//UCPreliminaryInformation.FileID = FileID;
PreliminaryEnquiryId = preliminaryEnquiryID;
// Delete the record
//DeleteRecord(categoryID);
// Insert Operation Logs
ReferenceId = preliminaryEnquiryID;
FileTrackingID = Convert.ToInt32(commandArgs[2]);
ReferenceType = Convert.ToInt64(EnumLookup.ReferenceType.PreliminaryEnquiry);
//hfPreliminaryId.Value = preliminaryEnquiryID.ToString();
//Response.Redirect("PreliminaryEnquiryMigration.aspx?ReferenceID="+preliminaryEnquiryID+ "&ReferenceType=195");
//Session[CryptologyFunctions.Encrypt("ReferenceType")] = 195;
//BindData(PreliminaryEnquiryId, 195);
Response.Redirect("PreliminaryEnquiryMigration.aspx?ReferenceId=" + CryptologyFunctions.Encrypt(Convert.ToString(PreliminaryEnquiryId)) + "&ReferenceType=" + CryptologyFunctions.Encrypt(Convert.ToInt64(EnumLookup.ReferenceType.PreliminaryEnquiry).ToString()) + "&PreliminaryEnquiryId=" + CryptologyFunctions.Encrypt(Convert.ToString(PreliminaryEnquiryId)) + "&Finalized=" + CryptologyFunctions.Encrypt("false") + "&ViewMode=" + CryptologyFunctions.Encrypt("false") + "&FileTrackingID=" + CryptologyFunctions.Encrypt(Convert.ToString(FileTrackingID)));
//ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('Selected" + preliminaryEnquiryID + "');", true);
//ApplyFilter();
//if (!string.IsNullOrEmpty(Convert.ToString(Request.QueryString["ReferenceId"])) && !string.IsNullOrEmpty(Convert.ToString(Request.QueryString["ReferenceType"])))
//{
//}
//ScriptManager.RegisterStartupScript(this, typeof(string), "CurrentTab", String.Format("CurrentTab();"), true);
//LoadDropdownList();
//LoadDraftPreliminaryEnquiry(0, 10);
}
if (e.CommandName == "Delete")
{
string[] commandArgs = e.CommandArgument.ToString().Split(new char[] { ';' });
int preliminaryEnquiryID = Convert.ToInt32(commandArgs[0]);
// Delete the record
//DeleteRecord(categoryID);
// Insert Operation Logs
hdnpreliminaryEnquiryDeleteId.Value = preliminaryEnquiryID.ToString();
//ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('Deleted' );", true);
//grdDraftPreliminaryEnquiry.Update();
ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), String.Format("OpenManageStatementDeleteModal();"), true);
}
}
protected void grdDraftPreliminaryEnquiry_RowDeleted(object sender, GridViewDeletedEventArgs e)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('Deleted' );", true);
}
protected void radGrdDraftPreliminaryEnquiry_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridDataItem)// to access a row
{
GridDataItem item = (GridDataItem)e.Item;
Int64 preEnqID = (Int64)DataBinder.Eval(item.DataItem, "preliminaryenquiryid");
//var preEnqId = DataBinder.Eval(item.DataItem, "preliminaryEnquiryID") == null ? 0 : (long)DataBinder.Eval(item.DataItem, "Priority");
LinkButton lnkgrdDraftPreliminaryEnquirySelect = (LinkButton)item.FindControl("lnkgrdDraftPreliminaryEnquirySelect");
//lnkgrdDraftPreliminaryEnquirySelect.PostBackUrl = "PreliminaryEnquiry.aspx?ReferenceId=" + referenceid + "&ReferenceType=195";
PreliminaryEnquiryId = preEnqID;
lnkgrdDraftPreliminaryEnquirySelect.PostBackUrl = "PreliminaryEnquiryMigration.aspx? ReferenceId = " + CryptologyFunctions.Encrypt(PreliminaryEnquiryId) + " & ReferenceType = " + CryptologyFunctions.Encrypt(Convert.ToInt64(EnumLookup.ReferenceType.PreliminaryEnquiry).ToString()) + " & PreliminaryEnquiryId = " + CryptologyFunctions.Encrypt(PreliminaryEnquiryId) + " & Finalized = " + CryptologyFunctions.Encrypt("false") + " &ViewMode="+ CryptologyFunctions.Encrypt( false)+")";
}
}
protected void radGrdDraftPreliminaryEnquiry_PageIndexChanged(object sender, Telerik.Web.UI.GridPageChangedEventArgs e)
{
var pageIndex = e.NewPageIndex;
radGrdDraftPreliminaryEnquiry.CurrentPageIndex = pageIndex;
LoadDraftPreliminaryEnquiry(pageIndex, radGrdDraftPreliminaryEnquiry.PageSize);
}
protected void radGrdDraftPreliminaryEnquiry_PageSizeChanged(object sender, GridPageSizeChangedEventArgs e)
{
LoadDraftPreliminaryEnquiry(0, e.NewPageSize);
}
protected void lnkAddNew_Click(object sender, EventArgs e)
{
Response.Redirect("PreliminaryEnquiryMigration.aspx");
}
protected void btnDelete_Click(object sender, EventArgs e)
{
bool Isdelete = false;
if (!string.IsNullOrEmpty(hdnpreliminaryEnquiryDeleteId.ToString()))
{
using (var client = ServiceClient<IPreliminaryEnquiryManager>.Create(ObjectConstants.PreliminaryEnquiryManager))
{
Isdelete = client.Instance.DeletePreliminaryEnquiryByPreliminaryEnquiryID(Convert.ToInt64(hdnpreliminaryEnquiryDeleteId));
}
if (Isdelete)
{
LoadDraftPreliminaryEnquiry(radGrdDraftPreliminaryEnquiry.CurrentPageIndex, 10);
ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('" + hdnpreliminaryEnquiryDeleteId + "Deleted ');", true);
string bodyMessage = (Isdelete) ? PageUtils.GetResourceValue("Common", "resDeleted") : "";
SetFadeMesssage(bodyMessage);
}
}
}
}
}
-----------------------stored procedure
USE [CBI]
GO
/****** Object: StoredProcedure [dbo].[SSP_GetAllDraftPreliminaryEnquiryByOfficeIDUserIDWithPaging] Script Date: 3/5/2024 10:49:26 AM ******/
DROP PROCEDURE [dbo].[SSP_GetAllDraftPreliminaryEnquiryByOfficeIDUserIDWithPaging]
GO
/****** Object: StoredProcedure [dbo].[SSP_GetAllDraftPreliminaryEnquiryByOfficeIDUserIDWithPaging] Script Date: 3/5/2024 10:49:26 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[SSP_GetAllDraftPreliminaryEnquiryByOfficeIDUserIDWithPaging]
@OfficeID bigINT,
@CurrentUserID bigint,
@PageIndex INT = 1,
@PageSize INT = 1
AS
BEGIN
SELECT fi.fileid, pe.preliminaryenquiryid, pe.sourceofpe,pe.complaintreferencenumber, pe.penumber, pe.PEDate, fi.OfficeID, fti.FileTrackingID
FROM PreliminaryEnquiry pe
INNER JOIN FileInformation fi
ON fi.referenceid = pe.preliminaryenquiryid AND fi.ReferenceType=195
INNER JOIN FileTrackingInformation fti
ON fti.FileID = fi.FileID AND fti.ToLocation = 0
AND fi.OfficeID = @OfficeID AND fi.CurrentUserID = @CurrentUserID ORDER BY pe.PreliminaryEnquiryId DESC
OFFSET (@PageIndex * @PageSize)
ROWS FETCH NEXT @PageSize ROWS ONLY
SELECT COUNT(*) as TotalRowCount
FROM PreliminaryEnquiry pe
INNER JOIN FileInformation fi
ON fi.referenceid = pe.preliminaryenquiryid AND fi.ReferenceType=195
INNER JOIN FileTrackingInformation fti
ON fti.FileID = fi.FileID AND fti.ToLocation = 0
AND fi.OfficeID = @OfficeID;
END
GO
No comments:
Post a Comment