File manager - Edit - G:/PleskVhosts/indiaminerals.in/vgm.INFOFIXDEVELOPERS.COM/admin/transferReport.aspx.cs
Back
using System; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Web.UI.WebControls; using WebApp.LIBS; namespace WebApp.admin { public partial class transferReport : BasePageClass { string cs = ConfigurationManager.ConnectionStrings["gav"].ConnectionString; SqlDataAdapter da1; protected void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { string query = "SELECT * FROM discharge WHERE Discharge = 'Transfer to Own Gaushala' OR Discharge='Transfer to Other Gaushala' ORDER BY Discharge_id DESC"; using (SqlConnection connection = new SqlConnection(cs)) { using (da1 = new SqlDataAdapter(query, connection)) { DataTable dt = new DataTable(); da1.Fill(dt); Gridview1.DataSource = dt; Gridview1.DataBind(); } } } } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { string selectedTransferType = DropDownList1.SelectedValue; // Build your query based on the selected transfer type string query = "SELECT * FROM discharge WHERE Discharge = @TransferType ORDER BY Discharge_id DESC"; using (SqlConnection connection = new SqlConnection(cs)) { using (da1 = new SqlDataAdapter(query, connection)) { da1.SelectCommand.Parameters.AddWithValue("@TransferType", selectedTransferType); DataTable dt = new DataTable(); da1.Fill(dt); Gridview1.DataSource = dt; Gridview1.DataBind(); } } } protected void show_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(DropDownList1.SelectedValue)) { // Check if both "From" and "To" dates are selected if (!string.IsNullOrEmpty(From.Text) && !string.IsNullOrEmpty(To.Text)) { string selectedTransferType = DropDownList1.SelectedValue; string fromDate = From.Text; string toDate = To.Text; // Build your query based on the selected transfer type and date range string query = "SELECT * FROM discharge WHERE Discharge = @TransferType AND Date BETWEEN @FromDate AND @ToDate ORDER BY Discharge_id DESC"; using (SqlConnection connection = new SqlConnection(cs)) { using (da1 = new SqlDataAdapter(query, connection)) { da1.SelectCommand.Parameters.AddWithValue("@TransferType", selectedTransferType); da1.SelectCommand.Parameters.AddWithValue("@FromDate", fromDate); da1.SelectCommand.Parameters.AddWithValue("@ToDate", toDate); DataTable dt = new DataTable(); da1.Fill(dt); Gridview1.DataSource = dt; Gridview1.DataBind(); } } } } else { if (!string.IsNullOrEmpty(From.Text) && !string.IsNullOrEmpty(To.Text)) { string fromDate = From.Text; string toDate = To.Text; // Build your query based on the selected transfer type and date range string query = "SELECT * FROM discharge WHERE Date BETWEEN @FromDate AND @ToDate ORDER BY Discharge_id DESC"; using (SqlConnection connection = new SqlConnection(cs)) { using (da1 = new SqlDataAdapter(query, connection)) { da1.SelectCommand.Parameters.AddWithValue("@FromDate", fromDate); da1.SelectCommand.Parameters.AddWithValue("@ToDate", toDate); DataTable dt = new DataTable(); da1.Fill(dt); Gridview1.DataSource = dt; Gridview1.DataBind(); } } } } } protected void Gridview1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView rowView = (DataRowView)e.Row.DataItem; string dischargeType = rowView["Discharge"].ToString(); // Assuming "gaushala_name" is the column containing the owner's mobile number string ownerMobileNo = rowView["gaushala_name"].ToString(); // Find the "Gaushala Name" column in the GridView int columnIndex = -1; for (int i = 0; i < e.Row.Cells.Count; i++) { if (Gridview1.Columns[i] is BoundField && ((BoundField)Gridview1.Columns[i]).DataField == "gaushala_name") { columnIndex = i; break; } } // Modify the "Gaushala Name" value based on the discharge type if (columnIndex != -1) { if (dischargeType == "Transfer to Own Gaushala") { e.Row.Cells[columnIndex].Text = "Own"; } // If it's "Transfer to Other Gaushala," the actual value will be displayed } } } } }
| ver. 1.4 |
Github
|
.
| PHP 7.3.33 | Generation time: 0.05 |
proxy
|
phpinfo
|
Settings