-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClientesAltas.aspx.cs.exclude
202 lines (172 loc) · 6.79 KB
/
ClientesAltas.aspx.cs.exclude
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Newtonsoft.Json;
using System.Net.Sockets;
using System.Net;
using System.Data;
using System.Text;
using System.IO;
using System.Globalization;
using System.Web.Services;
namespace MasTicket
{
public partial class ClientesAltas : System.Web.UI.Page
{
wsac.IsacClient ws;
TarjetasViewModel tvm;
RecargasViewModel rvm;
protected void Page_PreRender()
{
ClientScript.GetPostBackEventReference(this, string.Empty);
}
protected void Page_Load(object sender, EventArgs e)
{
//--------------------------------------------------------------------------------------------------
int idusr = 0;
if (!IsPostBack)
{
if (Session["idadminlogged"] != null)
{
if (int.TryParse(Session["idadminlogged"].ToString(), out idusr))
{
if (idusr > 0)
{
ws = Session["wsac"] as wsac.IsacClient;
string json = ws.GetAdmin(idusr, "", "");
List<Usuario> lu = JsonConvert.DeserializeObject<List<Usuario>>(json);
if (lu.Count > 0)
{
Session["adminlogged"] = lu.FirstOrDefault();
}
else
Response.Redirect("index.aspx");
}
else
Response.Redirect("index.aspx");
}
else
Response.Redirect("index.aspx");
}
}
else
{
if (Request["__EVENTTARGET"] == "lnkSalir")
{
Session["idadminlogged"] = 0;
Session["adminlogged"] = null;
Response.Redirect("index.aspx");
Session.Abandon();
Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));
}
}
//-------------------------------------------------------------------------------------------------
if (!IsPostBack)
{
ws = Session["wsac"] as wsac.IsacClient;
if (tvm == null)
{
tvm = new TarjetasViewModel();
Session["tvm"] = tvm;
}
tvm.WS = ws;
tvm.Inicia();
}
/* btnConsultar.Click += (s, ea) =>
{
Refresh();
spnJS.Text = "";
};*/
btnExcel.Click += (s, ea) =>
{
DumpExcel();
spnJS.Text = "";
};
}
private void DumpExcel()
{
ws = Session["wsac"] as wsac.IsacClient;
byte[] reporte = ws.ExportaRepUsr();
string saveAsFileName = "RepUsrs.xls";
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", saveAsFileName));
Response.Clear();
Response.BinaryWrite(reporte);
Response.End();
}
private static string obtieneD() {
wsac.IsacClient ws = HttpContext.Current.Session["wsac"] as wsac.IsacClient;
// ws = Session["wsac"] as wsac.IsacClient;
string json = ws.GetAClientes();
return json;
}
[WebMethod]
public static List<object> RefreshC()
{
List<object> iData = new List<object>();
//altas y ventas semanales
List<string> labelsDiario = new List<string>();
List<string> labelsSem = new List<string>();
List<string> labelsMensual = new List<string>();
List<int> lst_dataSemanalAltas = new List<int>();
List<double> lst_dataSemanalVentas = new List<double>();
List<int> lst_dataMensualAltas = new List<int>();
List<double> lst_dataMensualVentas = new List<double>();
List<int> lst_dataDiarioAltas = new List<int>();
List<double> lst_dataDiarioVentas = new List<double>();
string json = obtieneD();
List<AClientes> lsu = JsonConvert.DeserializeObject<List<AClientes>>(json);
CultureInfo ci = new CultureInfo("es-MX");
foreach (AClientes u in lsu)
{
labelsSem.Add(u.semana.ToString() + "_" + u.anio.ToString());
lst_dataSemanalAltas.Add(Convert.ToInt32(u.altas.ToString()));
lst_dataSemanalVentas.Add(Convert.ToDouble(u.ventasM.ToString()));
}
// altas y ventas mensuales
wsac.IsacClient ws = HttpContext.Current.Session["wsac"] as wsac.IsacClient;
//altas mensuales=1 ventas mensuales=2
json = ws.GetMesDatos(1);
List<DatosMes> lsu2 = JsonConvert.DeserializeObject<List<DatosMes>>(json);
foreach (DatosMes u in lsu2)
{
labelsMensual.Add(u.mes.ToString() + "_" + u.anio.ToString());
lst_dataMensualAltas.Add(Convert.ToInt32(u.num.ToString()));
}
json = ws.GetMesDatos(2);
lsu2 = JsonConvert.DeserializeObject<List<DatosMes>>(json);
foreach (DatosMes u in lsu2)
{
lst_dataMensualVentas.Add(Convert.ToDouble(u.num.ToString()));
}
// altas y ventas diarias
json = ws.GetDiaDatos(1);
List<DatosDias> lsu3 = JsonConvert.DeserializeObject<List<DatosDias>>(json);
foreach (DatosDias u in lsu3)
{
labelsMensual.Add(u.dia.ToString());
lst_dataDiarioAltas.Add(Convert.ToInt32(u.num.ToString()));
}
json = ws.GetDiaDatos(2);
lsu3 = JsonConvert.DeserializeObject<List<DatosDias>>(json);
foreach (DatosDias u in lsu3)
{
lst_dataDiarioVentas.Add(Convert.ToDouble(u.num.ToString()));
}
iData.Add(labelsDiario);
iData.Add(labelsSem);
iData.Add(labelsMensual);
iData.Add(lst_dataSemanalAltas);
iData.Add(lst_dataSemanalVentas);
iData.Add(lst_dataMensualAltas);
iData.Add(lst_dataMensualVentas);
iData.Add(lst_dataDiarioAltas);
iData.Add(lst_dataDiarioVentas);
return iData;
}
}
}