以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  关于退出窗体  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=102367)

--  作者:peibaomin
--  发布时间:2017/6/18 19:35:00
--  关于退出窗体

For Each dt As DataTable In DataTables
    If dt.HasChanges Then
        Dim Result As DialogResult
        Result = MessageBox.Show("窗体处于编辑状态,是否放弃编辑退出?", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
        If Result = DialogResult.No Then
            jinzhihangjianyidong= False
            Exit For
        ElseIf result = DialogResult.Cancel Then
            Tables("机具库存资料").Current("机具条码") = e.Form.Controls("jijutiaomatext1").Value
            Tables("机具库存资料").Current("所属仓库") = e.Form.Controls("suoshucangkuCombo").Value
            Tables("机具库存资料").Current("客户姓名") = e.Form.Controls("kehuxingmingCombo").Value
            Tables("机具库存资料").Current("机具型号") = e.Form.Controls("jijuxinghaoCombo").Value
            Tables("机具库存资料").Current("机具类型") = e.Form.Controls("jijuleixingCombo ").Value
            Tables("机具库存资料").Current("厂家名称") = e.Form.Controls("changjiaxingmingCombo").Value
            Tables("机具库存资料").Current("机具来源") = e.Form.Controls("jijulaiyuanCombo").Value
            Tables("机具库存资料").Current("机具所属机构") = e.Form.Controls("jijusuoshujigouCombo").Value
            Tables("机具库存资料").Current("机具所属机构负责人") = e.Form.Controls("jijusuoshujigongfuzerenCombo").Value
            Tables("机具库存资料").Current("所属机构级别") = e.Form.Controls("suoshujigoujibieCombo").Value
            DataTables("机具库存资料").save
            jinzhihangjianyidong= True
            Return
        End If
    End If
Next
e.Cancel  =False
jinzhihangjianyidong= True

 

 

 

 

这句代码有为题吗?

我想实现选择“是”选项则执行保存修改的数据后退出窗体,如选择“否”选项则执行不保存修改的数据退出窗体,如选择“取消”选项则执行不保存数据返回原窗体。可运行的时候选“取消”选项也是退出窗体,选“否“选项则保存数据退出窗体,选择\'是"选项也是退出窗体整个都乱了!请老师指点指点,谢谢!!


--  作者:有点色
--  发布时间:2017/6/18 21:35:00
--  
If Tables("机具库存资料").DataTable.HasChanges Then
    Dim Result As DialogResult
    Result = MessageBox.Show("窗体处于编辑状态,是否放弃编辑退出?", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
    If Result = DialogResult.No Then
        \'jinzhihangjianyidong= False
    ElseIf result = DialogResult.Cancel Then
        e.cancel = True
    ElseIf result = DialogResult.Yes Then
        Tables("机具库存资料").Current("机具条码") = e.Form.Controls("jijutiaomatext1").Value
        Tables("机具库存资料").Current("所属仓库") = e.Form.Controls("suoshucangkuCombo").Value
        Tables("机具库存资料").Current("客户姓名") = e.Form.Controls("kehuxingmingCombo").Value
        Tables("机具库存资料").Current("机具型号") = e.Form.Controls("jijuxinghaoCombo").Value
        Tables("机具库存资料").Current("机具类型") = e.Form.Controls("jijuleixingCombo ").Value
        Tables("机具库存资料").Current("厂家名称") = e.Form.Controls("changjiaxingmingCombo").Value
        Tables("机具库存资料").Current("机具来源") = e.Form.Controls("jijulaiyuanCombo").Value
        Tables("机具库存资料").Current("机具所属机构") = e.Form.Controls("jijusuoshujigouCombo").Value
        Tables("机具库存资料").Current("机具所属机构负责人") = e.Form.Controls("jijusuoshujigongfuzerenCombo").Value
        Tables("机具库存资料").Current("所属机构级别") = e.Form.Controls("suoshujigoujibieCombo").Value
        DataTables("机具库存资料").save
        \'jinzhihangjianyidong= True
    End If
End If