-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcust_list.aspx.cs
89 lines (69 loc) · 3.15 KB
/
cust_list.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
80
81
82
83
84
85
86
87
88
89
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data.SqlClient;
namespace authwebpart
{
public partial class cust_list : System.Web.UI.Page
{
public static string s = WebConfigurationManager.ConnectionStrings["v0scon"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["suser"] == null)
{
Response.Redirect("login.aspx");
}
if (!IsPostBack)
{
/* using (scon)
{
scon.Open();
string query = " SELECT c_id, c_fname, c_mname, c_lname, city, create_date FROM customer where isactive=@isactive ORDER BY c_id DESC";
SqlCommand sqc = new SqlCommand(query, scon);
sqc.Parameters.AddWithValue("@isactive", true);
GridView2.DataSource = sqc.ExecuteReader();
GridView2.DataBind();
rdr.Close();
}
*/
}
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
Response.Redirect("~/view.aspx?c_id=" + ((LinkButton)sender).Text);
}
protected void GridView2_RowDataBound1(object sender, GridViewRowEventArgs e)
{
//diplay customer list and transection info
if (e.Row.RowType == DataControlRowType.DataRow)
{
using (SqlConnection scon = new SqlConnection(s))
{
scon.Open();
int rowcid = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "c_id"));
// Response.Write("customer id"+rowcid);
string tdquery = "SELECT SUM(t_amount) FROM transection where (c_id=@c_id AND t_type=@t_type) GROUP BY c_id ";
SqlCommand tdmycmd = new SqlCommand(tdquery, scon);
tdmycmd.Parameters.AddWithValue("@c_id", rowcid);
tdmycmd.Parameters.AddWithValue("@t_type","d");
object totald = tdmycmd.ExecuteScalar();
string ss = Convert.ToString(totald);
string tcquery = "SELECT SUM(t_amount) FROM transection where (c_id=@c_id AND t_type=@t_type) GROUP BY c_id ";
SqlCommand tcmycmd = new SqlCommand(tcquery, scon);
tcmycmd.Parameters.AddWithValue("@c_id", rowcid);
tcmycmd.Parameters.AddWithValue("@t_type", "c");
object totalc = tcmycmd.ExecuteScalar();
string ss1 = Convert.ToString(totalc);
//double rss = Math.Round(double.Parse(ss), 2);
//double rss1 = Math.Round(ss1, 2);
e.Row.Cells[5].Text = ss.ToString();
e.Row.Cells[4].Text = ss1.ToString();
}
}
}
}
}