-
Notifications
You must be signed in to change notification settings - Fork 0
/
Facturas.aspx.cs
161 lines (143 loc) · 5.92 KB
/
Facturas.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
using DevExpress.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Facturas : BasePage
{
DateTime fechahoy = CommonFunction.fechaserver();
protected void Page_Load(object sender, EventArgs e)
{
if (Session["User"] == null)
{
if (Page.IsCallback)
{
ASPxWebControl.RedirectOnCallback("/Account/login.aspx");
}
else
{
Response.Redirect("/Account/login.aspx");
}
}
// if (Request.Browser.IsMobileDevice)
// {
// if (Page.IsCallback)
// {
// ASPxWebControl.RedirectOnCallback("/mobile/Facturas.aspx");
// }
// else
// {
// Response.Redirect("/mobile/Facturas.aspx");
// }
// }
DateTime? defecha = null;
DateTime? afecha = null;
if (!Page.IsPostBack)
{
Session["buttonclick"] = "date";
defecha = Convert.ToDateTime(fechahoy.ToString("01/MMM/yyy"));
afecha = Convert.ToDateTime(DateTime.DaysInMonth(fechahoy.Year, fechahoy.Month) + "/" + fechahoy.Month + "/" + fechahoy.Year);
}
if ((dtfromDate.Date != null || dttoDate.Date != null) && Convert.ToString(Session["buttonclick"]) == "date")
{
defecha = dtfromDate.Date;
afecha = dttoDate.Date;
}
var Cliente = (Clientes)Session["User"];
GridViewFacturas.DataSource = FacturasRepository.GetAllFacturas("", Cliente.AutoCliente, defecha, afecha);
GridViewFacturas.DataBind();
string SerieFactura = string.Empty;
if (GridViewFacturas.GetSelectedFieldValues("SerieFactura").Count > 0)
{
SerieFactura = Convert.ToString(GridViewFacturas.GetSelectedFieldValues("SerieFactura").Select(c => c).FirstOrDefault());
}
else
{
SerieFactura = Convert.ToString(GridViewFacturas.GetRowValues(0, "SerieFactura"));
}
GridViewFacturasDetail.DataSource = FacturasRepository.GetFacturasDetail(SerieFactura);
GridViewFacturasDetail.DataBind();
}
protected void GridViewFacturas_CustomCallback(object sender, DevExpress.Web.ASPxGridViewCustomCallbackEventArgs e)
{
var Cliente = (Clientes)Session["User"];
if (Cliente == null)
{
if (Page.IsCallback)
{
ASPxWebControl.RedirectOnCallback("/Account/login.aspx");
}
else
{
Response.Redirect("/Account/login.aspx");
}
}
if (e.Parameters.Contains("searchalbaran"))
{
Session["buttonclick"] = "searchalbaran";
GridViewFacturas.DataSource = FacturasRepository.GetAllFacturas("", Cliente.AutoCliente, null, null);
}
else if (e.Parameters.Contains("searchfectura"))
{
Session["buttonclick"] = "searchfectura";
GridViewFacturas.DataSource = FacturasRepository.GetAllFacturas(searchfectura.Text, Cliente.AutoCliente, null, null);
}
else if (e.Parameters.Contains("date"))
{
Session["buttonclick"] = "date";
GridViewFacturas.DataSource = FacturasRepository.GetAllFacturas("", Cliente.AutoCliente, dtfromDate.Date, dttoDate.Date);
}
else
{
Session["buttonclick"] = "showall";
GridViewFacturas.DataSource = FacturasRepository.GetAllFacturas("", Cliente.AutoCliente, null, null);
}
GridViewFacturas.DataBind();
}
protected void GridViewFacturasDetail_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridViewColumnDataEventArgs e)
{
var Cliente = (Clientes)Session["User"];
if (Cliente == null)
{
ASPxWebControl.RedirectOnCallback("/Account/login.aspx");
}
string CodigoCliente = Cliente.Código;
int AutoCliente = Cliente.AutoCliente;
int AutoArticulo = Convert.ToInt32(e.GetListSourceFieldValue("AutoArtículo"));
string resp = (string)CommonFunction.Calculoalbaran(Convert.ToString(GridViewFacturasDetail.GetRowValues(e.ListSourceRowIndex, "SerieAlbaran")), 5);
if (e.Column.FieldName == "TotalNeto")
{
var val = CommonFunction.Field(resp, 1, "&");
if (!string.IsNullOrEmpty(val))
e.Value = Convert.ToDouble(CommonFunction.Field(resp, 1, "&"));
}
else if (e.Column.FieldName == "NetoIgic")
{
var val = CommonFunction.Field(resp, 2, "&");
if (!string.IsNullOrEmpty(val))
e.Value = Convert.ToDouble(CommonFunction.Field(resp, 2, "&"));
}
}
protected void GridViewFacturas_SelectionChanged(object sender, EventArgs e)
{
string SerieFactura = Convert.ToString(GridViewFacturas.GetSelectedFieldValues("SerieFactura").Select(c => c).FirstOrDefault());
GridViewFacturasDetail.DataSource = FacturasRepository.GetFacturasDetail(SerieFactura);
GridViewFacturasDetail.DataBind();
}
protected void dttoDate_Init(object sender, EventArgs e)
{
dttoDate.Date = Convert.ToDateTime(DateTime.DaysInMonth(fechahoy.Year, fechahoy.Month) + "/" + fechahoy.Month + "/" + fechahoy.Year);
}
protected void dtfromDate_Init(object sender, EventArgs e)
{
dtfromDate.Date = Convert.ToDateTime(fechahoy.ToString("01/MMM/yyy"));
}
protected void GridViewFacturasDetail_CustomCallback(object sender, DevExpress.Web.ASPxGridViewCustomCallbackEventArgs e)
{
string SerieFactura = Convert.ToString(GridViewFacturas.GetSelectedFieldValues("SerieFactura").Select(c => c).FirstOrDefault());
GridViewFacturasDetail.DataSource = FacturasRepository.GetFacturasDetail(SerieFactura);
GridViewFacturasDetail.DataBind();
}
}