Foxtable(狐表)用户栏目专家坐堂 → web保存


  共有5620人关注过本帖树形打印复制链接

主题:web保存

帅哥哟,离线,有人找我吗?
cd_tdh
  1楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐精 帖子:3209 积分:21331 威望:0 精华:0 注册:2016/3/28 16:57:00
web保存  发帖心情 Post By:2022/6/20 16:13:00 [显示全部帖子]

老师,给自己出了个难题,请老师指导,web界面如下:

 

 
图片点击可在新窗口打开查看此主题相关图片如下:11.jpg
图片点击可在新窗口打开查看

保存时,如果只有课内阅读有数据,就新增一行数据,如果课内阅读、课外阅读都有数据,就新增两行数据,该怎么保存?

If e.PostValues.Count = 0 Then

........

else

    Dim nms() As String = {"班级","姓名"} '不能为空的列名数组
    For Each nm As String In nms
        If e.PostValues.ContainsKey(nm) = False Then '生成错误提示页
            With wb.AddMsgPage("","msgpage","增加失败", nm & "列不能为空!")
                .icon = "Warn" '改变图标
                .AddButton("btn1","返回").Attribute = ""
            End With
            e.WriteString(wb.Build)
            Return  Nothing '必须返回
        End If
    Next
    If e.PostValues ("课内阅读") <> "" Then
        nms = New String() {"班级","姓名","打卡用时"}  '重新定义了nms数组,增加了两列.
        Dim dr As DataRow = DataTables("语文打卡记录").AddNew()
        For Each nm As String In nms
            If e.PostValues.ContainsKey(nm) Then
                dr(nm) = e.PostValues(nm)
            End If
        Next
        dr("打卡日期") = Date.Today
        dr("打卡项目") = "课内阅读"
        dr("登记状态") = True
        dr("登记人") = _UserXingMing
        dr("登记日期") = Date.Today
       
        Dim lst As  List(of String) = dr.Lines("附件")
        For Each key As String In e.Files.Keys
            If key = "up1" Then
                For Each fln As String In e.Files(key)
                    e.SaveFile(key,fln, ProjectPath & "web\images\语文打开记录\" & fln) '保存接收到的文件
                    lst.add("/images/语文打开记录/" &  "/" & fln)
                Next
                dr.Lines("附件") = lst
            End If
        Next
       
    End If
    'dr.Save
   
    If e.PostValues("课外阅读") <> "" Then
        nms = New String() {"班级","姓名","打卡用时"}  '重新定义了nms数组,增加了两列.
        Dim ds As DataRow = DataTables("语文打卡记录").AddNew()
        For Each nm As String In nms
            If e.PostValues.ContainsKey(nm) Then
                ds(nm) = e.PostValues(nm)
            End If
        Next
        ds("打卡日期") = Date.Today
        ds("打卡项目") = "课外阅读"
        ds("登记状态") = True
        ds("登记人") = _UserXingMing
        ds("登记日期") = Date.Today
        Dim lst As List(of String) = ds.Lines("附件")
        For Each key As String In e.Files.Keys
            If key = "up2" Then
                For Each fln As String In e.Files(key)
                    e.SaveFile(key,fln, ProjectPath & "web\images\语文打开记录\" & fln) '保存接收到的文件
                    lst.add("/images/语文打开记录/" &  "/" & fln)
                Next
                ds.Lines("附件") = lst
            End If
        Next
    End If
   
    'ds.Save
    '保存并生成增加成功提示页面
    With wb.AddMsgPage("","msgpage","打卡成功", "好好学习,天天向上!") '生成成功提示页
        .AddButton("btn1","继续增加","Yuwen_Clock_add.htm")
    End With
    e.WriteString(wb.Build)
End If


 回到顶部
帅哥哟,离线,有人找我吗?
cd_tdh
  2楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐精 帖子:3209 积分:21331 威望:0 精华:0 注册:2016/3/28 16:57:00
  发帖心情 Post By:2022/6/20 17:01:00 [显示全部帖子]

up1\up2是附件,附件不是必传项目。保存按钮全部代码如下:

Dim e As object = args(0)
Dim wb As New weui
wb.InsertHTML("<style>.exui-navbar {height:40px;}</style>")
wb.AppendHTML("<link rel='stylesheet' href='./weui/exweui.css'/>",True)
If e.PostValues.Count = 0 Then
    wb.AddForm("","form1","Yuwen_Clock_add.htm")
    '设置导航条并添加标题栏名称
    With ExWeUI.WebUI.AddNavBar("form1","navbar01")
        .Attribute = "style='background-color: #FBF9FC;color:#000000'" '设置导航条背景色和标题文字颜色
        With .LeftGroup.AddItem("nvi01","")                            '左导航栏添加一个项目
            .image = "./images/返回.png"                               '添加图标
            '.Attribute = """          '浏览器后退功能
            .Attribute = ""   '回退到首页指定页面
        End With
        With .RightGroup.AddItem("nvi02","")      '右导航栏添加一个空项目
        End With
        .CenterGroup.Text = "语文打卡登记信息" '标题栏名称
        wb.InsertHTML("form1",.BuildHtml) '添加到TabBar的page1中
    End With
    '添加学生信息分组
    With wb.AddInputGroup("form1","id1","学生信息") 'ParentID 父容器的ID,如果是顶层对象,设置为""即可. ID 分组ID. Text 可选参数,用于指定分组标题.
        With .AddInput("班级","班&emsp;&emsp;级","text")
            .Value = _UserGroup
            .Readonly= True
        End With
        With .AddInput("姓名","姓&emsp;&emsp;名","text")
            .Value = _UserXingMing
            .Readonly= True
        End With
        With .AddInput("打卡日期","打卡日期","data")
            .Value = Date.Today
            .Readonly= True
        End With
       
    End With
   
    '添加打卡项目
    With wb.AddInputGroup("form1","打卡项目","打卡项目")
        With .AddInputCell("ic1") '通过InputCell增加输入框
            .AddLabel("ls1","课内阅读",0)  '增加标签,0显示在左边
            .AddInput("课内阅读","number",1).Placeholder ="课内阅读时间" '增加输入框,1表示显示在中间
            .AddLabel("ls2","(分钟)",2)     '增加标签,2表示显示在右边
        End With
        With .AddUploader("up1","",True)
            .Accept = "image/*"
            .Capture = "camera" '拍照上传
            .AllowDelete = True '允许删除
            .Incremental = True '允许重复选择文件或连续拍照
            .ScaleWidth = 400 '自动压缩图片宽度为400个像素,高度等比例压缩
        End With
       
        With .AddInputCell("ic1") '通过InputCell增加输入框
            .AddLabel("ls1","课外阅读",0)  '增加标签,0显示在左边
            .AddInput("课外阅读","number",1).Placeholder ="课外阅读时间" '增加输入框,1表示显示在中间
            .AddLabel("ls2","(分钟)",2)     '增加标签,2表示显示在右边
        End With
        With .AddUploader("up2","",True)
            .Accept = "image/*"
            .Capture = "camera" '拍照上传
            .AllowDelete = True '允许删除
            .Incremental = True '允许重复选择文件或连续拍照
            .ScaleWidth = 400 '自动压缩图片宽度为400个像素,高度等比例压缩
        End With
    End With
   
    With wb.AddPreview("","pv1","","")
        .AddButton("保&emsp;&emsp;存","", 1,"submit")
    End With
    wb.InsertHTML("<style>.weui-form-preview {margin-top:5px;}</style>")                      '设置AddPreview1与上边间距
Else
    Dim nms() As String = {"班级","姓名","打卡日期"} '不能为空的列名数组
    For Each nm As String In nms
        If e.PostValues.ContainsKey(nm) = False Then '生成错误提示页
            With wb.AddMsgPage("","msgpage","增加失败", nm & "列不能为空!")
                .icon = "Warn" '改变图标
                .AddButton("btn1","返回").Attribute = ""
            End With
            e.WriteString(wb.Build)
            Return  Nothing '必须返回
        End If
    Next
    If e.Files.containskey("up1")Then
        nms = New String() {"班级","姓名","打卡日期","打卡用时"}  '重新定义了nms数组,增加了两列.
        Dim dr As DataRow = DataTables("语文打卡记录").AddNew()
        For Each nm As String In nms
            If e.PostValues.ContainsKey(nm) Then
                dr(nm) = e.PostValues(nm)
            End If
        Next
        dr("打卡项目") = "课内阅读"
        dr("登记状态") = True
        dr("登记人") = _UserXingMing
        dr("登记日期") = Date.Today
       
        Dim lst As  List(of String) = dr.Lines("附件")
        For Each key As String In e.Files.Keys
            If key = "up1" Then
                For Each fln As String In e.Files(key)
                    e.SaveFile(key,fln, ProjectPath & "web\images\语文打卡记录\" & fln) '保存接收到的文件
                    lst.add("/images/语文打卡记录/" &  "/" & fln)
                Next
                dr.Lines("附件") = lst
            End If
        Next
            dr.Save
    End If
   
    If e.Files.containskey("up2")Then
        nms = New String() {"班级","姓名","打卡日期","打卡用时"}  '重新定义了nms数组,增加了两列.
        Dim ds As DataRow = DataTables("语文打卡记录").AddNew()
        For Each nm As String In nms
            If e.PostValues.ContainsKey(nm) Then
                ds(nm) = e.PostValues(nm)
            End If
        Next
        ds("打卡项目") = "课外阅读"
        ds("登记状态") = True
        ds("登记人") = _UserXingMing
        ds("登记日期") = Date.Today
        Dim lst As List(of String) = ds.Lines("附件")
        For Each key As String In e.Files.Keys
            If key = "up2" Then
                For Each fln As String In e.Files(key)
                    e.SaveFile(key,fln, ProjectPath & "web\images\语文打卡记录\" & fln) '保存接收到的文件
                    lst.add("/images/语文打卡记录/" &  "/" & fln)
                Next
                ds.Lines("附件") = lst
            End If
        Next
    ds.Save
    End If

    '保存并生成增加成功提示页面
    With wb.AddMsgPage("","msgpage","打卡成功", "好好学习,天天向上!") '生成成功提示页
        .AddButton("btn1","返回").Attribute = ""
    End With
    e.WriteString(wb.Build)
End If

e.WriteString(wb.Build)


 回到顶部
帅哥哟,离线,有人找我吗?
cd_tdh
  3楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐精 帖子:3209 积分:21331 威望:0 精华:0 注册:2016/3/28 16:57:00
  发帖心情 Post By:2022/6/20 17:10:00 [显示全部帖子]

保存没成功,保存成功的弹窗也没出来

 回到顶部
帅哥哟,离线,有人找我吗?
cd_tdh
  4楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐精 帖子:3209 积分:21331 威望:0 精华:0 注册:2016/3/28 16:57:00
  发帖心情 Post By:2022/6/20 17:27:00 [显示全部帖子]

对的啊,应该是已通过红色这个控件来判断啊?

With .AddInputCell("ic1") '通过InputCell增加输入框
            .AddLabel("ls1","课内阅读",0)  '增加标签,0显示在左边
            .AddInput("课内阅读","number",1).Placeholder ="课内阅读时间" '增加输入框,1表示显示在中间
            .AddLabel("ls2","(分钟)",2)     '增加标签,2表示显示在右边
        End With

....

With .AddInputCell("ic1") '通过InputCell增加输入框
            .AddLabel("ls1","课外阅读",0)  '增加标签,0显示在左边
            .AddInput("课外阅读","number",1).Placeholder ="课外阅读时间" '增加输入框,1表示显示在中间
            .AddLabel("ls2","(分钟)",2)     '增加标签,2表示显示在右边
        End With


 回到顶部
帅哥哟,离线,有人找我吗?
cd_tdh
  5楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐精 帖子:3209 积分:21331 威望:0 精华:0 注册:2016/3/28 16:57:00
  发帖心情 Post By:2022/6/20 17:43:00 [显示全部帖子]

点保存没反应,调试else后面一个弹窗都不出来

 回到顶部
帅哥哟,离线,有人找我吗?
cd_tdh
  6楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐精 帖子:3209 积分:21331 威望:0 精华:0 注册:2016/3/28 16:57:00
  发帖心情 Post By:2022/6/21 8:36:00 [显示全部帖子]

犯了2个错误,昨天纠结半天,睡一觉一下想明白了

错误1:

With wb.AddPreview("form1","pv1","","")
        .AddButton("保&emsp;&emsp;存","", 1,"submit")
    End With
    wb.InsertHTML("<style>.weui-form-preview {margin-top:5px;}</style>")                      '设置AddPreview1与上边间距

错误2:

    If e.PostValues.ContainsKey("课内阅读") Then
        nms = New String() {"班级","姓名","打卡日期"}  '重新定义了nms数组,增加了两列.
        Dim dr As DataRow = DataTables("语文打卡记录").AddNew()
        For Each nm As String In nms
            If e.PostValues.ContainsKey(nm) Then
                dr(nm) = e.PostValues(nm)
            End If
        Next
        dr("打卡项目") = "课内阅读"
        dr("打卡用时") = e.PostValues("课内阅读")  ‘Id是课内阅读、课外阅读,不是打卡用时
        dr("登记状态") = True
        dr("登记人") = _UserXingMing
        dr("登记日期") = Date.Today

 

图片点击可在新窗口打开查看

[此贴子已经被作者于2022/6/21 8:42:40编辑过]

 回到顶部