以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  字段添加问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=117119)

--  作者:lxhmax
--  发布时间:2018/4/7 1:24:00
--  字段添加问题
老师,为啥这个复选项,颜色字段可以正常添加到表中,而尺码字段是无法添加的表中的?

\'通用事件头
Dim fl As String = "d:\\web\\" & e.path
If filesys.FileExists(fl)
    Dim idx As Integer = fl.LastIndexOf(".")
    Dim ext As String  = fl.SubString(idx)
    Select Case ext
        Case ".jpg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar"
            e.WriteFile(fl)
            Return \'这里必须返回
    End Select
End If
Dim wb As New weui
\'身份验证
Dim Verified As Boolean \'用于标记用户是否通过了身份验证
Dim UserName As String = e.Cookies("username") \'从cookie中获取用户名
Dim Password As String = e.Cookies("password") \'从cookie中获取用户密码
If e.Path = "logon.htm" \'如果是通过登录页面访问,从PostValues即可中提取用户名和密码
    If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password")  Then
        UserName = e.PostValues("username")
        Password = e.PostValues("password")
    End If
End If
If UserName = "张三" AndAlso Password = "888" Then  \'实际使用的时候,请改为从数据库读取用户名和密码进行比较
    Verified  = True
ElseIf Username = "李四" AndAlso Password="999" Then
    Verified  = True
End If
If Verified AndAlso e.Path = "logon.htm"  Then \'如果用户访问的是登录页,且身份验证成功
    wb.AppendCookie("username",UserName) \'将用户名和密码写入cookie
    wb.AppendCookie("password",Password)
    wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") \'直接跳转到首页
    e.WriteString(wb.Build) \'生成网页
    Return \'必须的
ElseIf Verified = False AndAlso e.Path <> "logon.htm" Then \'如果用户身份验证失败,且访问的不是登录页面
    wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") \'那么直接跳转到登录页面
    e.WriteString(wb.Build) \'生成网页
    Return \'必须的
End If
\'开始生成网页
Select Case e.path
    Case "logon.htm" \'登录页面
        wb.AddPageTitle("","pageheader","销售系统","由湛江辉迅基于Foxtable开发")
        If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password")  Then \'判断是否是验证失败后的重新登录
            wb.AddTopTips("","toptip1","用户名或密码错误!").msec = 2000 \'如果用户通过登录按钮访问,则给用户一个2秒的提示.
        End If
        wb.AddForm("","form1","logon.htm")
        With wb.AddInputGroup("form1","ipg1")
            .AddInput("username","户名","text")
            .AddInput("password","密码","password")
        End With
        With wb.AddButtonGroup("form1","btg1",True)
            .Add("btn1", "登录", "submit")
        End With
    Case "exit.htm" \'退出登录
        wb.DeleteCookie("username") \'清除cookie中原来的用户名和密码
        wb.DeleteCookie("password")
        wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") \'那么直接跳转到登录页面
    Case "", "default.htm" \'首页
        wb.AddPageTitle("","pageheader","销售系统","由湛江辉迅基于Foxtable开发")
        With wb.AddGrid("","g1")
            .Add("c1","增加订单", "./images/zjdd.png","http://192.168.1.122/addnew.htm")
            .Add("c2","订单管理", "./images/ddgl.png", "http://192.168.1.122/khgl.htm")
            .Add("c3","商品入库", "./images/sprk.png", "http://www.foxtable.com")
            .Add("c4","库存管理", "./images/kcgl.png", "http://www.foxtable.com")
            .Add("c5","供应商", "./images/gys.png", "http://www.foxtable.com")
            .Add("c6","客户管理", "./images/khgl.png", "http://www.foxtable.com")
            .Add("c7","退出", "./images/exit0.png", "exit.htm") \'退出登录
        End With
    Case "addnew.htm"
        If e.PostValues.Count = 0 Then
            wb.AddForm("","form1","addnew.htm")
            With wb.AddInputGroup("form1","ipg1","产品资料")
                .AddInput("产品名称","产品名称","Text") \'前一个"姓名"是ID,后一个"姓名"是标题
                .AddInput("品牌","品牌","Text")
                .AddInput("产品大类","产品大类","Text")
                .AddInput("产品小类","产品小类","Text")
                .AddInput("款号","款号","Text")
                \'.AddInput("颜色","颜色","Text")
                \'.AddInput("尺码","尺码","Text")
                .AddInput("库存数","库存数","number")
                .AddInput("销售价","销售价","number")
                .AddInput("批发价","批发价","number")
                .AddInput("进货价","进货价","number")
                .AddInput("供应商","供应商","Text")
                .AddInput("描述","描述","Text")
            End With
            With wb.AddCheckGroup("form1","颜色","颜色")
                .Add("红","红")
                .Add("黄","黄")
                .Add("蓝","蓝")
            End With
            With wb.AddCheckGroup("form1","尺码","尺码")
                .Add("S","S")
                .Add("M","M")
                .Add("L","L")
            End With
            With wb.AddButtonGroup("form1","btg1",True)
                .Add("btn1", "确定", "submit")
            End With
            e.WriteString(wb.Build)
        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 \'必须返回
                End If
            Next
            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
            \'以下代码处理品牌复选列表项
            Dim cm As String
            nms = New String() {"S","M","L"} \'将nms重新定义为品牌数组
            For Each nm As String In nms
                If e.PostValues.ContainsKey(nm) AndAlso e.PostValues(nm).Trim() = "on" Then \'不能省略Trim
                    cm = cm & nm  & ","
                End If
            Next

            If cm > "" Then
                dr("尺码") = cm.Trim(",")
            End If
            \'以下代码处理品牌复选列表项
            Dim ys As String
            nms = New String() {"红","黄","蓝"} \'将nms重新定义为品牌数组
            For Each nm As String In nms
                If e.PostValues.ContainsKey(nm) AndAlso e.PostValues(nm).Trim() = "on" Then \'不能省略Trim
                    ys = ys & nm  & ","
                End If
            Next
            If ys > "" Then
                dr("颜色") = ys.Trim(",")
            End If
            \'保存并生成增加成功提示页面
            dr.save()
            With wb.AddMsgPage("","msgpage","增加成功", "好好学习,天天向上") \'生成成功提示页
                .AddButton("btn1","继续增加","addnew.htm")
            End With
            e.WriteString(wb.Build)
        End If 
End Select
e.WriteString(wb.Build) \'生成网页


--  作者:有点蓝
--  发布时间:2018/4/7 9:36:00
--  
大小写问题

nms = New String() {"s","m","l"} 

ID输入框ID,注意生成网页时,WeUI会自动将所有ID转换为小写,例如"Table1"或转换为"table1",今后不再重复提示,大家请自行留意。