首页上一页 1 下一页尾页 5 条记录 1/1页
C#开发典型模块大全中,桌面精灵模块,我改成sql数据库,运行出错,请老师看下是什么问题呀?
发表在C#图书答疑
2010-09-11
是否精华
是
否
版块置顶:
是
否
//以下写在主窗体中,
private void frm_main_Load(object sender, EventArgs e)
{
timer2.Start();
}
//日程提醒,弹出窗口。
private void timer2_Tick(object sender, EventArgs e)
{
DataSet myds = dbOp.getDataSet("select * from tb_remind ", "tb_remind");
for (int i = 0; i < myds.Tables[0].Rows.Count; i++)
{
string strName = myds.Tables[0].Rows[i][0].ToString();
string strFrequency = myds.Tables[0].Rows[i][1].ToString();
string strTime = myds.Tables[0].Rows[i][2].ToString();
string strContent = myds.Tables[0].Rows[i][3].ToString();
string[] strTimes = strTime.Split(' ');
//判断提醒方式,并根据提醒方式弹出提醒对话框
if (strFrequency == "仅仅一次")
{
if (DateTime.Now.ToShortDateString() == strTimes[0].ToString() && DateTime.Now.ToLongTimeString() == strTimes[1].ToString())
{
MessageBox.Show(strContent, strName, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
//int intNum = Convert.ToInt32(strFrequency.Substring(0, 1)); [font color=#FF0000] //注释掉这些就没出错,确定这段有问题。[/font]
//string strUnit = strFrequency.Substring(1, 1);
//TimeSpan TSpan = DateTime.Now - Convert.ToDateTime(strTimes[0]);
//switch (strUnit)
//{
// case "天"://每几天提醒一次
// if (TSpan.Days % intNum == 0 && DateTime.Now.ToLongTimeString() == strTimes[1].ToString())
// MessageBox.Show(strContent, strName, MessageBoxButtons.OK, MessageBoxIcon.Information);
// break;
// case "周"://每几周提醒一次
// if (TSpan.Days % (intNum * 7) == 0 && DateTime.Now.ToLongTimeString() == strTimes[1].ToString())
// MessageBox.Show(strContent, strName, MessageBoxButtons.OK, MessageBoxIcon.Information);
// break;
// case "月"://每几月提醒一次
// if (TSpan.Days % (intNum * 30) == 0 && DateTime.Now.ToLongTimeString() == strTimes[1].ToString())
// MessageBox.Show(strContent, strName, MessageBoxButtons.OK, MessageBoxIcon.Information);
// break;
// case "年"://每几年提醒一次
// if (TSpan.Days % (intNum * 365) == 0 && DateTime.Now.ToLongTimeString() == strTimes[1].ToString())
// MessageBox.Show(strContent, strName, MessageBoxButtons.OK, MessageBoxIcon.Information);
// break;
//}
}
}
}
//以下是数据库
_name char
_frequency nchar
_time nchar 数据格式为 2008-06-18 0:00:00
_content nchar
_isGq char
private void frm_main_Load(object sender, EventArgs e)
{
timer2.Start();
}
//日程提醒,弹出窗口。
private void timer2_Tick(object sender, EventArgs e)
{
DataSet myds = dbOp.getDataSet("select * from tb_remind ", "tb_remind");
for (int i = 0; i < myds.Tables[0].Rows.Count; i++)
{
string strName = myds.Tables[0].Rows[i][0].ToString();
string strFrequency = myds.Tables[0].Rows[i][1].ToString();
string strTime = myds.Tables[0].Rows[i][2].ToString();
string strContent = myds.Tables[0].Rows[i][3].ToString();
string[] strTimes = strTime.Split(' ');
//判断提醒方式,并根据提醒方式弹出提醒对话框
if (strFrequency == "仅仅一次")
{
if (DateTime.Now.ToShortDateString() == strTimes[0].ToString() && DateTime.Now.ToLongTimeString() == strTimes[1].ToString())
{
MessageBox.Show(strContent, strName, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
//int intNum = Convert.ToInt32(strFrequency.Substring(0, 1)); [font color=#FF0000] //注释掉这些就没出错,确定这段有问题。[/font]
//string strUnit = strFrequency.Substring(1, 1);
//TimeSpan TSpan = DateTime.Now - Convert.ToDateTime(strTimes[0]);
//switch (strUnit)
//{
// case "天"://每几天提醒一次
// if (TSpan.Days % intNum == 0 && DateTime.Now.ToLongTimeString() == strTimes[1].ToString())
// MessageBox.Show(strContent, strName, MessageBoxButtons.OK, MessageBoxIcon.Information);
// break;
// case "周"://每几周提醒一次
// if (TSpan.Days % (intNum * 7) == 0 && DateTime.Now.ToLongTimeString() == strTimes[1].ToString())
// MessageBox.Show(strContent, strName, MessageBoxButtons.OK, MessageBoxIcon.Information);
// break;
// case "月"://每几月提醒一次
// if (TSpan.Days % (intNum * 30) == 0 && DateTime.Now.ToLongTimeString() == strTimes[1].ToString())
// MessageBox.Show(strContent, strName, MessageBoxButtons.OK, MessageBoxIcon.Information);
// break;
// case "年"://每几年提醒一次
// if (TSpan.Days % (intNum * 365) == 0 && DateTime.Now.ToLongTimeString() == strTimes[1].ToString())
// MessageBox.Show(strContent, strName, MessageBoxButtons.OK, MessageBoxIcon.Information);
// break;
//}
}
}
}
//以下是数据库
_name char
_frequency nchar
_time nchar 数据格式为 2008-06-18 0:00:00
_content nchar
_isGq char