您能帮我解决我的问题吗?我正在使用SQL Server数据库,并且c#有一个体育馆,我想用他的报价签到我的登录客户端。
报价表:
| ID | startdate | month | day | enddate | type |
| 1 | 2019-03-05| 3 | null |2019-06-05 |Business Calendar |
| 2 | 2019-03-05| null | 30 |2019-04-04 |Day Calendar |
我尝试以下代码:
try
{
string che = @"(select count(*)from table where id='" + ID.Text + "' and startdate <='" + DateTime.Now + "' and endDate >='" + DateTime.Now + "' )";
con.Open();
SqlCommand sda = new SqlCommand(che, con);
int count = (int)sda.ExecuteScalar();
if (count > 0)
{
using (SqlCommand com = new SqlCommand("INSERT INTO [checkin] (ID,time,username) VALUES (@ID,@time,@username)", con))
{
com.Parameters.AddWithValue("@ID", ID.Text);
com.Parameters.AddWithValue("@time", txttime.Text);
com.Parameters.AddWithValue("@username", txtusername.Text);
com.ExecuteNonQuery();
}
MetroFramework.MetroMessageBox.Show(this, "Check In Sucssesfuly ................... ", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MetroFramework.MetroMessageBox.Show(this, "this ID Expired .....................", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if(con.State == ConnectionState.Open)
con.Close();
}
我正在寻找的是在日历天数未检查ID过期的结束日期时向此代码中添加一些内容
三个月后我有了她的第一个病 第二 每天登录30次或每天