using System; using System.Data; using System.Data.SqlClient; 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.Text; public partial class Example3 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string connstring = ConfigurationManager.ConnectionStrings["Statistics"].ToString(); SqlConnection conn = new SqlConnection(connstring); MOHP.NICHP.fillComboBox(dropCent, "select * from LTDepHosp", conn, "-----"); //TreeView1.Nodes[0].Checked = true; } } public void FillCustomers() { string connstring = ConfigurationManager.ConnectionStrings["Statistics"].ToString(); SqlConnection conn = new SqlConnection(connstring); SqlCommand cmdFilter = new SqlCommand(); cmdFilter.CommandType = CommandType.StoredProcedure; cmdFilter.CommandText = "showHosp"; cmdFilter.Parameters.AddWithValue("@codDep", int.Parse(dropCent.SelectedValue.ToString())); cmdFilter.Connection = conn; conn.Open(); SqlDataAdapter da = new SqlDataAdapter(cmdFilter); DataSet ds = new DataSet(); da.Fill(ds); TreeView1.Nodes.Clear(); foreach (DataRow dr in ds.Tables[0].Rows) { TreeNode node = new TreeNode(); node.Text = dr["HospNam"].ToString().Trim(); node.Value = dr["CodHosp"].ToString().Trim(); node.PopulateOnDemand = true; node.ToolTip = "Click to get Child"; node.SelectAction = TreeNodeSelectAction.SelectExpand; node.CollapseAll(); TreeView1.Nodes.Add(node); } } private DataSet GetDataSet(string sql) { //if (sql == null || sql.Length == 0) // return String.Empty; string connstring = ConfigurationManager.ConnectionStrings["Statistics"].ToString(); SqlConnection conn = new SqlConnection(connstring); //SqlConnection conn = null; try { SqlDataAdapter da = new SqlDataAdapter(sql, conn); DataSet ds = new DataSet(); da.Fill(ds); return ds; } catch (Exception ex) { return null; } } protected void TreeView1_TreeNodePopulate(object sender, TreeNodeEventArgs e) { switch (e.Node.Depth) { case 0: FillCustomers(); break; } } protected void Button1_Click(object sender, EventArgs e) { } protected void dropCent_SelectedIndexChanged(object sender, EventArgs e) { FillCustomers(); } void check_changed(object sender, EventArgs e) { //lblTest.Text = "TestText"; } protected void check_changed(object sender, TreeNodeEventArgs e) { //lblTest.Text = "TestText"; } protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e) { } protected void Button1_Click1(object sender, EventArgs e) { StringBuilder Hosp = new StringBuilder(); string connstring = ConfigurationManager.ConnectionStrings["Statistics"].ToString(); SqlConnection conn = new SqlConnection(connstring); SqlCommand cmdFilter = new SqlCommand(); cmdFilter.CommandType = CommandType.StoredProcedure; cmdFilter.CommandText = "showhospdep"; cmdFilter.Connection = conn; conn.Open(); SqlDataAdapter da = new SqlDataAdapter(cmdFilter); DataSet dsFillter = new DataSet(); da.Fill(dsFillter, "showhospdep"); 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 (TreeView1.Nodes[1].Checked != false) { if (txtsql.Trim() != "") txtsql += " AND "; txtsql += "CodHosp=" +TreeView1.Nodes[1].Value; } dvSearch.RowFilter = txtsql.Trim(); grdShowHosp.DataSource = dvSearch; grdShowHosp.DataBind(); conn.Close(); TextBox1.Text = txtsql; } public void CheckAllNodes(TreeNodeCollection nodes) { foreach (TreeNode node in nodes) { node.Checked = true; } } public void UncheckAllNodes(TreeNodeCollection nodes) { foreach (TreeNode node in nodes) { node.Checked = false; } } void showCliencEnd() { //TextBox1.Text = TreeView1.SelectedNode.Text; string connstring = ConfigurationManager.ConnectionStrings["Statistics"].ToString(); SqlConnection conn = new SqlConnection(connstring); SqlCommand cmdFilter = new SqlCommand(); cmdFilter.CommandType = CommandType.StoredProcedure; cmdFilter.CommandText = "showhospdep"; cmdFilter.Parameters.AddWithValue("@CodDep", int.Parse(dropCent.SelectedValue.ToString())); int P_PAR; P_PAR = int.Parse(TreeView1.Nodes[0].Value.ToString()); cmdFilter.Parameters.AddWithValue("@CodHosp",P_PAR); SqlDataAdapter da = new SqlDataAdapter(cmdFilter); DataSet dsFillter = new DataSet(); cmdFilter.Connection = conn; conn.Open(); da.Fill(dsFillter); grdShowHosp.DataSource = dsFillter; grdShowHosp.DataBind(); conn.Close(); } protected void grdShowhosp_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Separator) { Label lbl1 = (Label)e.Row.FindControl("lblNeaft1"); Label lbl2 = (Label)e.Row.FindControl("lblInstrance"); Label lbl3 = (Label)e.Row.FindControl("lblFamily"); Label lbl4 = (Label)e.Row.FindControl("lblFree"); Label lbl5 = (Label)e.Row.FindControl("lblCase_Arab"); Label lbl6 = (Label)e.Row.FindControl("lblCase_Forgien1"); Label lbl8 = (Label)e.Row.FindControl("lblConcract"); Label lbl7 = (Label)e.Row.FindControl("lbltotal"); Label lblMonth = (Label)e.Row.FindControl("lblMonth1"); int totalvalue = int.Parse(lbl1.Text.ToString()) + int.Parse(lbl2.Text.ToString()) + int.Parse(lbl3.Text.ToString()) + int.Parse(lbl4.Text.ToString()) + int.Parse(lbl5.Text.ToString()) + int.Parse(lbl6.Text.ToString()) + int.Parse(lbl8.Text.ToString()); e.Row.Cells[8].Text = totalvalue.ToString(); DataRowView rowView = (DataRowView)e.Row.DataItem; int salary1 = (int)rowView["TotalNeaft_City"]; int salary2 = (int)rowView["TotalInstrance"]; int salary3 = (int)rowView["TotalConcract"]; int salary4 = (int)rowView["TotalFamily"]; int salary5 = (int)rowView["TotalFree"]; int salary6 = (int)rowView["TotalCase_Arab"]; int salary7 = (int)rowView["TotalCase_Forgien"]; int salary = (int)rowView["TotalAll"]; totalSalary += salary; totalNeaft_City += salary1; totalInstrance += salary2; totalConcract += salary3; totalFamily += salary4; totalFree += salary5; totalCase_Arab += salary6; totalCase_Forgien += salary7; } } public double GetTotalCase_Forgien() { return totalCase_Forgien; } public double GetTotalCase_Arab() { return totalCase_Arab; } public double GetTotalFree() { return totalFree; } public double GetTotalFamily() { return totalFamily; } public double GetTotalConcract() { return totalConcract; } public double GetTotalInstrance() { return totalInstrance; } public double GetTotalNeaf() { return totalNeaft_City; } public double GetTotalSalary() { return totalSalary; } private double totalSalary = 0; private double totalNeaft_City = 0; private double totalInstrance = 0; private double totalConcract = 0; private double totalFamily = 0; private double totalFree = 0; private double totalCase_Arab = 0; private double totalCase_Forgien = 0; protected void TreeView1_SelectedNodeChanged1(object sender, EventArgs e) { ///******************************************MOHAMED ABDUL-RAOUF 18-11-2013 TextBox1.Text = TreeView1.SelectedNode.Value; string connstring = ConfigurationManager.ConnectionStrings["Statistics"].ToString(); SqlConnection conn = new SqlConnection(connstring); SqlCommand cmdFilter = new SqlCommand(); cmdFilter.CommandType = CommandType.StoredProcedure; cmdFilter.CommandText = "showhospdep"; cmdFilter.Connection = conn; conn.Open(); //cmdFilter.Parameters.AddWithValue("@CodDep", int.Parse(dropCent.SelectedValue.ToString())); //int P_PAR; //P_PAR = int.Parse(TreeView1.Nodes[1].Value.ToString()); //cmdFilter.Parameters.AddWithValue("@CodHosp",TreeView1.SelectedValue.ToString()); SqlDataAdapter da = new SqlDataAdapter(cmdFilter); DataSet dsFillter = new DataSet(); da.Fill(dsFillter, "showhospdep"); 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 (TreeView1.Nodes[1].Checked != false) { if (txtsql.Trim() != "") txtsql += " AND "; txtsql += "CodHosp=" + TreeView1.Nodes[1].Value; } dvSearch.RowFilter = txtsql.Trim(); grdShowHosp.DataSource = dvSearch; grdShowHosp.DataBind(); conn.Close(); } ///******************************************MOHAMED ABDUL-RAOUF 18-11-2013 private void Treeview1_AfterSelect(object sender, TreeNodeEventArgs e) { if (TreeView1.SelectedNode.Depth == 0) { foreach (TreeNode item in TreeView1.SelectedNode.ChildNodes) { item.Checked = true; } } } protected void grdShowClienc_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Separator) { Label lbl1 = (Label)e.Row.FindControl("lblNeaft1"); Label lbl2 = (Label)e.Row.FindControl("lblInstrance"); Label lbl3 = (Label)e.Row.FindControl("lblFamily"); Label lbl4 = (Label)e.Row.FindControl("lblFree"); Label lbl5 = (Label)e.Row.FindControl("lblCase_Arab"); Label lbl6 = (Label)e.Row.FindControl("lblCase_Forgien1"); Label lbl8 = (Label)e.Row.FindControl("lblConcract"); Label lbl7 = (Label)e.Row.FindControl("lbltotal"); Label lblMonth = (Label)e.Row.FindControl("lblMonth1"); Label lblDep = (Label)e.Row.FindControl("NameDep"); int totalvalue = int.Parse(lbl1.Text.ToString()) + int.Parse(lbl2.Text.ToString()) + int.Parse(lbl3.Text.ToString()) + int.Parse(lbl4.Text.ToString()) + int.Parse(lbl5.Text.ToString()) + int.Parse(lbl6.Text.ToString()) + int.Parse(lbl8.Text.ToString()); e.Row.Cells[8].Text = totalvalue.ToString(); DataRowView rowView = (DataRowView)e.Row.DataItem; int salary1 = (int)rowView["TotalNeaft_City"]; int salary2 = (int)rowView["TotalInstrance"]; int salary3 = (int)rowView["TotalConcract"]; int salary4 = (int)rowView["TotalFamily"]; int salary5 = (int)rowView["TotalFree"]; int salary6 = (int)rowView["TotalCase_Arab"]; int salary7 = (int)rowView["TotalCase_Forgien"]; int salary = (int)rowView["TotalAll"]; totalSalary += salary; totalNeaft_City += salary1; totalInstrance += salary2; totalConcract += salary3; totalFamily += salary4; totalFree += salary5; totalCase_Arab += salary6; totalCase_Forgien += salary7; } } protected void TreeNodeEventHandler(object sender, TreeNodeEventArgs e) { } }