首页上一页 1 下一页尾页 1 条记录 1/1页
C#开发实战宝典
发表在C#图书答疑
2010-12-19
是否精华
是
否
版块置顶:
是
否
你好,《C#开发实战宝典》第29章企业人事管理系统,关于在指定日期内查询员工合同,这个功能你们没有做啊,系统只有设置多少天提示合同日期,但没有显示合同提示啊!
另外我有个语句不明白什么意思,就是在员工合同查询的那段代码,我把它贴上来:
#region 查询指定范围内生日与合同到期的职工
/// <summary>
/// 查询指定范围内生日与合同到期的职工.
/// </summary>
/// <param name="i">标识,判断查询的是生日,还是合同</param>
public void PactDay(int i)
{
DataSet DSet = MyDataClass.getDataSet("select * from tb_Clew where kind=" + i + " and unlock=1", "tb_clew");
if (DSet.Tables[0].Rows.Count > 0)
{
string Vfield = "";
string dSQL = "";
int sday = Convert.ToInt32(DSet.Tables[0].Rows[0][1]);
if (i == 1)
{
Vfield = "Birthday";
dSQL = "select * from tb_Stuffbusic where (datediff(day,getdate(),convert(Nvarchar(12),cast (cast (year(getdate()) as char(4))+'-'+ cast(month(" + Vfield + ") as char(2))+'-'+ cast (day(" + Vfield + ") as char(2)) as datetime),110))<=" + sday + ") and (datediff(day,getdate(),convert(Nvarchar(12),cast (cast (year(getdate()) as char(4))+'-'+ cast(month(" + Vfield + ") as char(2))+'-'+cast (day(" + Vfield + ") as char(2)) as datetime),110))>=0)";
}
else
{
Vfield = "Pact_E";
dSQL = "select * from tb_Stuffbusic where ((getdate()-convert(Nvarchar(12)," + Vfield + ",110))>=-" + sday + " and (getdate()-convert(Nvarchar(12)," + Vfield + ",110))<=0)";
}
DSet = MyDataClass.getDataSet(dSQL, "tb_Stuffbusic");
if (DSet.Tables[0].Rows.Count > 0)
{
if (i == 1)
Vfield = "是否查看" + sday.ToString() + "天内过生日的职工信息?";
else
Vfield = "是否查看" + sday.ToString() + "天内合同到期的职工信息?";
if (MessageBox.Show(Vfield, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
{
DataClass.MyMeans.AllSql = dSQL;
Show_Form("人事档案浏览", 1);
}
}
}
}
#endregion
这段SQL语句表示什么意思:dSQL = "select * from tb_Stuffbusic where (datediff(day,getdate(),convert(Nvarchar(12),cast (cast (year(getdate()) as char(4))+'-'+ cast(month(" + Vfield + ") as char(2))+'-'+ cast (day(" + Vfield + ") as char(2)) as datetime),110))<=" + sday + ") and (datediff(day,getdate(),convert(Nvarchar(12),cast (cast (year(getdate()) as char(4))+'-'+ cast(month(" + Vfield + ") as char(2))+'-'+cast (day(" + Vfield + ") as char(2)) as datetime),110))>=0)";
where条件筛选的用的什么 where里面的这个datediff表示什么?
明日读者,谢谢!
另外我有个语句不明白什么意思,就是在员工合同查询的那段代码,我把它贴上来:
#region 查询指定范围内生日与合同到期的职工
/// <summary>
/// 查询指定范围内生日与合同到期的职工.
/// </summary>
/// <param name="i">标识,判断查询的是生日,还是合同</param>
public void PactDay(int i)
{
DataSet DSet = MyDataClass.getDataSet("select * from tb_Clew where kind=" + i + " and unlock=1", "tb_clew");
if (DSet.Tables[0].Rows.Count > 0)
{
string Vfield = "";
string dSQL = "";
int sday = Convert.ToInt32(DSet.Tables[0].Rows[0][1]);
if (i == 1)
{
Vfield = "Birthday";
dSQL = "select * from tb_Stuffbusic where (datediff(day,getdate(),convert(Nvarchar(12),cast (cast (year(getdate()) as char(4))+'-'+ cast(month(" + Vfield + ") as char(2))+'-'+ cast (day(" + Vfield + ") as char(2)) as datetime),110))<=" + sday + ") and (datediff(day,getdate(),convert(Nvarchar(12),cast (cast (year(getdate()) as char(4))+'-'+ cast(month(" + Vfield + ") as char(2))+'-'+cast (day(" + Vfield + ") as char(2)) as datetime),110))>=0)";
}
else
{
Vfield = "Pact_E";
dSQL = "select * from tb_Stuffbusic where ((getdate()-convert(Nvarchar(12)," + Vfield + ",110))>=-" + sday + " and (getdate()-convert(Nvarchar(12)," + Vfield + ",110))<=0)";
}
DSet = MyDataClass.getDataSet(dSQL, "tb_Stuffbusic");
if (DSet.Tables[0].Rows.Count > 0)
{
if (i == 1)
Vfield = "是否查看" + sday.ToString() + "天内过生日的职工信息?";
else
Vfield = "是否查看" + sday.ToString() + "天内合同到期的职工信息?";
if (MessageBox.Show(Vfield, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
{
DataClass.MyMeans.AllSql = dSQL;
Show_Form("人事档案浏览", 1);
}
}
}
}
#endregion
这段SQL语句表示什么意思:dSQL = "select * from tb_Stuffbusic where (datediff(day,getdate(),convert(Nvarchar(12),cast (cast (year(getdate()) as char(4))+'-'+ cast(month(" + Vfield + ") as char(2))+'-'+ cast (day(" + Vfield + ") as char(2)) as datetime),110))<=" + sday + ") and (datediff(day,getdate(),convert(Nvarchar(12),cast (cast (year(getdate()) as char(4))+'-'+ cast(month(" + Vfield + ") as char(2))+'-'+cast (day(" + Vfield + ") as char(2)) as datetime),110))>=0)";
where条件筛选的用的什么 where里面的这个datediff表示什么?
明日读者,谢谢!