private void button1_Click(object sender
, EventArgs e
)
{
try
{
com
= comNames
.Text
.Trim();
XlName
= ComUserName
.Text
.Trim();
comUsers
= comUser
.Text
.Trim();
TxtUlogsS
= TxtUlogs
.Text
.Trim();
comDs
= ComDKQ
.Text
.Trim();
SQbase
.ReplaceSQLChar(com
);
SQbase
.ReplaceSQLChar(XlName
);
SQbase
.ReplaceSQLChar(comUsers
);
SQbase
.ReplaceSQLChar(TxtUlogsS
);
SQbase
.ReplaceSQLChar(Comlogs
.Text
.Trim());
if (grid
== 1)
{
da1
= DateTime
.Parse(dpic1
.Value
.ToString(dati
));
da2
= DateTime
.Parse(dpic2
.Value
.ToString(datis
));
if (da1
>= da2
)
{
MessageBox
.Show("开始时间必须小于结束时间", "提示");
}
else
{
string sql
= string.Format(" where 1=1");
if (com
== "全部")
{
sql
+= string.Format(@"");
}
else
{
sql
+= string.Format(@" and holderName='" + com
+ "'");
}
if (comDs
== "全部")
{
sql
+= string.Format(@"");
}
else
{
sql
+= string.Format(@" and Name='" + comDs
+ "'");
}
if (CKBox
.Checked
!= true)
{
sql
+= string.Format(@" and '" + da2
.ToString() + "'>= g.[OPtime] and g.[OPtime] >='" + da1
.ToString() + "'");
}
else
{
sql
+= string.Format(@"");
}
sql
+= " ORDER BY g.[OPtime] DESC ";
DataGdv
.DataSource
= SKJLS
.Cardlogs_Getdate(sql
);
SQbase
.Roswtxt(DataGdv
, RoswSTxt
);
}
}
if (grid
== 2)
{
da1
= DateTime
.Parse(dpic1
.Value
.ToString(dati
));
da2
= DateTime
.Parse(dpic2
.Value
.ToString(datis
));
if (da1
>= da2
)
{
MessageBox
.Show("开始时间必须小于结束时间", "提示");
}
else
{
string sql
= string.Format(" where 1=1");
if (comUsers
== "全部")
{
sql
+= string.Format(@"");
}
else
{
sql
+= string.Format(@"and ul.[Name] = '" + comUsers
+ "'");
}
if (!string.IsNullOrEmpty(TxtUlogsS
))
{
if (TxtUlogsS
== "全部")
{
sql
+= string.Format(@" and [oEvent] like '%%'");
}
else
{
sql
+= string.Format(@" and [oEvent] like '%" + TxtUlogsS
+ "%'");
}
}
if (!string.IsNullOrEmpty(Comlogs
.Text
.Trim()))
{
if (Comlogs
.Text
.Trim() == "全部")
{
sql
+= string.Format(@"");
}
else
{
sql
+= string.Format(@" and [EventType] like '%" + Comlogs
.Text
.Trim().ToString() + "%'");
}
}
if (CKBox
.Checked
!= true)
{
sql
+= string.Format(@" and ('" + da2
.ToString() + "'>OPtime and OPtime>'" + da1
.ToString() + "')");
}
else
{
sql
+= string.Format(@"");
}
sql
+= " order by [OPtime] desc";
DataGdv
.DataSource
= YHCZJLS
.Userlogs_Getdate(sql
);
SQbase
.Roswtxt(DataGdv
, RoswSTxt
);
}
}
if (grid
== 3)
{
da1
= DateTime
.Parse(dpic1
.Value
.ToString(dati
));
da2
= DateTime
.Parse(dpic2
.Value
.ToString(datis
));
if (da1
>= da2
)
{
MessageBox
.Show("开始时间必须小于结束时间", "提示");
}
else
{
string sql
= "where 1=1";
if (!string.IsNullOrEmpty(XlName
))
{
if (XlName
== "全部")
{
sql
+= string.Format(@"");
}
else
{
sql
+= string.Format(@" and [Name]='" + XlName
+ "'");
}
}
if (!string.IsNullOrEmpty(com
))
{
if (com
== "全部")
{
sql
+= string.Format(@"");
}
else
{
sql
+= string.Format(@" and holderName='" + com
+ "'");
}
}
if (CKBox
.Checked
!= true)
{
sql
+= string.Format(@" and '" + da2
.ToString() + "'>=OPtime and OPtime >='" + da1
.ToString() + "'");
}
else
{
sql
+= string.Format(@"");
}
sql
+= string.Format(@" order by [OPtime] desc ");
DataGdv
.DataSource
= XGJLS
.Routelogs_getdate(sql
);
SQbase
.Roswtxt(DataGdv
, RoswSTxt
);
}
}
if (grid
== 4)
{
da1
= DateTime
.Parse(dpic1
.Value
.ToString(dati
));
da2
= DateTime
.Parse(dpic2
.Value
.ToString(datis
));
if (da1
>= da2
)
{
MessageBox
.Show("开始时间必须小于结束时间", "提示");
}
else
{
string sql
= "";
if (!string.IsNullOrEmpty(XlName
))
{
if (XlName
== "全部")
{
sql
+= string.Format(@"");
}
else
{
sql
+= string.Format(@" and [Name]='" + XlName
+ "'");
}
}
if (!string.IsNullOrEmpty(com
))
{
if (com
== "全部")
{
sql
+= string.Format(@"");
}
else
{
sql
+= string.Format(@" and [holderName]='" + com
+ "'");
}
}
if (CKBox
.Checked
!= true)
{
sql
+= string.Format(@" and '" + da2
.ToString() + "'>=OPtime and OPtime >='" + da1
.ToString() + "'");
}
else
{
sql
+= string.Format(@"");
}
sql
+= string.Format(@" order by [RouteLogID],[order]");
XGXxShowS(DataGdv
, sql
);
SQbase
.Roswtxt(DataGdv
, RoswSTxt
);
}
}
if (grid
== 5)
{
da1
= DateTime
.Parse(dpic1
.Value
.ToString(dati
));
da2
= DateTime
.Parse(dpic2
.Value
.ToString(datis
));
if (da1
>= da2
)
{
MessageBox
.Show("开始时间必须小于结束时间", "提示");
}
else
{
string sql
= " where [order]=1";
if (!string.IsNullOrEmpty(XlName
))
{
if (XlName
== "全部")
{
sql
+= string.Format(@"");
}
else
{
sql
+= string.Format(@" and t.[Name] ='" + XlName
+ "'");
}
}
if (!string.IsNullOrEmpty(com
))
{
if (com
== "全部")
{
sql
+= string.Format(@"");
}
else
{
sql
+= string.Format(@" and [holderName]='" + com
+ "'");
}
}
if (CKBox
.Checked
!= true)
{
sql
+= string.Format(@" and '" + da2
.ToString() + "'> NextActioT and NextActioT>'" + da1
.ToString() + "'");
}
else
{
sql
+= string.Format(@"");
}
sql
+= string.Format(@" order by Startuptime,e.[RouteID],[Order] ");
XLXGS(DataGdv
, sql
);
if (!string.IsNullOrEmpty(XlName
) && XlName
!= "全部")
{
DataTable dtco
= new DataTable();
dtco
= bl
.countS(XlName
);
foreach (DataRow dr
in dtco
.Rows
)
{
if (dr
[0].ToString() != "0")
{
DataGdv
.Rows
[0].Cells
[4].Value
= dr
[0].ToString();
}
else
{
RoswSTxt
.Text
= "";
}
}
}
SQbase
.Roswtxt(DataGdv
, RoswSTxt
);
}
}
}
catch (Exception ex
)
{
MessageBox
.Show(ex
.ToString());
}
}
转载请注明原文地址: https://mac.8miu.com/read-500263.html