01.
private
void
get3month()
02.
{
03.
string
strd, strd1, strd2, strd3, strm, stry, strdt;
04.
strd1 =
"/31/"
;
05.
strd2 =
"/30/"
;
06.
strd3 =
"/29/"
;
07.
strd = cb_date.EditValue.ToString().Substring(3, 2);
08.
strm = cb_date.EditValue.ToString().Substring(0, 2);
09.
stry = cb_date.EditValue.ToString().Substring(6, 4);
10.
if
(ตรงนี้ผมไม่รู้จะใส่อะไรดี....ใส่แล้วก็ ERROR)
11.
{
12.
strdt = strm + strd + stry;
13.
txtdate.EditValue = strdt;
14.
}
15.
DT = (Convert.ToInt32(StrMount) - Mount);
16.
if
((DT < 0))
17.
{
18.
DT = 0;
19.
DT = (Mount - Convert.ToInt32(StrMount));
20.
Str3 = cbdate_str.Text.Substring(6, 4);
21.
DT2 = (12 - DT);
22.
DT3 = (Convert.ToInt32(Str3) - 1);
23.
X = DT2.ToString().Length;
24.
if
((X == 1))
25.
{
26.
Dateback = (
"0"
+ DT2.ToString());
27.
Str2 = (Dateback
28.
+ (cbdate_str.Text.Substring(2, 4) + DT3.ToString()));
29.
}
30.
else
31.
{
32.
Str2 = (DT2.ToString()
33.
+ (cbdate_str.Text.Substring(2, 4) + DT3.ToString()));
34.
}
35.
MessageBox.Show(Str2);
36.
dsca = ojsql2.GetDataSet(
"select month(ddate) dmonth,sum(iquantity) qty,sum(isum )amt from salebillvouch a inner join salebillvouchs b on a.sbvid=b.sbvid where cinvcode='"
+ txtpd_code.Text +
"' and ddate>='"
+ cbdate_str.EditValue +
"' and ddate<='"
+ Str2 +
"' group by month(ddate)"
,
"data"
);
37.
gvFile.DataSource = dsca.Tables[0];
38.
39.
}
40.
else
41.
{
42.
Str3 = cbdate_str.Text.Substring(6, 4);
43.
DT3 = (Convert.ToInt32(Str3) - 1);
44.
X = DT.ToString().Length;
45.
if
((X == 1))
46.
{
47.
Dateback = (
"0"
+ DT.ToString());
48.
if
((Dateback ==
"00"
))
49.
{
50.
Str2 = (
"12"
51.
+ (cbdate_str.Text.Substring(2, 4) + DT3.ToString()));
52.
}
53.
else
54.
{
55.
Str2 = (Dateback
56.
+ (cbdate_str.Text.Substring(2, 3) + cbdate_str.Text.Substring(5, 5)));
57.
}
58.
}
59.
else
if
((DT.ToString() ==
"00"
))
60.
{
61.
Str2 = (
"12"
62.
+ (cbdate_str.Text.Substring(2, 4) + DT3.ToString()));
63.
}
64.
else
65.
{
66.
Str2 = (DT.ToString()
67.
+ (cbdate_str.Text.Substring(2, 3) + cbdate_str.Text.Substring(5, 5)));
68.
}
69.
MessageBox.Show(Str2);
70.
dsca = ojsql2.GetDataSet(
"select month(ddate) dmonth,sum(iquantity) qty,sum(isum )amt from salebillvouch a inner join salebillvouchs b on a.sbvid=b.sbvid where cinvcode='"
+ txtpd_code.Text +
"' and ddate>='"
+ Str2 +
"' and ddate<='"
+ cbdate_str.EditValue +
"' group by month(ddate)"
,
"data"
);
71.
gvFile.DataSource = dsca.Tables[0];
72.
}
73.
}