⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmyzlshowg.frm

📁 小型超市进销存系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         Caption         =   "国际码:"
         Height          =   180
         Left            =   3480
         TabIndex        =   7
         Top             =   480
         Width           =   720
      End
   End
End
Attribute VB_Name = "frmYZLShowG"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim XG As Boolean

Private Sub cmbArea_Click()
    Dim strsql As String
    Dim I As Integer
    strsql = "select typename from t_type where sarea='" & cmbArea.Text & "'"
    Dblink.executeSQL (strsql)
    
    cmbType.Clear
    cmbType.Text = "请选择"
    For I = 1 To Dblink.rs.RecordCount
        cmbType.AddItem Trim(Dblink.rs.Fields(0).Value)
        Dblink.rs.MoveNext
        If Dblink.rs.EOF = True Then Exit For
    Next I
End Sub

Private Sub cmdAmend_Click()
Dim strsql As String
If YZLAddgoods = True Then
    If txtUPC.Text = "" Then
        MsgBox "商品国际码不能为空!", vbExclamation
        txtUPC.SetFocus
        Exit Sub
    End If
    
    If txtName.Text = "" Then
        MsgBox "商品名称不能为空!", vbExclamation
        txtName.SetFocus
        Exit Sub
    End If
    
    If txtBrand.Text = "" Then
        MsgBox "商品品牌不能为空!", vbExclamation
        txtBrand.SetFocus
        Exit Sub
    End If
    
    If cmbType.Text = "选择商品类型" Then
        MsgBox "请选择商品类型!"
        cmbType.SetFocus
        Exit Sub
    End If
    
    If txtSpec.Text = "" Then
        MsgBox "商品规格不能为空!", vbExclamation
        txtSpec.SetFocus
        Exit Sub
    End If
    
    If txtArea.Text = "" Then
        MsgBox "商品产地不能为空!", vbExclamation
        txtArea.SetFocus
        Exit Sub
    End If
    
    If txtUnit.Text = "" Then
        MsgBox "商品销售单位不能为空!", vbExclamation
        txtUnit.SetFocus
        Exit Sub
    End If
    
    strsql = "select * from t_goods where upc='" & Trim(txtUPC.Text) & "'"
    Dblink.executeSQL (strsql)
    If Dblink.rs.RecordCount <> 0 Then
        MsgBox "商品库中已有此UPC,请核对!", vbInformation
        txtUPC.SetFocus
        txtUPC.SelStart = 0
        txtUPC.SelLength = 15
        Exit Sub
    End If
    
    strsql = "select * from t_brand where brand='" & Trim(txtBrand.Text) & "'"
    Dblink.executeSQL (strsql)
    If Dblink.rs.RecordCount = 0 Then
        MsgBox "商品库中无此品牌信息,请先添加其品牌!", vbInformation
        txtBrand.SetFocus
        txtBrand.SelStart = 0
        txtBrand.SelLength = 10
        Exit Sub
    End If
    
    strsql = "insert into t_goods values('" & Trim(txtId.Text) & "','" & Trim(txtName.Text) & "','" & Trim(txtUPC.Text) & "','" & Trim(txtBrand.Text) & "','" & Trim(cmbType.Text) & "','" & Trim(txtSpec.Text) & "','" & Trim(txtUnit.Text) & "',0,'" & Trim(txtArea.Text) & "')"
    Dblink.executeSQL (strsql)
    
    strsql = "insert into t_market values('" & Trim(txtId.Text) & "','" & Trim(txtName.Text) & "','" & Trim(txtBrand.Text) & "','" & Trim(txtUnit.Text) & "',0)"
    Dblink.executeSQL (strsql)
    
    Call YZLRefMSHFlexGrid(frmYZLGoods, "select goodsid '商品号',goodsname '商品名称',upc '国际码',brand '品牌',typename '商品类型',spec '商品规格',unit '销售单位',store '库存',area '产地' from t_goods")
    frmYZLGoods.cmbArea.Text = "所有区域"
    frmYZLGoods.cmbType.Text = "请选择商品类型"
    frmYZLGoods.cmbType.Enabled = False
    YZLAddgoods = False
    Unload Me
    Exit Sub
End If

If XG = False Then
    txtType.Visible = False
    cmbType.Visible = True
    txtName.Enabled = True
    txtSpec.Enabled = True
    txtUnit.Enabled = True
    txtArea.Enabled = True
    txtSarea.Visible = False
    cmbArea.Visible = True
    cmbArea.Text = txtSarea.Text
    cmdAmend.Caption = "确定修改"
    cmdDel.Visible = False
    XG = True
    cmbType.Text = txtType.Text
    
    strsql = "select typename from t_type where sarea='" & cmbArea.Text & "'"
    Set Dblink.rs = Dblink.executeSQL(strsql)
    For I = 1 To Dblink.rs.RecordCount
        cmbType.AddItem Trim(Dblink.rs.Fields(0).Value)
        Dblink.rs.MoveNext
        If Dblink.rs.EOF Then Exit For
    Next I
Else
    strsql = "update t_goods set typename='" & Trim(cmbType.Text) & "',goodsname='" & Trim(txtName.Text) & "',spec='" & Trim(txtSpec.Text) & "',unit='" & Trim(txtUnit.Text) & "',area='" & Trim(txtArea.Text) & "' where goodsid='" & Trim(txtId.Text) & "'"
    Dblink.executeSQL (strsql)
    
    Call YZLRefMSHFlexGrid(frmYZLGoods, "select goodsid '商品号',goodsname '商品名称',upc '国际码',brand '品牌',typename '商品类型',spec '商品规格',unit '销售单位',store '库存',area '产地' from t_goods")
    frmYZLGoods.cmbArea.Text = "所有区域"
    frmYZLGoods.cmbType.Text = "请选择商品类型"
    frmYZLGoods.cmbType.Enabled = False
    XG = False
    Unload Me
End If
End Sub

Private Sub cmdBack_Click()
    If YZLAddgoods = True Then YZLAddgoods = False
    If XG = True Then XG = False
    Unload Me
End Sub

Private Sub cmdDel_Click()
    Dim strsql As String
    If Val(txtStock.Text) = 0 And Val(txtMarket.Text) = 0 Then
        strsql = "delete t_goods where goodsid='" & Trim(txtId.Text) & "'"
        Dblink.executeSQL (strsql)
        Call YZLRefMSHFlexGrid(frmYZLGoods, "select goodsid '商品号',goodsname '商品名称',upc '国际码',brand '品牌',typename '商品类型',spec '商品规格',unit '销售单位',store '库存',area '产地' from t_goods")
        frmYZLGoods.cmbArea.Text = "所有区域"
        frmYZLGoods.cmbType.Text = "请选择商品类型"
        frmYZLGoods.cmbType.Enabled = False
        XG = False
        Unload Me
    Else
        MsgBox "此单品还有库存,不能进行此操作!", vbExclamation
        Exit Sub
    End If
End Sub

Private Sub Form_Load()
cmbArea.AddItem "所有区域"
cmbArea.AddItem "食品"
cmbArea.AddItem "中心"
cmbArea.AddItem "非食"
cmbArea.AddItem "生鲜"
If YZLAddgoods = False Then
    Dim strsql As String
    strsql = "select upc,typename,goodsname,brand,spec,store,unit,area from t_goods where goodsid='" & Trim(frmYZLGoods.MSHFlexGrid1.Tag) & "'"
    Dblink.executeSQL (strsql)
    txtId.Text = Trim(frmYZLGoods.MSHFlexGrid1.Tag)
    txtUPC.Text = Dblink.rs.Fields(0).Value
    txtType.Text = Dblink.rs.Fields(1).Value
    txtName.Text = Dblink.rs.Fields(2).Value
    txtBrand.Text = Dblink.rs.Fields(3).Value
    txtSpec.Text = Dblink.rs.Fields(4).Value
    txtStock.Text = Dblink.rs.Fields(5).Value
    txtUnit.Text = Dblink.rs.Fields(6).Value
    txtArea.Text = Dblink.rs.Fields(7).Value
    
    strsql = "select sarea from t_type where typename='" & txtType.Text & "'"
    Dblink.executeSQL (strsql)
    txtSarea.Text = Dblink.rs.Fields(0).Value
    
    strsql = "select num from t_market where goodsid='" & Trim(txtId.Text) & "'"
    Dblink.executeSQL (strsql)
    txtMarket.Text = Dblink.rs.Fields(0).Value
Else
    txtId.Text = newid("t_goods", "goodsid") '调用存储过程,自动生成临时新的商品号
    txtUPC.Enabled = True
    txtSarea.Visible = False
    cmbArea.Visible = True
    cmbArea.Text = "请选择所在区域"
    txtName.Enabled = True
    txtBrand.Enabled = True
    txtType.Visible = False
    cmbType.Visible = True
    txtSpec.Enabled = True
    txtArea.Enabled = True
    txtUnit.Enabled = True
    txtStock.Text = 0
    txtMarket.Text = 0
    cmdAmend.Caption = "确定"
    cmdDel.Visible = False
End If
End Sub

Private Sub txtArea_KeyPress(KeyAscii As Integer)
    KeyAscii = YZLKpress(KeyAscii)
End Sub

Private Sub txtBrand_KeyPress(KeyAscii As Integer)
    KeyAscii = YZLKpress(KeyAscii)
End Sub

Private Sub txtName_KeyPress(KeyAscii As Integer)
    KeyAscii = YZLKpress(KeyAscii)
End Sub

Private Sub txtSpec_KeyPress(KeyAscii As Integer)
    KeyAscii = YZLKpress(KeyAscii)
End Sub

Private Sub txtUnit_KeyPress(KeyAscii As Integer)
    KeyAscii = YZLKpress(KeyAscii)
End Sub

Private Sub txtUPC_KeyPress(KeyAscii As Integer)
    If ((KeyAscii > 47 And KeyAscii < 58) Or KeyAscii = 8) Then
        Exit Sub
    Else
        KeyAscii = 0
    End If
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -