001.
public
void
GetData(
string
str)
002.
{
003.
004.
textBox1.Text = str;
005.
}
006.
007.
private
void
FormReport6_Load(
object
sender, EventArgs e)
008.
{
009.
010.
string
[] pb = textBox1.Text.Split((
" "
).ToCharArray());
011.
textBox2.Text = pb[0];
012.
textBox3.Text = pb[1];
013.
textBox10.Text = textBox2.Text +
"-"
+ textBox3.Text;
014.
015.
CrystalDecisions.Shared.ParameterFields pfields =
new
CrystalDecisions.Shared.ParameterFields();
016.
CrystalDecisions.Shared.ParameterField pfield =
new
CrystalDecisions.Shared.ParameterField();
017.
CrystalDecisions.Shared.ParameterDiscreteValue disvalue =
new
CrystalDecisions.Shared.ParameterDiscreteValue();
018.
019.
string
[] pp = textBox10.Text.Split((
"-"
).ToCharArray());
020.
string
dayer = pp[2];
021.
string
MonthPart = pp[1];
022.
string
pre = pp[0];
023.
string
day2 = pp[5];
024.
string
mon = pp[4],mmo=
""
;
025.
string
pre2 = pp[3],mont=
""
;
026.
027.
if
(MonthPart ==
"1"
)
028.
{
029.
mont =
"มกราคม"
;
030.
}
031.
else
if
(MonthPart ==
"2"
)
032.
{
033.
mont =
"กุมภาพันธ์"
;
034.
}
035.
else
if
(MonthPart ==
"3"
)
036.
{
037.
mont =
"มีนาคม"
;
038.
}
039.
else
if
(MonthPart ==
"4"
)
040.
{
041.
mont =
"เมษายน"
;
042.
}
043.
else
if
(MonthPart ==
"5"
)
044.
{
045.
mont =
"พฤษภาคม"
;
046.
}
047.
else
if
(MonthPart ==
"6"
)
048.
{
049.
mont =
"มิถุนายน"
;
050.
}
051.
else
if
(MonthPart ==
"7"
)
052.
{
053.
mont =
"กรกฎาคม"
;
054.
}
055.
else
if
(MonthPart ==
"8"
)
056.
{
057.
mont =
"สิงหาคม"
;
058.
}
059.
else
if
(MonthPart ==
"9"
)
060.
{
061.
mont =
"กันยายน"
;
062.
}
063.
else
if
(MonthPart ==
"10"
)
064.
{
065.
066.
mont =
"ตุลาคม"
;
067.
}
068.
else
if
(MonthPart ==
"11"
)
069.
{
070.
mont =
"พฤศจิกายน"
;
071.
}
072.
else
if
(MonthPart ==
"12"
)
073.
{
074.
mont =
"ธันวาคม"
;
075.
}
076.
else
077.
{
078.
079.
}
080.
081.
082.
if
(mon ==
"1"
)
083.
{
084.
mmo =
"มกราคม"
;
085.
}
086.
else
if
(mon ==
"2"
)
087.
{
088.
mmo =
"กุมภาพันธ์"
;
089.
}
090.
else
if
(mon ==
"3"
)
091.
{
092.
mmo =
"มีนาคม"
;
093.
}
094.
else
if
(mon ==
"4"
)
095.
{
096.
mmo =
"เมษายน"
;
097.
}
098.
else
if
(mon ==
"5"
)
099.
{
100.
mmo =
"พฤษภาคม"
;
101.
}
102.
else
if
(mon ==
"6"
)
103.
{
104.
mmo =
"มิถุนายน"
;
105.
}
106.
else
if
(mon ==
"7"
)
107.
{
108.
mmo =
"กรกฎาคม"
;
109.
}
110.
else
if
(mon ==
"8"
)
111.
{
112.
mmo =
"สิงหาคม"
;
113.
}
114.
else
if
(mon ==
"9"
)
115.
{
116.
mmo =
"กันยายน"
;
117.
}
118.
else
if
(mon ==
"10"
)
119.
{
120.
121.
mmo =
"ตุลาคม"
;
122.
}
123.
else
if
(MonthPart ==
"11"
)
124.
{
125.
mmo =
"พฤศจิกายน"
;
126.
}
127.
else
if
(MonthPart ==
"12"
)
128.
{
129.
mmo =
"ธันวาคม"
;
130.
}
131.
else
132.
{
133.
134.
}
135.
136.
137.
138.
textBox11.Text = dayer +
" "
+ mont +
" "
+ pre;
139.
textBox4.Text = day2 +
" "
+ mmo +
" "
+ pre2;
140.
141.
142.
SqlConnection cnn;
143.
string
connectionString =
null
;
144.
string
sql =
null
;
145.
146.
connectionString =
"Data Source =.\\SqlExpress;Initial Catalog=datatest;Integrated Security=true"
;
147.
cnn =
new
SqlConnection(connectionString);
148.
cnn.Open();
149.
sql =
"SELECT*FROM datapeople where daterecord between '"
+ textBox2.Text +
"' and '"
+ textBox3.Text +
"'"
;
150.
SqlDataAdapter dscmd =
new
SqlDataAdapter(sql, cnn);
151.
DataSet ds =
new
DataSet();
152.
dscmd.Fill(ds,
"PC"
);
153.
154.
cnn.Close();
155.
156.
CrystalReport7 objRpt =
new
CrystalReport7();
157.
objRpt.SetDataSource(ds.Tables[
"PC"
]);
158.
159.
disvalue.Value = textBox11.Text+
" "
+textBox4.Text;
160.
pfield.Name =
"dte"
;
161.
pfield.CurrentValues.Add(disvalue);
162.
pfields.Add(pfield);
163.
crystalReportViewer1.ParameterFieldInfo = pfields;
164.
165.
crystalReportViewer1.ReportSource = objRpt;
166.
crystalReportViewer1.Refresh();
167.
168.
169.
}