
@page
@model xxtsoft.Web.Entry.Pages.qd.IndexModel
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>签到</title>
<link href="~/layui/layui/css/layui.css" rel="stylesheet" />
<style>
body {
background-color: #e7eff3;
}
.bar {
height: 50px;
line-height: 50px;
text-align: center;
font-size:18px;
font-weight:bold;
}
</style>
</head>
<body>
<div class="layui-bg-green bar">
活动签到
</div>
<div class="layui-fluid" style="margin-top:20px;">
<form method="post" class="layui-form" lay-filter="layui-form">
<blockquote class="layui-elem-quote">
@Html.Raw(Model.zt)
</blockquote>
<div class="layui-panel layui-padding-3">
<div class="layui-form-item">
<label class="layui-form-label">活动时间:</label>
<div class="layui-input-inline layui-input-wrap">
@Html.Raw(Model.sj)
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">姓名:<font color="red">*</font></label>
<div class="layui-input-block">
<input type="text" name="xm" id="xm" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">手机:<font color="red">*</font></label>
<div class="layui-input-block">
<input type="text" name="sjh" id="sjh" lay-verify="required|phone" placeholder="请输入" autocomplete="off" class="layui-input">
</div>
</div>
</div>
<br />
<div class="layui-form-item">
<input type="hidden" name="id" id="id" value="@Model.id">
<button type="submit" class="layui-btn layui-btn-fluid" lay-submit>提交</button>
</div>
</form>
</div>
<!-- HTML Content -->
<script src="~/layui/layui/layui.js"></script>
<script>
// Usage
layui.use(function(){
var form = layui.form;
var layer = layui.layer;
});
</script>
</body>
</html>using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using xxtsoft.Common;
namespace xxtsoft.Web.Entry.Pages.qd
{
public class IndexModel : PageModel
{
public string zt = "";
public string id = "";
public string sj = "";
private readonly SqlSugar.ISqlSugarClient _db;
public IndexModel(SqlSugar.ISqlSugarClient db)
{
this._db = db;
}
public void OnGet()
{
id = FunHelper.FilerForm(Request.Query["id"]);
if (string.IsNullOrEmpty(id))
{
MessageHelper.ShowPre("参数错误");
return;
}
zt = CommHelper.GuanLian("rw_hd", id, "zt");
sj = DateTime.Parse(CommHelper.GuanLian("rw_hd", id, "sj")).ToString("yyyy-MM-dd HH:mm");
}
public async Task<IActionResult> OnPostAsync()
{
string xm = FunHelper.FilerForm(Request.Form["xm"]);
string sjh = FunHelper.FilerForm(Request.Form["sjh"]);
string id = FunHelper.FilerForm(Request.Form["id"]);
if (string.IsNullOrEmpty(xm) || string.IsNullOrEmpty(sjh) || string.IsNullOrEmpty(id))
{
return Content("参数错误");
}
var dt = await _db.Ado.GetDataTableAsync("select id from rw_hdqd where hdid=" + FunHelper.SafeInt(id) + " and sjh='" + sjh + "'");
if (dt.Rows.Count > 0)
{
MessageHelper.ShowLocation("请勿重复签到");
return Page();
//return RedirectToPage("/qd/index?id="+id);
}
else
{
await _db.Ado.ExecuteCommandAsync("insert into rw_hdqd(hdid,depid,sjh,xm,qdsj) values(" + FunHelper.SafeInt(id) + "," + CommHelper.GuanLian("rw_hd", id, "depid") + ",'" + sjh + "','" + xm + "','" + DateTime.Now + "')");
}
return RedirectToPage("/qd/tip");
}
}
}