File manager - Edit - G:/PleskVhosts/indiaminerals.in/vgm.INFOFIXDEVELOPERS.COM/admin/Medicine_ObserveReport.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 Medicine_ObserveReport : BasePageClass { SqlDataAdapter da1; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string cs = ConfigurationManager.ConnectionStrings["gav"].ConnectionString; using (SqlConnection con = new SqlConnection(cs)) { string query = "SELECT O.*, M.Medicine_name FROM observation AS O " + "INNER JOIN medicine AS M ON O.Medicine_id = M.ID "; using (SqlCommand cmd = new SqlCommand(query, con)) { con.Open(); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { DataTable dt = new DataTable(); da.Fill(dt); Gridview1.DataSource = dt; Gridview1.DataBind(); } } } da1 = new SqlDataAdapter("SELECT DISTINCT M.Medicine_name FROM observation AS O INNER JOIN medicine AS M ON O.Medicine_id = M.ID", cs); DataTable dt1 = new DataTable(); da1.Fill(dt1); DropDownList1.DataSource = dt1; DropDownList1.DataTextField = "Medicine_name"; DropDownList1.DataBind(); } } protected void show_Click(object sender, EventArgs e) { try { string selectedMedicine = DropDownList1.SelectedValue; string cs = ConfigurationManager.ConnectionStrings["gav"].ConnectionString; using (SqlConnection con = new SqlConnection(cs)) { con.Open(); DateTime fromDate, toDate; if (DateTime.TryParse(From.Text, out fromDate) && DateTime.TryParse(To.Text, out toDate)) { string query = "SELECT O.*, M.Medicine_name FROM observation AS O " + "INNER JOIN medicine AS M ON O.Medicine_id = M.ID " + "WHERE O.Date >= @FromDate AND O.Date <= @ToDate "; if (!string.IsNullOrEmpty(selectedMedicine)) { query += "AND M.Medicine_name = @MedicineName "; } using (SqlCommand cmd = new SqlCommand(query, con)) { cmd.Parameters.AddWithValue("@FromDate", fromDate); cmd.Parameters.AddWithValue("@ToDate", toDate); if (!string.IsNullOrEmpty(selectedMedicine)) { cmd.Parameters.AddWithValue("@MedicineName", selectedMedicine); } using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { DataTable dt = new DataTable(); da.Fill(dt); Gridview1.DataSource = dt; Gridview1.DataBind(); } } } } } catch(Exception ex) { Response.Write("<script>alert('An error occurred: " + ex.Message + "')</script>"); } } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { string selectedMedicine = DropDownList1.SelectedValue; string cs = ConfigurationManager.ConnectionStrings["gav"].ConnectionString; using (SqlConnection con = new SqlConnection(cs)) { con.Open(); string query = "SELECT O.*, M.Medicine_name FROM observation AS O " + "INNER JOIN medicine AS M ON O.Medicine_id = M.ID"; if (!string.IsNullOrEmpty(selectedMedicine)) { query += " WHERE M.Medicine_name = @MedicineName"; } using (SqlCommand cmd = new SqlCommand(query, con)) { if (!string.IsNullOrEmpty(selectedMedicine)) { cmd.Parameters.AddWithValue("@MedicineName", selectedMedicine); } using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { DataTable dt = new DataTable(); da.Fill(dt); Gridview1.DataSource = dt; Gridview1.DataBind(); } } } } } }
| ver. 1.4 |
Github
|
.
| PHP 7.3.33 | Generation time: 0.08 |
proxy
|
phpinfo
|
Settings