以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 如何实现打开页面就写入开始时间,点确定按钮后就写入学习时间并计算学习时长 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=150526) |
-- 作者:李孝春 -- 发布时间:2020/6/1 10:43:00 -- 如何实现打开页面就写入开始时间,点确定按钮后就写入学习时间并计算学习时长 下述代码无法在页面打开时就记录开始时间 导致开始时间和学习时间 都是当前点击确定按钮后的时间 求解 如何实现打开页面就写入开始时间,点确定按钮后就写入学习时间并计算学习时长 Dim e As RequestEventArgs = args(0) Dim wb As New weui Dim danweimingcheng As String = e.PostValues("单位名称") Dim suoshuzhibu As String = e.PostValues("所属支部") Dim xingming As String = e.PostValues("姓名") Dim tupianleibie As String = e.PostValues("图片类别") Dim bt As String =Tables("学习内容").Current("内容") Dim st As New Date(1970,1,1,8,0,0) Dim d As Date = cdate("2020-02-01") Dim t As Long = (Date.Now - st).TotalSeconds() Dim bianhao As String= Date.Today & "(" & t & ")" Dim 开始时间 As String = e.Cookies("开始时间") 开始时间=Date.Now() Select Case e.Path Case "xuexi.htm" If e.PostValues.Count = 0 Then wb.AddPageTitle("","ph1","党员在线学习系统","瓮安县检察院【党建综合系统】") wb.AddForm("","form1","xuexi.htm") With wb.AddInputGroup("form1","ipg1","【" & e.Cookies("姓名") & "】开始学习时间:" & Date.Now()) .AddInput("学习要求","学习要求","Text").Value="做好自学笔记,以备检查!" End With With wb.AddInputGroup("form1","ipg2","学习内容") With .AddTextArea("bz",15) .Readonly=True .Value= bt End With End With With wb.AddButtonGroup("form1","btg1",True) .Add("btn1", "确定", "submit") End With wb.AppendHTML("<script src=\'./lib/ajaxform.js\'></script>",True) wb.AppendHTML("<script>document.getElementById(\'btn1\').disabled=true;document.getElementById(\'btn1\').style.backgroundColor = \'#b2b2b2\';var cnt = 60;setTimeout(countDown,1000);</script>") e.WriteString(wb.Build) \'生成网页 Else Dim tp As TimeSpan Dim kaishi As Date=Format(开始时间, "T") Dim jieshu As Date=Format(date.now, "T") tp = jieshu-kaishi MessageBox.Show(tp.TotalMinutes) \'真正的时段型数据要转换为秒数,才能存入时段列 Dim cmd1 As New SQ LCommand cmd1.Connect ionN ame = "智慧党建" cmd1.Comma ndText = "Inse rt In to 学习内容 (内容,学习时间,开始时间,学习人员,学习编号,学习时长) Values(?,?,?,?,?)" cmd1.Parameters.Add("@内容", bt) cmd1.Parameters.Add("@学习时间", Date.Now()) cmd1.Parameters.Add("@开始时间", 开始时间) cmd1.Parameters.Add("@学习人员", e.Cookies("姓名")) cmd1.Parameters.Add("@学习编号", bianhao) cmd1.Parameters.Add("@学习时长", tp) cmd1.ExecuteN onQuery With wb.AddMsgPage("","msgpage","学习成功", "好好学习,天天向上") \'生成成功提示页 .AddButton("btn1","继续学习","xuexi.htm") End With e.WriteString(wb.Build) End If End Select
[此贴子已经被作者于2020/6/1 10:43:52编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/6/1 10:53:00 -- 1、函数里再做这种判断完全是多余的,所有函数都去掉这种判断 Select Case e.Path Case "xuexi.htm" 2、利用隐藏域保存开始时间 wb.AddForm("","form1","xuexi.htm") .AddHiddenValue("开始时间",Date.Now()) ------------- Else Dim tp As TimeSpan Dim kaishi As Date=cdate(e.PostValues("开始时间")) Dim jieshu As Date=date.now tp = jieshu-kaishi MessageBox.Show(tp.TotalMinutes) \'真正的时段型数据要转换为秒数,才能存入时段列 Dim cmd1 As New SQ LCommand cmd1.Connect ionN ame = "智慧党建" cmd1.Comma ndText = "Inse rt In to 学习内容 (内容,学习时间,开始时间,学习人员,学习编号,学习时长) Values(?,?,?,?,?)" cmd1.Parameters.Add("@内容", bt) cmd1.Parameters.Add("@学习时间", Date.Now()) cmd1.Parameters.Add("@开始时间", kaishi) cmd1.Parameters.Add("@学习人员", e.Cookies("姓名")) cmd1.Parameters.Add("@学习编号", bianhao) cmd1.Parameters.Add("@学习时长", tp.TotalMinutes) cmd1.ExecuteN onQuery |