以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  不知怎的第一项绑定总是丢了  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=151326)

--  作者:kennypalm
--  发布时间:2020/6/20 16:53:00
--  不知怎的第一项绑定总是丢了

如图所示 ,已经绑定数据库,但按新增后 输入 1,2,3,4 项时,第一项总会自己丢掉,没法保存



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


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


[此贴子已经被作者于2020/6/20 16:54:16编辑过]

--  作者:有点蓝
--  发布时间:2020/6/20 16:58:00
--  
控件和表事件分别有什么代码?
--  作者:kennypalm
--  发布时间:2020/6/20 17:01:00
--  
这个是 form load 事件

Dim lbl_status As WinForm.Label = e.Form.Controls("lbl_status")
Dim cmd_Add_detail As WinForm.Button = e.Form.Controls("cmd_Add_detail")
Dim str_pc_serial As String
Dim I As Integer
Dim pc_transaction As Table = e.Form.Controls("pc_transaction").Table


cmd_Add_detail.Text=vars("msg_input") & vars("datagrid.detail")
P_Row_status=""
P_DataRow_status=""


DataTables("pc_master").load()


If Tables("pc_master").Count>0  Then
    

If Tables("pc_master").Position=0 Then
    
    i=Tables("pc_master").Position+1
Else
    i=Tables("pc_master").Position
    End  If
    
    Dim r As Row =Tables("pc_master").Current
    str_pc_serial=        r("pc_serial")
    \'    messagebox .Show (" str_pc_serial " & str_pc_serial )
    DataTables("pc_transaction").loadfilter = "pc_serial=\'"&  str_pc_serial &"\' "
    DataTables("pc_transaction").load()
    
    
    lbl_status.Text= vars("records")  & " : " &    i  & " / " &  Tables("pc_master").Count
End If

\'DataTables("pc_transaction").loadtop = Nothing
\'DataTables("pc_transaction").load()

--  作者:kennypalm
--  发布时间:2020/6/20 17:01:00
--  
这个是保存按键事件

Dim txt_inv_number As WinForm.TextBox = e.Form.Controls("txt_inv_number")
Dim txt_customer_cname As WinForm.TextBox = e.Form.Controls("txt_customer_cname")
Dim txt_customer_fax As WinForm.TextBox = e.Form.Controls("txt_customer_fax")
Dim txt_customer_no As WinForm.TextBox = e.Form.Controls("txt_customer_no")
Dim txt_customer_tel As WinForm.TextBox = e.Form.Controls("txt_customer_tel")
Dim txt_hdd_info As WinForm.TextBox = e.Form.Controls("txt_hdd_info")
Dim txt_item_desc As WinForm.TextBox = e.Form.Controls("txt_item_desc")
Dim txt_item_barcode As  WinForm.TextBox = e.Form.Controls("txt_item_barcode")
Dim txt_lan_ip As WinForm.TextBox = e.Form.Controls("txt_lan_ip")
Dim txt_monitor As WinForm.TextBox = e.Form.Controls("txt_monitor")
Dim txt_motherboard As WinForm.TextBox = e.Form.Controls("txt_motherboard")
Dim txt_pc_cpu As WinForm.TextBox = e.Form.Controls("txt_pc_cpu")
Dim txt_pc_remark As WinForm.TextBox = e.Form.Controls("txt_pc_remark")
Dim txt_photo_path1 As WinForm.TextBox = e.Form.Controls("txt_photo_path1")
Dim txt_photo_path2 As WinForm.TextBox = e.Form.Controls("txt_photo_path2")
Dim txt_photo_path3 As WinForm.TextBox = e.Form.Controls("txt_photo_path3")
Dim txt_photo_path4 As WinForm.TextBox = e.Form.Controls("txt_photo_path4")
Dim txt_photo_path5 As WinForm.TextBox = e.Form.Controls("txt_photo_path5")
Dim txt_wifi_ip As WinForm.TextBox = e.Form.Controls("txt_wifi_ip")
Dim pc_index As  String
Dim com_cat As WinForm.ComboBox = e.Form.Controls("com_cat")
Dim str(10) As String
Dim str_date As String
Dim str_pc_serial As String

P_selected_formname="PC_Master"

If len(txt_pc_cpu.text)=0 Then
    str(1)=vars("msg_not_input")
    str(2)=vars("msg_data")
    str(0)=str(1) & str(2)
    messagebox.Show (str(0))
    Exit Sub
End If

str_date=Format(Date.now,("yyyyMMddHHmmss"))


If len(txt_inv_number.Text)=0 Then
    txt_inv_number.Text= DataTables("pc_master") .Compute("Max(invoice_number)") + 1
     messagebox.Show (" txt_inv_number.Text " & txt_inv_number.Text )
End If

If len(str_pc_serial )=0 Then
    p_primary_key = DataTables("pc_master") .Compute("Max(primary_key)") + 1
    Functions.execute("Sub_GetSerial")
    str_pc_serial=P_primary_key &"_" & P_pc_serial
    \'messagebox.Show (" str_pc_serial " & str_pc_serial )
End If
    
    
    P_Row_pc_master("primary_key")=p_primary_key
    P_Row_pc_master("pc_serial")=str_pc_serial
    P_Row_pc_master("invoice_number")=txt_inv_number.Text
    P_Row_pc_master("pc_cpu")=txt_pc_cpu.text
    p_Row_pc_master("customer_cname")=txt_customer_cname.text
    P_Row_pc_master("customer_fax")=txt_customer_fax.Text
    P_Row_pc_master("customer_tel")=txt_customer_tel.Text
    P_Row_pc_master("pc_hdd_info")=txt_hdd_info.Text
    
    
    If len(com_cat.Text)>0 Then
        p_Row_pc_master("cat_code")=com_cat.Text
    Else
        p_Row_pc_master("cat_code")="cat_code"
    End If
    
    
    p_Row_pc_master("item_no")="item_no"
    p_Row_pc_master("item_cdesc")=txt_item_desc.Text
    p_Row_pc_master("item_barcode")=txt_item_barcode.Text
    
    p_Row_pc_master("pc_cpu")=txt_pc_cpu.Text
    p_Row_pc_master("pc_wifi_ip")=txt_wifi_ip.Text
    p_Row_pc_master("pc_lan_ip")=txt_lan_ip.Text
    p_Row_pc_master("pc_hdd_info")=txt_hdd_info.Text
    p_Row_pc_master("pc_monitor")=txt_monitor.Text
    p_Row_pc_master("pc_motherboard")=txt_motherboard.Text
    
    p_Row_pc_master("customer_no")=P_Customer_No
    p_Row_pc_master("customer_tel")=txt_customer_tel.Text
    
    pc_index=P_computer_name & "_" & P_Sales_Code &"_" & P_Customer_Card_No &"_" &  txt_customer_cname.Text  &"_" & txt_inv_number.Text
    MessageBox.Show ("pc_index " & pc_index )
    p_Row_pc_master("pc_index")=pc_index
    p_Row_pc_master("shopcode")=p_company_shopcode
    p_Row_pc_master("updated_on")=Date.now
    
    If len(P_Sales_Code)>0 Then
        p_Row_pc_master("updated_by")=P_Sales_Code
    Else
        p_Row_pc_master("updated_by")="admin"
    End If
    
    P_Row_pc_master.Save
    \'Tables("pc_master").current.save()
    
    \'DataTables("pc_master").Save()
    
    messagebox.Show (vars("msg_saved_records") )
    
    \'DataTables("pc_master").load()
    P_Row_status=""
    P_DataRow_status=""