c# - 登录时的签到情况
问题描述
你能帮我解决我的问题吗?我正在使用 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次或一天
解决方案
推荐阅读
- python - 有没有办法在scrapy中禁止域?
- python - 从 analytics.usa.gov API 中提取特定日期
- google-app-engine - Stackdriver Debugger 不捕获快照
- html - 浮动后链接和品牌名称未对齐 - 纯 CSS
- powershell-ise - Powershell ISE 中的自定义键盘快捷键
- arrays - 非法偏移类型(Laravel)
- sql-server - SparkSQL MS SQL Server,编译后得到消息“没有合适的驱动程序”
- php - 在 SQL 中显示消息列表
- android - Gradle 和 minifyEnabled 错误问题:app:transformClassesAndResourcesWithProguardForRelease'
- django - Django:“SessionStore”对象没有“会话”属性