以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  窗口文本框自动赋值  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=96830)

--  作者:sf020cf
--  发布时间:2017/2/28 17:26:00
--  窗口文本框自动赋值
现有一个入库窗口,有一个批次需要自动生成,格式是wwcn+当天+生产日期,例如wwcn170228150623 代码如下 
Dim scrq,yxqz As WinForm.DateTimePicker
scrq = e.Sender
yxqz = e.Form.Controls("有效期至")
Dim pc As String = e.Form.controls("批次").value
\'Dim qz As String = "WWCN"
Dim k As Date = scrq.value
Dim j As Date = yxqz.value
If k <= Date.Today Then
    yxqz.value = k.AddYears(2)
    e.Form.Controls("有效期至").Select()
Else
    MessageBox.Show("生产日期不能大于当天日期!", "错误提示!",MessageBoxButtons.OK,MessageBoxIcon.Warning)
    yxqz.value = ""
    scrq.value = ""
    e.Form.Controls("生产日期").Select()
    Return
End If
If scrq IsNot Nothing Then
pc =  "WWCN" & Format(Date.today,"yymmdd") & Format(k,"yymmdd")
End If

--  作者:sf020cf
--  发布时间:2017/2/28 17:44:00
--  
没反应,也不报错,也没自动赋值,要改哪里


--  作者:有点色
--  发布时间:2017/2/28 17:47:00
--  
Dim scrq,yxqz As WinForm.DateTimePicker
scrq = e.Sender
yxqz = e.Form.Controls("有效期至")
Dim pc = e.Form.controls("批次")
Dim k As Date = scrq.value
Dim j As Date = yxqz.value
If k <= Date.Today Then
    yxqz.value = k.AddYears(2)
    pc.Text =  "WWCN" & Format(Date.today,"yyMMdd") & Format(k,"yyMMdd")
    yxqz.Select()
Else
    MessageBox.Show("生产日期不能大于当天日期!", "错误提示!",MessageBoxButtons.OK,MessageBoxIcon.Warning)
    yxqz.value = Nothing
    scrq.value = Nothing
    e.Form.Controls("生产日期").Select()
End If

--  作者:有点色
--  发布时间:2017/2/28 17:47:00
--  

如果你控件的值,是绑定表列的,需要这样处理下

 

http://www.foxtable.com/webhelp/scr/2436.htm

 


--  作者:sf020cf
--  发布时间:2017/2/28 18:04:00
--  
谢谢。