File manager - Edit - G:/PleskVhosts/indiaminerals.in/vgm.INFOFIXDEVELOPERS.COM/admin/Reg_Closereport.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 Reg_Closereport : BasePageClass { string cs = ConfigurationManager.ConnectionStrings["gav"].ConnectionString; SqlDataAdapter da1; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string statusDischarge = "Discharge"; string statusDeath = "Death"; string statusOther = "Other"; da1 = new SqlDataAdapter("select * from registration where (status = '" + statusDischarge + "' OR status = '" + statusDeath + "' OR status = '" + statusOther + "')", cs); DataTable dt1 = new DataTable(); da1.Fill(dt1); Gridview1.DataSource = dt1; Gridview1.DataBind(); } } protected void show_Click(object sender, EventArgs e) { try { string cs = ConfigurationManager.ConnectionStrings["gav"].ConnectionString; string statusDischarge = "Discharge"; string statusDeath = "Death"; string statusOther = "Other"; string query = "SELECT id, Tag_no, animal_category, species, age, owner_name, owner_mobile_no FROM registration WHERE Date BETWEEN @FromDate AND @ToDate and status = @StatusDischarge OR status = @StatusDeath OR status = @StatusOther"; using (SqlConnection connection = new SqlConnection(cs)) { connection.Open(); SqlCommand cmd = new SqlCommand(query, connection); // Convert the text from the TextBoxes to DateTime objects DateTime fromDate = DateTime.Parse(From.Text); DateTime toDate = DateTime.Parse(To.Text); cmd.Parameters.AddWithValue("@FromDate", fromDate); cmd.Parameters.AddWithValue("@ToDate", toDate); cmd.Parameters.AddWithValue("@StatusDischarge", statusDischarge); cmd.Parameters.AddWithValue("@StatusDeath", statusDeath); cmd.Parameters.AddWithValue("@StatusOther", statusOther); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); Gridview1.DataSource = dt; Gridview1.DataBind(); } } catch (Exception ex) { // Log the error for debugging purposes // You might want to use a dedicated logging framework or log to a file/database // Example: Logger.Log(ex); // Display a user-friendly error message //ErrorMessageLabel.Text = "An error occurred while processing your request. Please try again later."; // Optionally, you can redirect the user to a custom error page // Example: Response.Redirect("ErrorPage.aspx"); } } protected void View_Command(object sender, CommandEventArgs e) { if (e.CommandName == "View") { string tagNo = e.CommandArgument.ToString(); // Assuming 'animal_detailmaster.aspx' is the target page Response.Redirect("animal_detailmaster.aspx?tag_no=" + tagNo); } } } }
| ver. 1.4 |
Github
|
.
| PHP 7.3.33 | Generation time: 0.03 |
proxy
|
phpinfo
|
Settings