File manager - Edit - G:/PleskVhosts/indiaminerals.in/vgm.INFOFIXDEVELOPERS.COM/admin/Registration_list.aspx.cs
Back
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Data; using System.Configuration; using WebApp.LIBS; namespace VGM.admin { public partial class Registration_list : BasePageClass { string cs = ConfigurationManager.ConnectionStrings["gav"].ConnectionString; SqlDataAdapter da1; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindGridData(); } } protected void View_Command(object sender, CommandEventArgs e) { if (e.CommandName == "View") { string commandArgument = e.CommandArgument.ToString(); string[] arguments = commandArgument.Split('&'); if (arguments.Length == 2) { string tagNo = arguments[0]; string animal_category = arguments[1]; Response.Redirect($"animal_detailmaster.aspx?tag_no={tagNo}&animal_category={animal_category}"); } else { // } } } protected void show_Click(object sender, EventArgs e) { string selectedStatus = DropDownList1.SelectedValue; string fromDate = From.Text; string toDate = To.Text; using (SqlConnection con = new SqlConnection(cs)) { con.Open(); if (!string.IsNullOrEmpty(selectedStatus)) { // Construct a dynamic SQL query string with parameters for the date range and status string sqlQuery = $"SELECT * FROM registration WHERE status = @Status AND Date BETWEEN @FromDate AND @ToDate ORDER BY id DESC"; using (SqlCommand cmd = new SqlCommand(sqlQuery, con)) { cmd.Parameters.AddWithValue("@Status", selectedStatus); cmd.Parameters.AddWithValue("@FromDate", fromDate); cmd.Parameters.AddWithValue("@ToDate", toDate); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); BindGrid(dt); } } else { // Construct a dynamic SQL query string with parameters for only the date range string sqlQuery = "SELECT * FROM registration WHERE Date BETWEEN @FromDate AND @ToDate ORDER BY id DESC"; using (SqlCommand cmd = new SqlCommand(sqlQuery, con)) { cmd.Parameters.AddWithValue("@FromDate", fromDate); cmd.Parameters.AddWithValue("@ToDate", toDate); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); // Clear existing rows before adding new ones Gridview1.DataSource = null; Gridview1.DataBind(); // Use a DataView for sorting and filtering DataView dv = dt.DefaultView; dv.Sort = "id DESC"; Gridview1.DataSource = dv; Gridview1.DataBind(); } } } } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { string selectedStatus = DropDownList1.SelectedValue; using (SqlConnection con = new SqlConnection(cs)) { con.Open(); string sqlQuery; if (!string.IsNullOrEmpty(selectedStatus)) { // Construct a dynamic SQL query string sqlQuery = $"SELECT * FROM registration WHERE status = @Status ORDER BY id DESC"; using (SqlCommand cmd = new SqlCommand(sqlQuery, con)) { cmd.Parameters.AddWithValue("@Status", selectedStatus); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); BindGrid(dt); } } } } private void BindGridData() { da1 = new SqlDataAdapter("SELECT * FROM registration ORDER BY id DESC", cs); DataTable dt1 = new DataTable(); da1.Fill(dt1); BindGrid(dt1); } private void BindGrid(DataTable dt) { // Clear existing rows before adding new ones Gridview1.DataSource = null; Gridview1.DataBind(); // Use a DataView for sorting and filtering DataView dv = dt.DefaultView; dv.Sort = "id DESC"; Gridview1.DataSource = dv; Gridview1.DataBind(); } } }
| ver. 1.4 |
Github
|
.
| PHP 7.3.33 | Generation time: 0.04 |
proxy
|
phpinfo
|
Settings