-
Notifications
You must be signed in to change notification settings - Fork 0
/
AgentDashBoard.aspx.cs
295 lines (230 loc) · 8.87 KB
/
AgentDashBoard.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
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.Configuration;
using System.Drawing;
using System.IO;
using System.Data;
using System.Text;
public partial class AgentDashBoard : System.Web.UI.Page
{
public string ccode;
public string pcode;
public string managmobNo;
public string pname;
public string cname;
DataTable dt = new DataTable();
DataSet ds = new DataSet();
SqlConnection con = new SqlConnection();
DbHelper DB = new DbHelper();
BLLPlantName BllPlant = new BLLPlantName();
DateTime tdt = new DateTime();
DateTime dtm = new DateTime();
DateTime dtm1 = new DateTime();
string strsql = string.Empty;
public int refNo = 0;
public static int roleid;
public static string agentidget;
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack != true)
{
if ((Session["Name"] != null) && (Session["pass"] != null))
{
roleid = Convert.ToInt32(Session["Role"].ToString());
ccode = Session["Company_code"].ToString();
pcode = Session["Plant_Code"].ToString();
cname = Session["cname"].ToString();
pname = Session["pname"].ToString();
// managmobNo = Session["managmobNo"].ToString();
tdt = System.DateTime.Now;
if (roleid < 3)
{
LoadSinglePlantName();
}
else
{
LoadPlantName();
}
pcode = ddl_PlantName.SelectedItem.Value;
Label6.Visible = false;
}
else
{
Server.Transfer("LoginDefault.aspx");
}
}
else
{
if ((Session["Name"] != null) && (Session["pass"] != null))
{
ccode = Session["Company_code"].ToString();
cname = Session["cname"].ToString();
pname = Session["pname"].ToString();
// managmobNo = Session["managmobNo"].ToString();
pcode = ddl_PlantName.SelectedItem.Value;
}
else
{
Server.Transfer("LoginDefault.aspx");
}
Label6.Visible = false;
}
}
private void LoadPlantName()
{
try
{
ds = null;
ds = BllPlant.LoadPlantNameChkLst1(ccode.ToString());
if (ds != null)
{
ddl_PlantName.DataSource = ds;
ddl_PlantName.DataTextField = "Plant_Name";
ddl_PlantName.DataValueField = "plant_Code";//ROUTE_ID
ddl_PlantName.DataBind();
}
else
{
}
}
catch (Exception ex)
{
}
}
private void LoadSinglePlantName()
{
try
{
ds = null;
ds = BllPlant.LoadSinglePlantNameChkLst1(ccode.ToString(), pcode);
if (ds != null)
{
ddl_PlantName.DataSource = ds;
ddl_PlantName.DataTextField = "Plant_Name";
ddl_PlantName.DataValueField = "plant_Code";//ROUTE_ID
ddl_PlantName.DataBind();
}
else
{
}
}
catch (Exception ex)
{
}
}
protected void btn_ok_Click(object sender, EventArgs e)
{
getAgentpersonal();
}
public void getAgentpersonal()
{
try
{
// string str = "SELECT AgentId,AgentName,NULL AS LoanAmount,Null as RecoveryAmount,Null as ReceiptAmount,Null as Balance FROM (select am.Agent_Id as AgentId,am.Agent_Name as AgentName,am.Agent_Name AS LoanAmount,am.Agent_Name AS RecoveryAmount,am.Agent_Name AS ReceiptAmount,am.Agent_Name AS Balance from (Select Agent_Id,Agent_Name from agent_Master where plant_code='"+pcode+"' group by Agent_Id,Agent_Name ) as am left join (Select agent_Id from LoanDetails where plant_code='"+pcode+"' group by agent_Id ) as ld on ld.Agent_Id=am.agent_Id where ld.agent_Id is not null) AS AA";
string str = "select am.Agent_Id as CanNo,Agent_Name,convert(varchar,AddedDate,103) as JoinDate,Route_Name,Address,phone_Number as Mobile from( select Agent_Id,phone_Number,AddedDate from Agent_Master where Plant_code='"+pcode+"' and Agent_Id='"+ddl_Agentid.Text+"' group by Agent_Id,phone_Number,AddedDate) am left join (select Agent_Id,Agent_Name,Route_Name,Address,Mobile from AgentInformation where Plant_code='"+pcode+"' and Agent_Id='"+ddl_Agentid.Text+"') as Ai on am.Agent_Id=ai.Agent_Id";
con = DB.GetConnection();
SqlCommand cmd = new SqlCommand(str, con);
DataTable dt = new DataTable();
DataTable dt1 = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
foreach (DataRow dr in dt.Rows)
{
string getcan = dr[0].ToString();
string AgentName = dr[1].ToString();
string JoinDate = dr[2].ToString();
string RouteName = dr[3].ToString();
string Address = dr[4].ToString();
string phone = dr[5].ToString();
//dt1.Rows.Add(getcan,
//GridView2.DataSource = dt;
//GridView2.DataBind();
}
}
catch
{
}
}
protected void BindData()
{
string str = "select am.Agent_Id as CanNo,Agent_Name,convert(varchar,AddedDate,103) as JoinDate,Route_Name,Address,phone_Number as Mobile from( select Agent_Id,phone_Number,AddedDate from Agent_Master where Plant_code='" + pcode + "' and Agent_Id='" + ddl_Agentid.Text + "' group by Agent_Id,phone_Number,AddedDate) am left join (select Agent_Id,Agent_Name,Route_Name,Address,Mobile from AgentInformation where Plant_code='" + pcode + "' and Agent_Id='" + ddl_Agentid.Text + "') as Ai on am.Agent_Id=ai.Agent_Id";
con = DB.GetConnection();
SqlCommand cmd = new SqlCommand(str, con);
DataTable dt = new DataTable();
DataTable dt1 = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
DataList1.DataSource = dt;
DataList1.DataBind();
}
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
{
}
protected void ddl_PlantName_SelectedIndexChanged(object sender, EventArgs e)
{
}
public void getAgent()
{
try
{
string Getagent = "";
Getagent = "Select agent_id from Agent_master where plant_code='" + pcode + "' and agent_id='" + ddl_Agentid.Text + "'";
con = DB.GetConnection();
SqlCommand cmd = new SqlCommand(Getagent, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
ddl_Agentid.Items.Add(dr["agent_id"].ToString());
}
}
}
catch
{
}
}
//public void getAgent()
//{
// try
// {
// string str = "SELECT AgentId,AgentName,NULL AS LoanAmount,Null as RecoveryAmount,Null as ReceiptAmount,Null as Balance FROM (select am.Agent_Id as AgentId,am.Agent_Name as AgentName,am.Agent_Name AS LoanAmount,am.Agent_Name AS RecoveryAmount,am.Agent_Name AS ReceiptAmount,am.Agent_Name AS Balance from (Select Agent_Id,Agent_Name from agent_Master where plant_code='" + pcode + "' group by Agent_Id,Agent_Name ) as am left join (Select agent_Id from LoanDetails where plant_code='" + pcode + "' group by agent_Id ) as ld on ld.Agent_Id=am.agent_Id where ld.agent_Id is not null) AS AA";
// con = DB.GetConnection();
// SqlCommand cmd = new SqlCommand(str, con);
// DataTable dt = new DataTable();
// SqlDataAdapter da = new SqlDataAdapter(cmd);
// da.Fill(dt);
// if (dt.Rows.Count > 1)
// {
// GridView2.DataSource = dt;
// GridView2.DataBind();
// }
// }
// catch
// {
// }
//}
//protected void ddl_PlantName_SelectedIndexChanged(object sender, EventArgs e)
//{
// ddl_Plantcode.SelectedIndex = ddl_PlantName.SelectedIndex;
// pcode = ddl_Plantcode.SelectedItem.Value;
//}
//protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
//{
//}
protected void btn_print_Click(object sender, EventArgs e)
{
}
protected void btn_export_Click(object sender, EventArgs e)
{
}
protected void ddl_Agentid_SelectedIndexChanged(object sender, EventArgs e)
{
getAgent();
}
}