forked from eh2arch/Shootball
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathView.aspx.cs
79 lines (74 loc) · 2.43 KB
/
View.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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;
public partial class View : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Server=ARCH; database=demo; uid=sa;pwd=sql");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
fillgrid();
}
void fillgrid()
{
Label_nopl.Visible = false;
con.Open();
string query = "select sum(Total) from defenders group by team having team='" + (int)(Drop_teamview.SelectedIndex + 1) + "'";
string query2 = "select sum(cost) from defenders group by team having team='" + (int)(Drop_teamview.SelectedIndex + 1) + "'";
SqlCommand cmd = new SqlCommand(query, con);
int ans, ans2;
try
{
ans = (int)cmd.ExecuteScalar();
}
catch (Exception ex)
{
ans = 0;
}
SqlCommand cmd2 = new SqlCommand(query2, con);
try
{
ans2 = (int)cmd2.ExecuteScalar();
}
catch (Exception ex)
{
ans2 = 0;
}
Literal1.Text = "Team " + (int)(Drop_teamview.SelectedIndex + 1) + " stats :";
//Literal2.Text = "Total Points: " + ans;
Literal3.Text = "Total Balance: " + (int)(100 - ans2) + " million ₤";
//Literal4.Text="Goalkeepers: "+(int)
string q = "select pl_name,club,pl_pos,cost from defenders where team='" + (int)(Drop_teamview.SelectedIndex + 1) + "'";
SqlDataAdapter da = new SqlDataAdapter(q, con);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
if (ds.Tables[0].Rows.Count==0)
{
Label_nopl.Visible = true;
}
}
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
fillgrid();
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
fillgrid();
}
protected void Drop_teamview_SelectedIndexChanged(object sender, EventArgs e)
{
fillgrid();
}
}