frmDispose.frm
上传用户:czxfzx
上传日期:2015-02-25
资源大小:749k
文件大小:9k
源码类别:

企业管理

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
  3. Begin VB.Form frmDispose 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "报损信息"
  6.    ClientHeight    =   4470
  7.    ClientLeft      =   2760
  8.    ClientTop       =   3750
  9.    ClientWidth     =   6360
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   4470
  14.    ScaleWidth      =   6360
  15.    ShowInTaskbar   =   0   'False
  16.    Begin VB.Frame fraMerchType 
  17.       Caption         =   "报损信息"
  18.       Height          =   3495
  19.       Left            =   120
  20.       TabIndex        =   8
  21.       Top             =   240
  22.       Width           =   6015
  23.       Begin VB.TextBox txtReason 
  24.          Height          =   735
  25.          Left            =   1200
  26.          MaxLength       =   255
  27.          MultiLine       =   -1  'True
  28.          ScrollBars      =   2  'Vertical
  29.          TabIndex        =   4
  30.          Text            =   "frmDispose.frx":0000
  31.          Top             =   1680
  32.          Width           =   4695
  33.       End
  34.       Begin VB.ComboBox cboMerchName 
  35.          Height          =   300
  36.          ItemData        =   "frmDispose.frx":000C
  37.          Left            =   1200
  38.          List            =   "frmDispose.frx":000E
  39.          Style           =   2  'Dropdown List
  40.          TabIndex        =   0
  41.          Top             =   300
  42.          Width           =   1815
  43.       End
  44.       Begin VB.TextBox txtCount 
  45.          Height          =   350
  46.          Left            =   1200
  47.          MaxLength       =   8
  48.          TabIndex        =   2
  49.          Text            =   "txtCount"
  50.          Top             =   1200
  51.          Width           =   1335
  52.       End
  53.       Begin VB.ComboBox cboUnit 
  54.          Height          =   300
  55.          ItemData        =   "frmDispose.frx":0010
  56.          Left            =   2760
  57.          List            =   "frmDispose.frx":0017
  58.          Style           =   2  'Dropdown List
  59.          TabIndex        =   3
  60.          Top             =   1230
  61.          Width           =   1335
  62.       End
  63.       Begin VB.TextBox txtRemark 
  64.          Height          =   735
  65.          Left            =   1200
  66.          MultiLine       =   -1  'True
  67.          ScrollBars      =   2  'Vertical
  68.          TabIndex        =   5
  69.          Text            =   "frmDispose.frx":0022
  70.          Top             =   2520
  71.          Width           =   4695
  72.       End
  73.       Begin MSComCtl2.DTPicker dtpRegDate 
  74.          Height          =   345
  75.          Left            =   1200
  76.          TabIndex        =   1
  77.          Top             =   735
  78.          Width           =   1815
  79.          _ExtentX        =   3201
  80.          _ExtentY        =   609
  81.          _Version        =   393216
  82.          Format          =   23068673
  83.          CurrentDate     =   38263
  84.       End
  85.       Begin VB.Label Label8 
  86.          AutoSize        =   -1  'True
  87.          Caption         =   "报损原因"
  88.          Height          =   180
  89.          Left            =   240
  90.          TabIndex        =   13
  91.          Top             =   1800
  92.          Width           =   720
  93.       End
  94.       Begin VB.Label Label7 
  95.          AutoSize        =   -1  'True
  96.          Caption         =   "报损数量"
  97.          Height          =   180
  98.          Left            =   240
  99.          TabIndex        =   12
  100.          Top             =   1320
  101.          Width           =   720
  102.       End
  103.       Begin VB.Label Label3 
  104.          AutoSize        =   -1  'True
  105.          Caption         =   "备注"
  106.          Height          =   180
  107.          Left            =   240
  108.          TabIndex        =   11
  109.          Top             =   2640
  110.          Width           =   360
  111.       End
  112.       Begin VB.Label Label1 
  113.          AutoSize        =   -1  'True
  114.          Caption         =   "报损商品"
  115.          Height          =   180
  116.          Left            =   240
  117.          TabIndex        =   10
  118.          Top             =   360
  119.          Width           =   720
  120.       End
  121.       Begin VB.Label Label5 
  122.          AutoSize        =   -1  'True
  123.          Caption         =   "统计时间"
  124.          Height          =   180
  125.          Left            =   240
  126.          TabIndex        =   9
  127.          Top             =   840
  128.          Width           =   720
  129.       End
  130.    End
  131.    Begin VB.CommandButton OKButton 
  132.       Caption         =   "确定"
  133.       Height          =   330
  134.       Left            =   3360
  135.       TabIndex        =   7
  136.       Top             =   3960
  137.       Width           =   1215
  138.    End
  139.    Begin VB.CommandButton CancelButton 
  140.       Caption         =   "取消"
  141.       Height          =   330
  142.       Left            =   4800
  143.       TabIndex        =   6
  144.       Top             =   3960
  145.       Width           =   1215
  146.    End
  147. End
  148. Attribute VB_Name = "frmDispose"
  149. Attribute VB_GlobalNameSpace = False
  150. Attribute VB_Creatable = False
  151. Attribute VB_PredeclaredId = True
  152. Attribute VB_Exposed = False
  153. Option Explicit
  154. Private OK As Boolean             '确定用户按了OK还是CANCEL按钮
  155. Private m_obj As clsDispose         '数据对象,用来存储用户输入数据
  156. Public m_ViewType As gxcViewType  '显示状态,指添加还是修改
  157. Private m_TypeId As Long
  158. Private m_Account As String       '调用此对话框的操作员
  159. '根据是“新增”还是修改,确定显示内容
  160. Private Sub SetStatus()
  161.   
  162.   '设置控件默认值
  163.   Call SetDefaultValue
  164.   
  165.   '设置状态
  166.   Select Case m_ViewType
  167.   Case vtadd    '添加
  168.     CancelButton.Visible = True
  169.     OKButton.Caption = "确定"
  170.   Case vtModify '修改
  171.     CancelButton.Visible = True
  172.     OKButton.Caption = "保存"
  173.   Case vtInfo   '查看
  174.     CancelButton.Visible = False
  175.     OKButton.Caption = "关闭"
  176.   End Select
  177. End Sub
  178. '打开对话框,并传出用户输入数据
  179. Public Function ShowDlg(ByRef obj As Object, _
  180.                         ByVal eViewType As gxcViewType, _
  181.                         Optional nTypeId As Long = -1, _
  182.                         Optional strUser As String = "") As Boolean
  183.   '保存数据
  184.   Set m_obj = obj         '用户输入数据存放于此对象中
  185.   m_ViewType = eViewType  '对话框状态
  186.   If nTypeId = -1 And (Not m_obj Is Nothing) Then
  187.     m_TypeId = m_obj.TypeId
  188.   Else
  189.     m_TypeId = nTypeId
  190.   End If
  191.   m_Account = strUser     '调用此对话框的用户账号
  192.   
  193.   
  194.   '根据新增、编辑或查看设置显示内容
  195.   SetStatus
  196.   
  197.   '显示对话框
  198.   OK = False
  199.   Me.Show vbModal
  200.   If OK = False Then
  201.     ShowDlg = False
  202.     Exit Function
  203.   End If
  204.   
  205.   '保存数据
  206.   Set obj = m_obj
  207.   
  208.   '返回并释放对话框
  209.   ShowDlg = True
  210.   Unload Me
  211.   
  212. End Function
  213. '设置控件默认值
  214. Private Sub SetDefaultValue()
  215.   Dim ctl As Control
  216.   Dim i As Integer
  217.   
  218.  
  219.  '如果是新增,则清空所有文本框
  220.  '此处判断 m_obj为空与判断m_ViewType = vtAdd等效,但更安全
  221.   If m_obj Is Nothing Then
  222.     For Each ctl In Controls
  223.       If TypeOf ctl Is TextBox Then
  224.         ctl.Text = ""
  225.       End If
  226.     Next
  227.   Else  '用传入对象的值更新数据
  228.     With m_obj
  229.       txtCount.Text = .Count
  230.       txtReason.Text = .Reason
  231.       txtRemark.Text = .Remark
  232.       cboUnit.ListIndex = 0
  233.       dtpRegDate.Value = .RegDate
  234.       For i = 0 To cboMerchName.ListCount - 1
  235.         If cboMerchName.ItemData(i) = .MerchandiseID Then
  236.           cboMerchName.ListIndex = i         '客户类型Id
  237.           Exit For
  238.         End If
  239.       Next i
  240.       
  241.     End With
  242.   End If
  243.   
  244. End Sub
  245. '检查输入有效性
  246. Private Function CheckValid() As Boolean
  247.   CheckValid = False
  248.     
  249.   If txtCount.Text = "" _
  250.     Or txtReason.Text = "" _
  251.     Or txtRemark.Text = "" Then
  252.     MsgBox "请填写完毕以上各项内容"
  253.     Exit Function
  254.   End If
  255.   If cboMerchName.Text = "" Then
  256.     MsgBox "请填写完毕以上各项内容"
  257.     Exit Function
  258.   End If
  259.   
  260.   If Not IsNumeric(txtCount.Text) Then
  261.     MsgBox "数量请输入数字"
  262.     Exit Function
  263.   End If
  264.   
  265.   If Not IsDate(dtpRegDate.Value) Then
  266.     MsgBox "请输入正确的日期格式"
  267.     Exit Function
  268.   End If
  269.   
  270.   CheckValid = True
  271.   
  272. End Function
  273. '保存数据
  274. Private Sub SaveValue()
  275.   '给“成员变量”对象赋值
  276.   With m_obj
  277.     '注意以下利用RealString函数替换去除输入中的单引号
  278.     .Count = txtCount.Text
  279.     .Reason = RealString(txtReason.Text)
  280.     .Remark = RealString(txtRemark.Text)
  281.     .MerchandiseID = cboMerchName.ItemData(cboMerchName.ListIndex)  '商品类型Id
  282.     .MerchName = cboMerchName.Text
  283.     .RegDate = dtpRegDate.Value
  284.     .OperatorId = m_Account   '操作者账号
  285.   End With
  286. End Sub
  287. '取消按钮
  288. Private Sub CancelButton_Click()
  289.   Unload Me
  290. End Sub
  291. Private Sub Form_Load()
  292.   Dim opMerch As New clsOpMerch
  293.   opMerch.FillCombo cboMerchName
  294. End Sub
  295. '确定按钮
  296. Private Sub OKButton_Click()
  297.   OK = True
  298.   
  299.   '检测输入有效性
  300.   If Not CheckValid Then Exit Sub
  301.   
  302.   '如果是新增状态,则初始化一个数据对象
  303.   If m_ViewType = vtadd Then Set m_obj = New clsDispose
  304.   
  305.   '保存用户输入
  306.   SaveValue
  307.   Me.Hide
  308.   
  309. End Sub