protected void Page_Load(object sender, EventArgs e) { List <ConversionReqModel> ConversionRequest = new List <ConversionReqModel>(); using (var con = Classes.DB.InstBTCDB("instbtc")) { if (Request.HttpMethod == "POST") { #region Build Additional Query for Search string client_id_query = !string.IsNullOrEmpty(txtClientId.Value) ? $"AND cv.client_id={txtClientId.Value} " : string.Empty; string email_query = !string.IsNullOrEmpty(txtClientEmail.Value) ? $"AND cl.email='{txtClientEmail.Value}' " : string.Empty; string created_date_query = !string.IsNullOrEmpty(txtCreatedDate.Value) ? $"AND cv.created_date::date='{DateTime.Parse(txtCreatedDate.Value)}' " : string.Empty; string credited_status_query = !string.IsNullOrEmpty(txtStatus.Value) ? $"AND cv.credited_status='{txtStatus.Value}' " : string.Empty; string client_name_query = !string.IsNullOrEmpty(txtClientName.Value) ? $"AND cv.client_name LIKE '%{txtClientName.Value}%' " : string.Empty; AddedQuery = string.Concat(client_id_query, email_query, created_date_query, credited_status_query, client_name_query); #endregion } #region Data Filling and Pagination Handling Dictionary <string, int> pagerDictionary = new Dictionary <string, int>(); string paginationString = "page"; DocListPager.initialize(paginationString, 10); pagerDictionary = DocListPager.paginate(Utilities.ConversionReqUtilities.GetConversionRequest(con, AddedQuery).Count().ToString()); ConversionRequest = Utilities.ConversionReqUtilities.GetConversionRequest(con, AddedQuery, pagerDictionary["offset"], pagerDictionary["limit"]); #endregion } rowCount.InnerHtml = $"{ConversionRequest.Count().ToString()} Records Found. ."; resultBody.InnerHtml = BuildHtmlTable(ConversionRequest); }
protected void Page_Load(object sender, EventArgs e) { this.OrderByMode = Request.QueryString["mode"] ?? "desc"; this.OrderBy = Request.QueryString["orderby"] ?? ""; if (this.OrderByMode.ToLower() != "desc") { this.OrderByMode = "asc"; } if (!this.OrderByDictionary.ContainsKey(this.OrderBy)) { this.OrderBy = this.OrderByDictionary.Keys.First(); } using (NpgsqlConnection conn = Classes.DB.InstBTCDB("instbtc")) { string txtType = Request.QueryString["txtType"]; string txtStatus = Request.QueryString["txtStatus"]; string txtClientId = Request.QueryString["txtClientId"]; string txtClientEmail = Request.QueryString["txtClientEmail"]; string txtClientName = Request.QueryString["txtClientName"]; string txtCreatedDate = Request.QueryString["txtCreatedDate"]; List <Documents> docs = new List <Documents>(); Dictionary <string, int> pagerDictionary = new Dictionary <string, int>(); string paginationString = "page"; DocListPager.initialize(paginationString, 10); TotalDocs = Utilities.Documents.DocumentsCount(conn); pagerDictionary = DocListPager.paginate(TotalDocs); docs = Utilities.Documents.GetDocuments(conn, pagerDictionary["offset"], pagerDictionary["limit"], orderby: $"{this.OrderByDictionary[this.OrderBy]} {this.OrderByMode.ToUpper()}"); string query = this.getQuery(conn, txtType, txtStatus, txtClientId, txtClientEmail, txtClientName, txtCreatedDate); if (query.Length > 0) { TotalDocs = Utilities.Documents.DocumentsCount(conn, query); DocListPager.AppendExistedQuery(); pagerDictionary = DocListPager.paginate(TotalDocs); docs = Utilities.Documents.GetDocuments(conn, query, pagerDictionary["offset"], pagerDictionary["limit"], orderby: $"{this.OrderByDictionary[this.OrderBy]} {this.OrderByMode.ToUpper()}"); } rowCount.InnerText = $"{TotalDocs} Records Found"; ShowDocuments(conn, docs); } }
protected void Page_Load(object sender, EventArgs e) { string pageChecker = Request.QueryString["page"]; if (string.IsNullOrEmpty(pageChecker)) { Session.Remove("WithdrawalSearch"); } using (NpgsqlConnection conn = Classes.DB.InstBTCDB("instbtc")) { NpgsqlCommand command = new NpgsqlCommand(); string query = string.Empty; if (Request.HttpMethod == "POST") { string status = txtStatus.Value; string clientId = txtClientId.Value; string clientEmail = txtClientEmail.Value; string clientName = txtClientName.Value; string walletId = txtWalletId.Value; string documentId = txtWalletId.Value; string createdDate = txtCreatedDate.Value; string docStatus = txtDocStatus.Value; string refferenceHash = txtHash.Value; WithdrawalSearchModel searchModel = new WithdrawalSearchModel() { Status = status, ClientModel = new ClientModelSearch { Id = clientId, Email = clientEmail }, DocumentStatus = docStatus, ClientName = clientName, WalletId = walletId, DocumentId = documentId, CreatedDate = createdDate, refference_hash = refferenceHash }; Session["WithdrawalSearch"] = searchModel; } if (Session["WithdrawalSearch"] != null) { WithdrawalSearchModel sessionSearchModel = (WithdrawalSearchModel)Session["WithdrawalSearch"]; //Get SQLCommand Parameters and Query Parameters KeyValuePair <NpgsqlCommand, string> pair = getParameter(sessionSearchModel); command = pair.Key; query = pair.Value; } //Get Withdrawals Datas List <MWithdrawal> withdrawalRequest = new List <MWithdrawal>(); withdrawalRequest = WithdrawalUtilities.WithdrawalRequest(conn, command, query); #region Pagination Dictionary <string, int> pagerDictionary = new Dictionary <string, int>(); string paginationString = "page"; DocListPager.initialize(paginationString, 10); TotalRequest = WithdrawalUtilities.GetWithdrawalCount(conn, command, query); pagerDictionary = DocListPager.paginate(TotalRequest); withdrawalRequest = WithdrawalUtilities.WithdrawalRequest(conn, command, query, pagerDictionary["offset"], pagerDictionary["limit"]); rowCount.InnerText = $"{TotalRequest} Records Found"; resultBody.InnerHtml = BuildHtmlTable(withdrawalRequest).ToString(); #endregion //Get Document Statuses Selection OptionUtilities optionUtilities = new OptionUtilities(); txtDocStatus.Items.Clear(); txtDocStatus.Items.AddRange(optionUtilities.GetDocumentStatusOptions()); //Return Values to their Fields ReturnFieldValues(); } }