asp.net razor post

浪淘沙7个月前后端77

image.png

@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");
        }

    }
}


相关文章

导出excel

@page @model xxtsoft.Web.Entry.Pages.test2Model @{ } <form method="post"&...

SqlSugar

   var dt = _db.SqlQueryable<object>("select * fr...

JNTemplate 模板标签读取dt数据

一、模板标签using JinianNet.JNTemplate; private readonly SqlSugar.ISqlSugarClient _db;...

asp.net core razor 远程请求 认证Basic auth 模式 body传递 json

private readonly HttpClient _httpClient;    public RemoteReq...

wangeditor编辑器

<!--编辑器--> <link href="/wangeditor/style.css" rel="stylesheet&quo...

asp.net core 取得页面form中所有表单值

public IActionResult OnPostSubmit()         { &n...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。