using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; using System.Drawing; public partial class RepBed : System.Web.UI.Page { public static string Interused = ""; protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string connstring = ConfigurationManager.ConnectionStrings["def"].ToString(); SqlConnection conn = new SqlConnection(connstring); MOHP.NICHP.fillComboBox(dropCent, "select * from LTDepHosp", conn, "-----"); MOHP.NICHP.fillComboBox(cmbMonth, "select * from LTMonth", conn, "----"); //lblData.Text = DateTime.Now.DayOfWeek.ToString() + " " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); gridshow.SelectedRowStyle.ForeColor = Color.Blue; } } protected void dropCent_SelectedIndexChanged1(object sender, EventArgs e) { string connstring = ConfigurationManager.ConnectionStrings["def"].ToString(); SqlConnection conn = new SqlConnection(connstring); MOHP.NICHP.fillComboBox(DropHosp, "select CodHosp,HospNam from LTHospt where Coddep=" + dropCent.SelectedValue, conn, "-----"); } protected void DropHosp_SelectedIndexChanged1(object sender, EventArgs e) { } protected void ButtonSrch_Click(object sender, EventArgs e) { SearchBed(); //showdataGrid(); } void showdataGrid() { for (int i = 0; i < gridshow.Rows.Count; ++i) { GridViewRow rowWF = gridshow.Rows[i]; Label lab = (Label)gridshow.Rows[i].FindControl("lblIns"); lab.Visible = false; } } void SearchBed() { string connstring = ConfigurationManager.ConnectionStrings["def"].ToString(); SqlConnection conn = new SqlConnection(connstring); SqlCommand cmdFilter = new SqlCommand(); cmdFilter.CommandType = CommandType.StoredProcedure; cmdFilter.CommandText = "ShowReportBed"; cmdFilter.Connection = conn; conn.Open(); SqlDataAdapter da = new SqlDataAdapter(cmdFilter); DataSet dsFillter = new DataSet(); da.Fill(dsFillter, "ShowReportBed"); DataView dvSearch = new DataView((dsFillter.Tables[0])); DataTable dt = new DataTable(); da.Fill(dt); string txtsql = ""; if (dropCent.SelectedValue.Trim() != "-1") { txtsql += "CodDep=" + dropCent.SelectedValue; } if (DropHosp.SelectedValue.Trim() != "-1") { if (txtsql.Trim() != "") txtsql += " AND "; txtsql += "CodHosp=" + DropHosp.SelectedValue; } if (cmbMonth.SelectedValue.Trim() != "-1") { if (txtsql.Trim() != "") txtsql += " AND "; txtsql += "IDMonth=" + cmbMonth.SelectedValue; } if (Chkins.Checked) { if (txtsql.Trim() != "") txtsql += " AND "; txtsql += "No_Interused <>" + "0"; showdataGrid(); } if (chkInterunused.Checked) { if (txtsql.Trim() != "") txtsql += " AND "; txtsql += "No_Interunused <>" + "0"; } if (ChkKidney.Checked) { if (txtsql.Trim() != "") txtsql += " AND "; txtsql += "NoKidney1 <>" + "0"; } if (ChkEmercy.Checked) { if (txtsql.Trim() != "") txtsql += " AND "; txtsql += "No_Emercy <>" + "0"; } if (chkWea.Checked) { if (txtsql.Trim() != "") txtsql += " AND "; txtsql += "No_Wea <>" + "0"; } if (chkResDr.Checked) { if (txtsql.Trim() != "") txtsql += " AND "; txtsql += "No_ResDr <>" + "0"; } if (chkResNurs.Checked) { if (txtsql.Trim() != "") txtsql += " AND "; txtsql += "No_ResNurs <>" + "0"; } dvSearch.RowFilter = txtsql.Trim(); gridshow.DataSource = dvSearch; gridshow.DataBind(); LblShowDep.Text = dropCent.SelectedItem.Text; LblShowDep.Visible = true; } protected void cmbMonth_SelectedIndexChanged(object sender, EventArgs e) { } protected void gridshow_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Label Points = ((Label)e.Row.FindControl("lblIns")); //Points.Visible = false; //do what ever you want to do here using the value of your label } } }