-
Notifications
You must be signed in to change notification settings - Fork 0
/
AgentInfoModify.aspx.cs
242 lines (206 loc) · 8.19 KB
/
AgentInfoModify.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
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html.simpleparser;
public partial class AgentInfoModify : System.Web.UI.Page
{
public static int roleid;
public string ccode;
public string pcode;
public string managmobNo;
public string pname;
public string cname;
public string agentName;
public string agentid;
DateTime dtm = new DateTime();
SqlConnection con = new SqlConnection();
DbHelper DB = new DbHelper();
DataSet DTG = new DataSet();
DataTable agentdataviews = new DataTable();
DataTable filename = new DataTable();
DataTable viewloanrecovery = new DataTable();
DateTime d1;
DateTime d2;
DateTime d11;
DateTime d22;
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
if ((Session["Name"] != null) && (Session["pass"] != null))
{
dtm = System.DateTime.Now;
ccode = Session["Company_code"].ToString();
pcode = Session["Plant_Code"].ToString();
//txt_FromDate.Text = dtm.ToString("dd/MM/yyyy");
roleid = Convert.ToInt32(Session["Role"].ToString());
dtm = System.DateTime.Now;
GridView2.Visible = true;
LoadPlantcode();
getagentlist();
// pcode = ddl_Plantname.SelectedItem.Value;
}
else
{
// pname = ddl_Plantname.SelectedItem.Text;
}
}
else
{
ccode = Session["Company_code"].ToString();
// LoadPlantcode();
// pcode = ddl_Plantname.SelectedItem.Value;
}
}
catch
{
}
}
public void LoadPlantcode()
{
try
{
con = DB.GetConnection();
string stt = "SELECT Plant_Code, Plant_Name FROM Plant_Master where plant_code not in (150,139,160) order by Plant_Code asc";
SqlCommand cmd = new SqlCommand(stt, con);
SqlDataAdapter DA = new SqlDataAdapter(cmd);
DA.Fill(DTG);
ddl_Plantname.DataSource = DTG.Tables[0];
ddl_Plantname.DataTextField = "Plant_Name";
ddl_Plantname.DataValueField = "Plant_Code";
ddl_Plantname.DataBind();
}
catch
{
}
}
protected void btn_get_Click(object sender, EventArgs e)
{
getagentlist();
}
public void getagentlist()
{
string value = "";
con = DB.GetConnection();
// value = "Select agent_id,Agent_name,Mobile,cartage,splbonus,BankName,ifsccode,accno,Nagent_id,NAgent_name,NMobile,Ncartage,Nsplbonus,NBankName,NBranchName,Nifsccode,Naccno,Username,convert(varchar,Datetime) as date from agent_masterLogs order by Tid desc";
if (RadioButtonList1.SelectedItem.Value == "1")
{
value = "sELECT agent_id,Agent_name,Mobile,cartage,splbonus,BMBANK_NAME as BankName,ifsccode,accno,Nagent_id,NAgent_name,NMobile,Ncartage,Nsplbonus,NBankName,NBranchName,Nifsccode,Naccno,Username,Date FROM (Select tid,agent_id,Agent_name,Mobile,cartage,splbonus,BankName,ifsccode,accno,Nagent_id,NAgent_name,NMobile,Ncartage,Nsplbonus,NBankName,NBranchName,Nifsccode,Naccno,Username,convert(varchar,Datetime,109) as date from agent_masterLogs ) AS LL LEFT JOIN (sELECT Bank_ID,BANK_NAME as BMBANK_NAME FROM BANK_MASTER GROUP BY Bank_ID,BANK_NAME ) AS BM ON LL.BankName=BM.Bank_ID order by tid desc";
}
else
{
value = "sELECT agent_id,Agent_name,Mobile,cartage,splbonus,BMBANK_NAME as BankName,ifsccode,accno,Nagent_id,NAgent_name,NMobile,Ncartage,Nsplbonus,NBankName,NBranchName,Nifsccode,Naccno,Username,Date FROM (Select tid,agent_id,Agent_name,Mobile,cartage,splbonus,BankName,ifsccode,accno,Nagent_id,NAgent_name,NMobile,Ncartage,Nsplbonus,NBankName,NBranchName,Nifsccode,Naccno,Username,convert(varchar,Datetime,109) as date from agent_masterLogs where plant_code='"+ddl_Plantname.SelectedItem.Value+"') AS LL LEFT JOIN (sELECT Bank_ID,BANK_NAME as BMBANK_NAME FROM BANK_MASTER GROUP BY Bank_ID,BANK_NAME ) AS BM ON LL.BankName=BM.Bank_ID order by tid desc";
}
SqlCommand cmd = new SqlCommand(value, con);
SqlDataAdapter dst = new SqlDataAdapter(cmd);
agentdataviews.Rows.Clear();
dst.Fill(agentdataviews);
if (agentdataviews.Rows.Count > 0)
{
GridView2.DataSource = agentdataviews;
GridView2.DataBind();
}
else
{
GridView2.DataSource = "";
GridView2.DataBind();
}
}
protected void GridView2_RowCreated(object sender, GridViewRowEventArgs e)
{
}
protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void btn_export_Click(object sender, EventArgs e)
{
try
{
Response.Clear();
Response.Buffer = true;
string filename = "' " + DateTime.Now.ToString() + ".xls";
getagentlist();
//Response.AddHeader("content-disposition", "attachment;filename=" + filename);
Response.AddHeader("content-disposition", "attachment; filename= '"+filename+"'");
// Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
using (StringWriter sw = new StringWriter())
{
HtmlTextWriter hw = new HtmlTextWriter(sw);
//To Export all pages
GridView2.AllowPaging = false;
getagentlist();
GridView2.HeaderRow.BackColor = Color.White;
foreach (TableCell cell in GridView2.HeaderRow.Cells)
{
cell.BackColor = GridView2.HeaderStyle.BackColor;
}
foreach (GridViewRow row in GridView2.Rows)
{
row.BackColor = Color.White;
foreach (TableCell cell in row.Cells)
{
if (row.RowIndex % 2 == 0)
{
cell.BackColor = GridView2.AlternatingRowStyle.BackColor;
}
else
{
cell.BackColor = GridView2.RowStyle.BackColor;
}
cell.CssClass = "textmode";
}
}
GridView2.RenderControl(hw);
//style to format numbers to string
string style = @"<style> td { mso-number-format:""" + "\\@" + @"""; }</style>";
// string style = @"<style> .textmode { } </style>";
Response.Write(style);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
}
}
catch (Exception ex)
{
WebMsgBox.Show(ex.ToString());
}
}
public override void VerifyRenderingInServerForm(Control control)
{
/* Verifies that the control is rendered */
}
protected void ddl_Plantname_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (RadioButtonList1.SelectedItem.Value == "1")
{
Panel1.Visible = false;
}
else
{
Panel1.Visible = true;
}
}
}