home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / Restaurant20246310122006.psc / frmCAddInvResep.frm < prev    next >
Text File  |  2002-02-11  |  28KB  |  875 lines

  1. VERSION 5.00
  2. Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
  3. Begin VB.Form frmCAddInvResep 
  4.    BackColor       =   &H00FFFFFF&
  5.    BorderStyle     =   3  'Fixed Dialog
  6.    Caption         =   "Penambahan Inventory Resep"
  7.    ClientHeight    =   4185
  8.    ClientLeft      =   45
  9.    ClientTop       =   330
  10.    ClientWidth     =   11355
  11.    ControlBox      =   0   'False
  12.    BeginProperty Font 
  13.       Name            =   "Tahoma"
  14.       Size            =   8.25
  15.       Charset         =   0
  16.       Weight          =   400
  17.       Underline       =   0   'False
  18.       Italic          =   0   'False
  19.       Strikethrough   =   0   'False
  20.    EndProperty
  21.    LinkTopic       =   "Form1"
  22.    MaxButton       =   0   'False
  23.    MinButton       =   0   'False
  24.    ScaleHeight     =   4185
  25.    ScaleWidth      =   11355
  26.    ShowInTaskbar   =   0   'False
  27.    StartUpPosition =   1  'CenterOwner
  28.    Begin VB.Frame fraFind 
  29.       BackColor       =   &H00FFFFFF&
  30.       BorderStyle     =   0  'None
  31.       Height          =   4095
  32.       Left            =   60
  33.       TabIndex        =   30
  34.       Top             =   60
  35.       Width           =   3435
  36.       Begin TabDlg.SSTab TabIndek 
  37.          Height          =   4035
  38.          Left            =   0
  39.          TabIndex        =   31
  40.          Top             =   0
  41.          Width           =   3345
  42.          _ExtentX        =   5900
  43.          _ExtentY        =   7117
  44.          _Version        =   393216
  45.          Tabs            =   2
  46.          Tab             =   1
  47.          TabsPerRow      =   2
  48.          TabHeight       =   520
  49.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  50.             Name            =   "MS Sans Serif"
  51.             Size            =   8.25
  52.             Charset         =   0
  53.             Weight          =   400
  54.             Underline       =   0   'False
  55.             Italic          =   0   'False
  56.             Strikethrough   =   0   'False
  57.          EndProperty
  58.          TabCaption(0)   =   "Indeks"
  59.          TabPicture(0)   =   "frmCAddInvResep.frx":0000
  60.          Tab(0).ControlEnabled=   0   'False
  61.          Tab(0).Control(0)=   "txtIndeks"
  62.          Tab(0).Control(1)=   "lstIndeks"
  63.          Tab(0).ControlCount=   2
  64.          TabCaption(1)   =   "Cari"
  65.          TabPicture(1)   =   "frmCAddInvResep.frx":001C
  66.          Tab(1).ControlEnabled=   -1  'True
  67.          Tab(1).Control(0)=   "lblLabels(11)"
  68.          Tab(1).Control(0).Enabled=   0   'False
  69.          Tab(1).Control(1)=   "lstCari"
  70.          Tab(1).Control(1).Enabled=   0   'False
  71.          Tab(1).Control(2)=   "cmdTampil"
  72.          Tab(1).Control(2).Enabled=   0   'False
  73.          Tab(1).Control(3)=   "cboBy"
  74.          Tab(1).Control(3).Enabled=   0   'False
  75.          Tab(1).Control(4)=   "txtCari"
  76.          Tab(1).Control(4).Enabled=   0   'False
  77.          Tab(1).ControlCount=   5
  78.          Begin VB.TextBox txtCari 
  79.             Height          =   315
  80.             Left            =   240
  81.             TabIndex        =   12
  82.             Top             =   1080
  83.             Width           =   2835
  84.          End
  85.          Begin VB.ComboBox cboBy 
  86.             Height          =   315
  87.             ItemData        =   "frmCAddInvResep.frx":0038
  88.             Left            =   240
  89.             List            =   "frmCAddInvResep.frx":0042
  90.             Style           =   2  'Dropdown List
  91.             TabIndex        =   11
  92.             Top             =   720
  93.             Width           =   2835
  94.          End
  95.          Begin VB.CommandButton cmdTampil 
  96.             Caption         =   "&Tampilkan"
  97.             Height          =   375
  98.             Left            =   240
  99.             TabIndex        =   13
  100.             Top             =   1440
  101.             Width           =   2835
  102.          End
  103.          Begin VB.ListBox lstCari 
  104.             Height          =   1815
  105.             ItemData        =   "frmCAddInvResep.frx":0080
  106.             Left            =   240
  107.             List            =   "frmCAddInvResep.frx":0087
  108.             TabIndex        =   14
  109.             Top             =   1860
  110.             Width           =   2835
  111.          End
  112.          Begin VB.TextBox txtIndeks 
  113.             Height          =   315
  114.             Left            =   -74760
  115.             TabIndex        =   0
  116.             Top             =   480
  117.             Width           =   2835
  118.          End
  119.          Begin VB.ListBox lstIndeks 
  120.             Height          =   2985
  121.             Left            =   -74760
  122.             TabIndex        =   1
  123.             Top             =   840
  124.             Width           =   2835
  125.          End
  126.          Begin VB.Label lblLabels 
  127.             AutoSize        =   -1  'True
  128.             BackStyle       =   0  'Transparent
  129.             Caption         =   "Berdasarkan"
  130.             BeginProperty Font 
  131.                Name            =   "Tahoma"
  132.                Size            =   8.25
  133.                Charset         =   0
  134.                Weight          =   700
  135.                Underline       =   0   'False
  136.                Italic          =   0   'False
  137.                Strikethrough   =   0   'False
  138.             EndProperty
  139.             Height          =   195
  140.             Index           =   11
  141.             Left            =   240
  142.             TabIndex        =   32
  143.             Top             =   480
  144.             Width           =   1080
  145.          End
  146.       End
  147.    End
  148.    Begin VB.Frame fraFields 
  149.       BackColor       =   &H00FFC0C0&
  150.       BorderStyle     =   0  'None
  151.       ForeColor       =   &H00000000&
  152.       Height          =   3195
  153.       Left            =   3480
  154.       TabIndex        =   15
  155.       Top             =   60
  156.       Width           =   7815
  157.       Begin VB.PictureBox Picture1 
  158.          BackColor       =   &H00FF8080&
  159.          BorderStyle     =   0  'None
  160.          Height          =   2475
  161.          Left            =   60
  162.          ScaleHeight     =   2475
  163.          ScaleWidth      =   7695
  164.          TabIndex        =   16
  165.          Top             =   660
  166.          Width           =   7695
  167.          Begin VB.TextBox txtFields 
  168.             Alignment       =   1  'Right Justify
  169.             BackColor       =   &H00E0E0E0&
  170.             DataField       =   "NilaiBuatAcc"
  171.             BeginProperty DataFormat 
  172.                Type            =   1
  173.                Format          =   "#,##0.00"
  174.                HaveTrueFalseNull=   0
  175.                FirstDayOfWeek  =   0
  176.                FirstWeekOfYear =   0
  177.                LCID            =   1033
  178.                SubFormatType   =   1
  179.             EndProperty
  180.             Height          =   315
  181.             Index           =   7
  182.             Left            =   3000
  183.             Locked          =   -1  'True
  184.             TabIndex        =   34
  185.             TabStop         =   0   'False
  186.             Text            =   "999,999,999.00"
  187.             Top             =   1740
  188.             Width           =   1455
  189.          End
  190.          Begin VB.TextBox txtFields 
  191.             BackColor       =   &H00E0E0E0&
  192.             DataField       =   "KodeBuat"
  193.             Height          =   315
  194.             Index           =   0
  195.             Left            =   3000
  196.             Locked          =   -1  'True
  197.             MaxLength       =   10
  198.             TabIndex        =   22
  199.             Text            =   "1234567890"
  200.             Top             =   300
  201.             Width           =   1215
  202.          End
  203.          Begin VB.TextBox txtFields 
  204.             Alignment       =   2  'Center
  205.             BackColor       =   &H00E0E0E0&
  206.             DataField       =   "Tanggal"
  207.             BeginProperty DataFormat 
  208.                Type            =   0
  209.                Format          =   "d-M-yyyy"
  210.                HaveTrueFalseNull=   0
  211.                FirstDayOfWeek  =   0
  212.                FirstWeekOfYear =   0
  213.                LCID            =   1033
  214.                SubFormatType   =   0
  215.             EndProperty
  216.             Height          =   315
  217.             Index           =   1
  218.             Left            =   5700
  219.             Locked          =   -1  'True
  220.             MaxLength       =   10
  221.             TabIndex        =   21
  222.             TabStop         =   0   'False
  223.             Text            =   "99/99/9999"
  224.             Top             =   300
  225.             Width           =   1215
  226.          End
  227.          Begin VB.TextBox txtFields 
  228.             BackColor       =   &H00E0E0E0&
  229.             DataField       =   "Karyawan"
  230.             Height          =   315
  231.             Index           =   2
  232.             Left            =   3000
  233.             Locked          =   -1  'True
  234.             TabIndex        =   20
  235.             Top             =   660
  236.             Width           =   1215
  237.          End
  238.          Begin VB.TextBox txtFields 
  239.             BackColor       =   &H00E0E0E0&
  240.             DataField       =   "NamaKaryawan"
  241.             Height          =   315
  242.             Index           =   3
  243.             Left            =   4260
  244.             Locked          =   -1  'True
  245.             TabIndex        =   19
  246.             TabStop         =   0   'False
  247.             Top             =   660
  248.             Width           =   2655
  249.          End
  250.          Begin VB.TextBox txtFields 
  251.             BackColor       =   &H00E0E0E0&
  252.             DataField       =   "NamaResep"
  253.             Height          =   315
  254.             Index           =   5
  255.             Left            =   4260
  256.             Locked          =   -1  'True
  257.             TabIndex        =   18
  258.             TabStop         =   0   'False
  259.             Top             =   1020
  260.             Width           =   2655
  261.          End
  262.          Begin VB.TextBox txtFields 
  263.             BackColor       =   &H00E0E0E0&
  264.             DataField       =   "Resep"
  265.             Height          =   315
  266.             Index           =   4
  267.             Left            =   3000
  268.             Locked          =   -1  'True
  269.             MaxLength       =   10
  270.             TabIndex        =   17
  271.             Top             =   1020
  272.             Width           =   1215
  273.          End
  274.          Begin VB.TextBox txtFields 
  275.             Alignment       =   1  'Right Justify
  276.             BackColor       =   &H00FFFFFF&
  277.             DataField       =   "JumlahAcc"
  278.             Height          =   315
  279.             Index           =   6
  280.             Left            =   3000
  281.             TabIndex        =   8
  282.             Top             =   1380
  283.             Width           =   675
  284.          End
  285.          Begin VB.Label lblInv 
  286.             AutoSize        =   -1  'True
  287.             BackStyle       =   0  'Transparent
  288.             Caption         =   "Total Nilai Penambahan"
  289.             ForeColor       =   &H00FFFFFF&
  290.             Height          =   195
  291.             Index           =   12
  292.             Left            =   1140
  293.             TabIndex        =   35
  294.             Top             =   1800
  295.             Width           =   1665
  296.          End
  297.          Begin VB.Label lblInv 
  298.             AutoSize        =   -1  'True
  299.             BackStyle       =   0  'Transparent
  300.             Caption         =   "Kode Pembuatan"
  301.             ForeColor       =   &H00FFFFFF&
  302.             Height          =   195
  303.             Index           =   0
  304.             Left            =   1140
  305.             TabIndex        =   28
  306.             Top             =   360
  307.             Width           =   1215
  308.          End
  309.          Begin VB.Label lblInv 
  310.             AutoSize        =   -1  'True
  311.             BackStyle       =   0  'Transparent
  312.             Caption         =   "Tanggal Buat"
  313.             ForeColor       =   &H00FFFFFF&
  314.             Height          =   195
  315.             Index           =   9
  316.             Left            =   4560
  317.             TabIndex        =   27
  318.             Top             =   360
  319.             Width           =   945
  320.          End
  321.          Begin VB.Label lblInv 
  322.             AutoSize        =   -1  'True
  323.             BackStyle       =   0  'Transparent
  324.             Caption         =   "Nama Karyawan"
  325.             ForeColor       =   &H00FFFFFF&
  326.             Height          =   195
  327.             Index           =   2
  328.             Left            =   1140
  329.             TabIndex        =   26
  330.             Top             =   720
  331.             Width           =   1170
  332.          End
  333.          Begin VB.Label lblInv 
  334.             AutoSize        =   -1  'True
  335.             BackStyle       =   0  'Transparent
  336.             Caption         =   "Nama Resep"
  337.             ForeColor       =   &H00FFFFFF&
  338.             Height          =   195
  339.             Index           =   1
  340.             Left            =   1140
  341.             TabIndex        =   25
  342.             Top             =   1080
  343.             Width           =   900
  344.          End
  345.          Begin VB.Label lblSatuan 
  346.             AutoSize        =   -1  'True
  347.             BackStyle       =   0  'Transparent
  348.             Caption         =   "Satuan"
  349.             DataField       =   "Satuan"
  350.             ForeColor       =   &H00FFFFFF&
  351.             Height          =   195
  352.             Left            =   3840
  353.             TabIndex        =   24
  354.             Top             =   1440
  355.             Width           =   510
  356.          End
  357.          Begin VB.Label lblInv 
  358.             AutoSize        =   -1  'True
  359.             BackStyle       =   0  'Transparent
  360.             Caption         =   "Jumlah penambahan"
  361.             ForeColor       =   &H00FFFFFF&
  362.             Height          =   195
  363.             Index           =   3
  364.             Left            =   1140
  365.             TabIndex        =   23
  366.             Top             =   1440
  367.             Width           =   1470
  368.          End
  369.       End
  370.       Begin VB.Label Label2 
  371.          AutoSize        =   -1  'True
  372.          BackStyle       =   0  'Transparent
  373.          Caption         =   "Penambahan Inventory Resep"
  374.          BeginProperty Font 
  375.             Name            =   "Times New Roman"
  376.             Size            =   15.75
  377.             Charset         =   0
  378.             Weight          =   400
  379.             Underline       =   0   'False
  380.             Italic          =   -1  'True
  381.             Strikethrough   =   0   'False
  382.          EndProperty
  383.          ForeColor       =   &H0000FFFF&
  384.          Height          =   345
  385.          Left            =   780
  386.          TabIndex        =   29
  387.          Top             =   180
  388.          Width           =   3825
  389.       End
  390.       Begin VB.Image Image2 
  391.          Height          =   570
  392.          Left            =   180
  393.          Picture         =   "frmCAddInvResep.frx":0094
  394.          Stretch         =   -1  'True
  395.          Top             =   60
  396.          Width           =   525
  397.       End
  398.       Begin VB.Shape Shape6 
  399.          BackColor       =   &H00800000&
  400.          BackStyle       =   1  'Opaque
  401.          Height          =   525
  402.          Left            =   60
  403.          Top             =   120
  404.          Width           =   7695
  405.       End
  406.    End
  407.    Begin VB.Frame Frame1 
  408.       BackColor       =   &H00FFFFFF&
  409.       BorderStyle     =   0  'None
  410.       Caption         =   "Frame1"
  411.       Height          =   795
  412.       Left            =   60
  413.       TabIndex        =   33
  414.       Top             =   3300
  415.       Width           =   11235
  416.       Begin VB.CommandButton cmdNext 
  417.          Caption         =   "&Maju"
  418.          Height          =   795
  419.          Left            =   5160
  420.          Picture         =   "frmCAddInvResep.frx":095E
  421.          Style           =   1  'Graphical
  422.          TabIndex        =   4
  423.          Top             =   0
  424.          Width           =   795
  425.       End
  426.       Begin VB.CommandButton cmdPrevious 
  427.          Caption         =   "M&undur"
  428.          Height          =   795
  429.          Left            =   4320
  430.          Picture         =   "frmCAddInvResep.frx":0C68
  431.          Style           =   1  'Graphical
  432.          TabIndex        =   3
  433.          Top             =   0
  434.          Width           =   795
  435.       End
  436.       Begin VB.CommandButton cmdFirst 
  437.          Caption         =   "&Pertama"
  438.          Height          =   795
  439.          Left            =   3480
  440.          Picture         =   "frmCAddInvResep.frx":0F72
  441.          Style           =   1  'Graphical
  442.          TabIndex        =   2
  443.          Top             =   0
  444.          Width           =   795
  445.       End
  446.       Begin VB.CommandButton cmdLast 
  447.          Caption         =   "&Terakhir"
  448.          Height          =   795
  449.          Left            =   6000
  450.          Picture         =   "frmCAddInvResep.frx":127C
  451.          Style           =   1  'Graphical
  452.          TabIndex        =   5
  453.          Top             =   0
  454.          Width           =   795
  455.       End
  456.       Begin VB.CommandButton cmdCancel 
  457.          Caption         =   "&Batal"
  458.          Height          =   795
  459.          Left            =   10380
  460.          Picture         =   "frmCAddInvResep.frx":1586
  461.          Style           =   1  'Graphical
  462.          TabIndex        =   10
  463.          Top             =   0
  464.          Visible         =   0   'False
  465.          Width           =   795
  466.       End
  467.       Begin VB.CommandButton cmdAdd 
  468.          Caption         =   "&Proses"
  469.          Height          =   795
  470.          Left            =   9540
  471.          Picture         =   "frmCAddInvResep.frx":1890
  472.          Style           =   1  'Graphical
  473.          TabIndex        =   6
  474.          Top             =   0
  475.          Width           =   795
  476.       End
  477.       Begin VB.CommandButton cmdClose 
  478.          Caption         =   "&Selesai"
  479.          Height          =   795
  480.          Left            =   10380
  481.          Picture         =   "frmCAddInvResep.frx":1B9A
  482.          Style           =   1  'Graphical
  483.          TabIndex        =   7
  484.          Top             =   0
  485.          Width           =   795
  486.       End
  487.       Begin VB.CommandButton cmdUpdate 
  488.          Caption         =   "&Setuju"
  489.          Height          =   795
  490.          Left            =   9540
  491.          Picture         =   "frmCAddInvResep.frx":1EA4
  492.          Style           =   1  'Graphical
  493.          TabIndex        =   9
  494.          Top             =   0
  495.          Visible         =   0   'False
  496.          Width           =   795
  497.       End
  498.    End
  499. End
  500. Attribute VB_Name = "frmCAddInvResep"
  501. Attribute VB_GlobalNameSpace = False
  502. Attribute VB_Creatable = False
  503. Attribute VB_PredeclaredId = True
  504. Attribute VB_Exposed = False
  505. Option Explicit
  506.  
  507. Dim WithEvents adoPrimaryRS As ADODB.Recordset
  508. Attribute adoPrimaryRS.VB_VarHelpID = -1
  509. Dim rsDetail As ADODB.Recordset
  510. Dim rsIndeks As ADODB.Recordset
  511. Dim rsCari As ADODB.Recordset
  512.  
  513. Dim PosisiRecord As Long
  514.  
  515. Dim mbChangedByCode As Boolean
  516. Dim mvBookMark As Variant
  517. Dim mbEditFlag As Boolean
  518. Dim mbAddNewFlag As Boolean
  519. Dim mbDataChanged As Boolean
  520.  
  521. Private Sub StatusFrame(bolStatus As Boolean)
  522.   '
  523.   Picture1.Enabled = bolStatus
  524.   fraFind.Enabled = Not bolStatus
  525.   '
  526. End Sub
  527.  
  528. Private Sub Form_Load()
  529.   '
  530.   sFormAktif = Me.Name
  531.   Set adoPrimaryRS = New ADODB.Recordset
  532.   adoPrimaryRS.Open "Select * from [C_BuatResepSpesial] Order by KodeBuat", db, adOpenStatic, adLockOptimistic
  533.   
  534.   Dim oText As TextBox
  535.   For Each oText In Me.txtFields
  536.     Set oText.DataSource = adoPrimaryRS
  537.   Next
  538.   Set lblSatuan.DataSource = adoPrimaryRS
  539.   '
  540.   RefreshIndeks
  541.   lstCari.Clear
  542.   TabIndek.Tab = 0
  543.   '
  544.   StatusFrame False
  545.   '
  546.   mbDataChanged = False
  547. End Sub
  548.  
  549. Private Sub Form_Unload(Cancel As Integer)
  550.   '
  551.   Screen.MousePointer = vbDefault
  552.   '
  553.   adoPrimaryRS.Close
  554.   Set adoPrimaryRS = Nothing
  555.   '
  556. End Sub
  557.  
  558. Private Sub cmdAdd_Click()
  559.   'On Error GoTo EditErr
  560.   '
  561.   If adoPrimaryRS.RecordCount = 0 Then
  562.     MsgBox "Data Permintaan Pembuatan Resep yang telah disetujui kosong", vbCritical
  563.     Exit Sub
  564.   End If
  565.   If adoPrimaryRS!NeedTransfer = False Then
  566.     MsgBox "Data Penambahan Inventory Resep telah diproses", vbInformation
  567.     Exit Sub
  568.   End If
  569.   
  570.   mvBookMark = adoPrimaryRS.Bookmark
  571.   StatusFrame True
  572.   txtFields(6).Text = adoPrimaryRS!Jumlah
  573.   '
  574.   db.BeginTrans
  575.   mbEditFlag = True
  576.   SetButtons False
  577.   '
  578.   Exit Sub
  579.  
  580. EditErr:
  581.   MsgBox Err.Description
  582. End Sub
  583.  
  584. Private Sub cmdUpdate_Click()
  585.   On Error GoTo UpdateErr
  586.  
  587.   adoPrimaryRS!JumlahAcc = txtFields(6).Text
  588.   adoPrimaryRS!NeedTransfer = False
  589.   adoPrimaryRS.UpdateBatch adAffectAll
  590.   '
  591.   ' Update StockCard Resep
  592.   Dim rsStockCardResep As New ADODB.Recordset
  593.   rsStockCardResep.Open "C_IStockCard", db, adOpenStatic, adLockOptimistic
  594.   rsStockCardResep.AddNew
  595.   rsStockCardResep!Tanggal = txtFields(1).Text
  596.   rsStockCardResep!Inventory = txtFields(4).Text
  597.   rsStockCardResep!NamaInventory = txtFields(5).Text
  598.   rsStockCardResep!PI = txtFields(0).Text
  599.   rsStockCardResep!JumlahPI = txtFields(6).Text
  600.   rsStockCardResep!SatuanBesar = lblSatuan.Caption
  601.   rsStockCardResep!Keterangan = "Penambahan Inventory Resep"
  602.   If txtFields(6).Text = 0 Then
  603.     rsStockCardResep!UnitMasuk = 0
  604.     rsStockCardResep!Harga = 0
  605.   Else
  606.     rsStockCardResep!Harga = CCur(txtFields(7).Text / txtFields(6).Text)
  607.     rsStockCardResep!UnitMasuk = txtFields(6).Text
  608.   End If
  609.   rsStockCardResep!HargaSubTotal = txtFields(7).Text
  610.   rsStockCardResep.Update
  611.   rsStockCardResep.Close
  612.   Set rsStockCardResep = Nothing
  613.   
  614.   ' Update File Inventory Resep
  615.   Dim rsItemInventory As New ADODB.Recordset
  616.   Dim StockMin, QtyOnHandKecilBaru As Single
  617.   rsItemInventory.Open "C_Inventory", db, adOpenStatic, adLockOptimistic
  618.   rsItemInventory.Find "Inventory='" & txtFields(4).Text & "'"
  619.   '
  620.   StockMin = rsItemInventory!ReorderLevel
  621.   QtyOnHandKecilBaru = rsItemInventory!QtyOnHandKecil + txtFields(6).Text
  622.   '
  623.   rsItemInventory!QtyOnHandKecil = QtyOnHandKecilBaru
  624.   rsItemInventory!JumlahItem = rsItemInventory!JumlahItem + txtFields(6).Text
  625.   rsItemInventory!LastInvoiceDate = txtFields(1).Text
  626.   rsItemInventory.Update
  627.   rsItemInventory.Close
  628.   Set rsItemInventory = Nothing
  629.   '
  630.   ' Update Stock Alert
  631.   If QtyOnHandKecilBaru > StockMin Then
  632.     ' Hapus Item di File Stock Alert
  633.     db.Execute "DELETE From [C_StockAlert] Where Inventory='" & txtFields(4).Text & "'"
  634.   Else
  635.     db.Execute "UPDATE [C_StockAlert] SET QtyOnHand =" & QtyOnHandKecilBaru & " Where Inventory='" & txtFields(4).Text & "'"
  636.   End If
  637.     
  638.   db.CommitTrans
  639.  
  640.   sPesan = "Pembuatan Resep dengan Kode " & txtFields(0).Text & vbCrLf
  641.   sPesan = sPesan & "telah ditambahkan dalam Inventory"
  642.   MsgBox sPesan, vbInformation
  643.   
  644.   If mbAddNewFlag Then
  645.     adoPrimaryRS.MoveLast              'move to the new record
  646.   End If
  647.  
  648.   mbEditFlag = False
  649.   mbAddNewFlag = False
  650.   SetButtons True
  651.   mbDataChanged = False
  652.   
  653.   RefreshIndeks
  654.   StatusFrame False
  655.   Exit Sub
  656.   '
  657. UpdateErr:
  658.   MsgBox Err.Description, vbCritical
  659. End Sub
  660.  
  661. Private Sub cmdCancel_Click()
  662.   On Error Resume Next
  663.  
  664.   SetButtons True
  665.   mbEditFlag = False
  666.   mbAddNewFlag = False
  667.   adoPrimaryRS.CancelUpdate
  668.   adoPrimaryRS.Requery
  669.   If mvBookMark > 0 Then
  670.     adoPrimaryRS.Bookmark = mvBookMark
  671.   Else
  672.     adoPrimaryRS.MoveFirst
  673.   End If
  674.   '
  675.   db.RollbackTrans
  676.   '
  677.   RefreshIndeks
  678.   StatusFrame False
  679.   mbDataChanged = False
  680.   '
  681. End Sub
  682.  
  683. Private Sub cmdClose_Click()
  684.   Unload Me
  685. End Sub
  686.  
  687. Private Sub cmdFirst_Click()
  688.   On Error Resume Next
  689.   '
  690.   adoPrimaryRS.MoveFirst
  691.   mbDataChanged = False
  692. End Sub
  693.  
  694. Private Sub cmdLast_Click()
  695.   On Error Resume Next
  696.   '
  697.   adoPrimaryRS.MoveLast
  698.   mbDataChanged = False
  699. End Sub
  700.  
  701. Private Sub cmdNext_Click()
  702.   On Error Resume Next
  703.   '
  704.   If Not adoPrimaryRS.EOF Then adoPrimaryRS.MoveNext
  705.   If adoPrimaryRS.EOF And adoPrimaryRS.RecordCount > 0 Then
  706.     Beep
  707.      'moved off the end so go back
  708.     adoPrimaryRS.MoveLast
  709.   End If
  710.   'show the current record
  711.   mbDataChanged = False
  712. End Sub
  713.  
  714. Private Sub cmdPrevious_Click()
  715.   On Error Resume Next
  716.  
  717.   If Not adoPrimaryRS.BOF Then adoPrimaryRS.MovePrevious
  718.   If adoPrimaryRS.BOF And adoPrimaryRS.RecordCount > 0 Then
  719.     Beep
  720.     'moved off the end so go back
  721.     adoPrimaryRS.MoveFirst
  722.   End If
  723.   'show the current record
  724.   mbDataChanged = False
  725. End Sub
  726.  
  727. Private Sub SetButtons(bVal As Boolean)
  728.   cmdAdd.Visible = bVal
  729.   cmdUpdate.Visible = Not bVal
  730.   cmdCancel.Visible = Not bVal
  731.   cmdClose.Visible = bVal
  732.   cmdNext.Enabled = bVal
  733.   cmdFirst.Enabled = bVal
  734.   cmdLast.Enabled = bVal
  735.   cmdPrevious.Enabled = bVal
  736. End Sub
  737.  
  738. Private Sub RefreshIndeks()
  739.   '
  740.   PosisiRecord = adoPrimaryRS.AbsolutePosition
  741.   '
  742.   Set rsIndeks = New ADODB.Recordset
  743.   rsIndeks.Open "Select KodeBuat FROM [C_BuatResepSpesial]", db, adOpenStatic, adLockOptimistic
  744.   Indeks
  745.   '
  746. End Sub
  747.  
  748. Private Sub Indeks()
  749.   '
  750.   On Error Resume Next
  751.   '
  752.   lstIndeks.Clear
  753.   Me.MousePointer = vbHourglass
  754.   '
  755.   Do While Not rsIndeks.EOF
  756.     lstIndeks.AddItem rsIndeks!KodeBuat
  757.     rsIndeks.MoveNext
  758.   Loop
  759.   
  760.   If PosisiRecord = 0 Then PosisiRecord = 1
  761.   lstIndeks.Selected(PosisiRecord - 1) = True
  762.   Me.MousePointer = vbDefault
  763.   '
  764. End Sub
  765.  
  766. Private Sub Cari()
  767.   '
  768.   On Error Resume Next
  769.   '
  770.   lstCari.Clear
  771.   Me.MousePointer = vbHourglass
  772.   '
  773.   Do While Not rsCari.EOF
  774.     lstCari.AddItem rsCari!KodeBuat
  775.     rsCari.MoveNext
  776.   Loop
  777.   Me.MousePointer = vbDefault
  778.   '
  779. End Sub
  780.  
  781. Private Sub txtIndeks_Change()
  782.   '
  783.   Set rsIndeks = New ADODB.Recordset
  784.   rsIndeks.Open "Select KodeBuat FROM [C_BuatResepSpesial] WHERE KodeBuat LIKE '%" & txtIndeks.Text & "%'", db, adOpenStatic, adLockOptimistic
  785.   Indeks
  786.   '
  787. End Sub
  788.  
  789. Private Sub lstIndeks_KeyPress(KeyAscii As Integer)
  790.   '
  791.   If KeyAscii = 13 Then
  792.     lstIndeks_Click
  793.   End If
  794.   '
  795. End Sub
  796.  
  797. Private Sub lstIndeks_KeyUp(KeyCode As Integer, Shift As Integer)
  798.   Select Case KeyCode
  799.     Case vbKeyUp, vbKeyDown, vbKeyPageUp, vbKeyPageDown
  800.       lstIndeks_Click
  801.   End Select
  802. End Sub
  803.  
  804. Private Sub lstIndeks_Click()
  805.   On Error GoTo Handler
  806.   '
  807.   adoPrimaryRS.MoveFirst
  808.   adoPrimaryRS.Find "KodeBuat ='" & lstIndeks.Text & "'"
  809.   Exit Sub
  810.   
  811. Handler:
  812.   MsgBox Err.Description
  813. End Sub
  814.  
  815. Private Sub cmdTampil_Click()
  816.   '
  817.   If cboBy.ListIndex = -1 Then
  818.     MsgBox "Tentukan kriteria pencarian terlebih dahulu", vbInformation
  819.     cboBy.SetFocus
  820.     Exit Sub
  821.   End If
  822.   '
  823.   Set rsCari = New ADODB.Recordset
  824.   Select Case cboBy.ListIndex
  825.     Case 0
  826.       rsCari.Open "Select * FROM [C_BuatResepSpesial] WHERE KodeBuat LIKE '%" & txtCari.Text & "%' and NeedTransfer=True Order By KodeBuat", db, adOpenStatic, adLockOptimistic
  827.     Case 1
  828.       rsCari.Open "Select * FROM [C_BuatResepSpesial] WHERE KodeBuat LIKE '%" & txtCari.Text & "%' and NeedTransfer=false Order By KodeBuat", db, adOpenStatic, adLockOptimistic
  829.   End Select
  830.   '
  831.   Cari
  832.   rsCari.Close
  833.   '
  834. End Sub
  835.  
  836. Private Sub txtCari_KeyPress(KeyAscii As Integer)
  837.   '
  838.   If KeyAscii = 13 Then
  839.     cmdTampil_Click
  840.     lstCari.SetFocus
  841.   End If
  842.   '
  843. End Sub
  844.  
  845. Private Sub cboBy_Change()
  846.   '
  847.   txtCari.Text = ""
  848.   txtCari.SetFocus
  849.   '
  850. End Sub
  851.  
  852. Private Sub cboBy_KeyPress(KeyAscii As Integer)
  853.   SendKeys "{TAB}"
  854. End Sub
  855.  
  856. Private Sub lstCari_Click()
  857.   '
  858.   On Error GoTo Handler
  859.   '
  860.   adoPrimaryRS.MoveFirst
  861.   adoPrimaryRS.Find "KodeBuat ='" & lstCari.Text & "'"
  862.   Exit Sub
  863.  
  864. Handler:
  865.   MsgBox Err.Description
  866.   '
  867. End Sub
  868.  
  869. Private Sub lstCari_KeyUp(KeyCode As Integer, Shift As Integer)
  870.   Select Case KeyCode
  871.     Case vbKeyUp, vbKeyDown, vbKeyPageUp, vbKeyPageDown
  872.       lstCari_Click
  873.   End Select
  874. End Sub
  875.