壹佰网|ERP100 - 企业信息化知识门户

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9786|回复: 1

發一段代碼,此代碼是客制訂單建議輸入,供應商搜索.

[复制链接]
发表于 2010/12/3 12:07:10 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622  。

您需要 登录 才可以下载或查看,没有帐号?注册

x

'//**************************************************
'// Custom VB.NET code for POSuggEntryForm
'// Created: 9/3/2010 12:51:14 PM
'//**************************************************
Imports System
Imports System.Data
Imports System.Diagnostics
Imports System.Windows.Forms
Imports System.ComponentModel
Imports Microsoft.VisualBasic
Imports Epicor.Mfg.UI
Imports Epicor.Mfg.UI.FrameWork
Imports Epicor.Mfg.UI.ExtendedProps
Imports Epicor.Mfg.UI.FormFunctions
Imports Epicor.Mfg.UI.Customization
Imports Epicor.Mfg.UI.Adapters
Imports Epicor.Mfg.UI.Searches
Imports Epicor.Mfg.BO


Module Script
    Private Frm As EpiForm
    Private Tbl As DataTable
    Private TempDataSet As DataSet
    Private txtSupplierReDefine  As EpiTextBox
    Private frm_txtSupplier As EpiTextBox
    Private VendorNameText As epiTextBox
    Private VendorDetail As EpiUltraGrid
    Private VendorDv As DataView
    Private RowIndex As Integer
   
'// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **

'// Begin Wizard Added Module Level Variables **


Private  WithEvents SugPoDtl_DataView As DataView

'// End Wizard Added Module Level Variables **

'// Add Custom Module Level Variables Here **




Sub InitializeCustomCode()
       txtSupplierReDefine = CType(csm.GetNativeControlReference("af558e88-6fa3-483c-a11d-defbb7b5b104"),EpiTextBox)
       TempDataSet= New DataSet()
       ChangenewFormBtnAttr()
       VendorNameText = New EpiTextBox

'// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **

'// Begin Wizard Added Variable Initialization


SugPoDtl_DataView = SugPoDtl_Row.dataView

AddHandler SugPoDtl_DataView.ListChanged, AddressOf SugPoDtl_DataView_ListChanged

AddHandler MtlSug_Row.EpiRowChanged, AddressOf MtlSug_AfterRowChange

'// End Wizard Added Variable Initialization

'// Begin Wizard Added Custom Method Calls


AddHandler newForm.Click, AddressOf Script.newForm_Click

'// End Wizard Added Custom Method Calls
        CreateTempTable()

End Sub




Sub DestroyCustomCode()



'// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **

'// Begin Wizard Added Object Disposal


RemoveHandler newForm.Click, AddressOf Script.newForm_Click

RemoveHandler SugPoDtl_DataView.ListChanged, AddressOf SugPoDtl_DataView_ListChanged

SugPoDtl_DataView = Nothing

RemoveHandler MtlSug_Row.EpiRowChanged, AddressOf MtlSug_AfterRowChange

'// End Wizard Added Object Disposal

'// Begin Custom Code Disposal


'// End Custom Code Disposal


End Sub

    Private Sub ChangenewFormBtnAttr()
        Dim edvGlbVendor As EpiDataView
        edvGlbVendor = CType(oTrans.EpiDataViews("MtlSug"), EpiDataView)
        If edvGlbVendor.DataView.Table.Rows.Count>0 Then
            newForm.Enabled = True
        Else
            newForm.Enabled = False
        End If
    End Sub


Private Sub newForm_Click(ByVal sender As Object, ByVal args As System.EventArgs)

' ** Place Event Handling Code Here **

'Dim frm As Form= new Form()
        'Dim frm As Form = New Form()
        'Create Form
        Try
         Frm = New EpiForm
         frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
         frm.MaximizeBox = False
         frm.MinimizeBox = False
REM         '---------------------         
         Dim VendorNameLabel As New epiLabel
             VendorNameLabel.Text = "供应商:"
             VendorNameLabel.Size = New   System.Drawing.Size(77,20)
             VendorNameLabel.Location   =   new   System.Drawing.Point(19,5)

             VendorNameText.Size = New System.Drawing.Size(150,25)
             VendorNameText.Location = New System.Drawing.Point(102,5)

        Dim SearchBtn As New epiButton
             SearchBtn.Text = "搜索"
             SearchBtn.Location = New System.Drawing.Point(280,5)
             SearchBtn.Size = New System.Drawing.Size(120,25)

         Dim Grp1 As New epiGroupBox
             Grp1.Dock = System.Windows.Forms.DockStyle.Top
             Grp1.size=New System.Drawing.Size(302,40)
             Grp1.Location = New System.Drawing.Point(0,0)
             Grp1.TabIndex = 1
             Grp1.Controls.Add(VendorNameLabel)
             Grp1.Controls.Add(VendorNameText)
             Grp1.Controls.Add(SearchBtn)

REM            
REM                  
REM            
             VendorDetail = New EpiUltraGrid()
             VendorDetail.Dock=System.Windows.Forms.DockStyle.bottom
             VendorDetail.size=New System.Drawing.Size(302,400)
             VendorDetail.ReadOnly = True
             VendorDetail.DisplayLayout.Override.AllowUpdate=false
             VendorDetail.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect
REM
          Dim Grp2 As New epiGroupBox
              Grp2.Dock = System.Windows.Forms.DockStyle.Fill
              Grp2.size=New System.Drawing.Size(302,380)
              Grp2.Location = New System.Drawing.Point(0,0)
              Grp2.Text = "供应商列表"
              Grp2.TabIndex = 2
              Grp2.Controls.Add(VendorDetail)
REM REM            
         AddHandler SearchBtn.Click,AddressOf SearchBtn_Click
         AddHandler VendorNameText.KeyPress,AddressOf   VendorNameText_KeyPress
         AddHandler frm.load,AddressOf frm_load
         Addhandler VendorDetail.DoubleClickRow,AddressOf VendorDetail_DoubleClickRow

         Dim Status As  System.Windows.Forms.StatusStrip = New System.Windows.Forms.StatusStrip()
         Status.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow
         Status.TabIndex = 0
REM      
         frm.Controls.Add(Grp1)
         frm.Controls.Add(Grp2)
         frm.Controls.Add(Status)
         frm.text = "供应商查询"
         frm.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
         frm.size = New System.Drawing.Size(600,500)
         frm.Location = New System.Drawing.Point(102,54)

frm.ShowDialog()
        Catch ex as exception
            EpiMessageBox.Show(ex.message)
        End Try

End Sub
   Private Sub ChangeGridCaption()
        Dim CaptionStr As String() = {"供应商编码","供应商名称","供应商电话","供应商编号"}
        Dim i As integer
        For i = 0 To CaptionStr.Length - 1
           VendorDetail.DisplayLayout.Bands(0).Columns(i).Header.Caption = CaptionStr(i)
           VendorDetail.DisplayLayout.Bands(0).Columns(i).Width = 100
        Next i
        VendorDetail.DisplayLayout.Bands(0).Columns(1).Width = 300
    End Sub
   Sub SearchBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
            TempDataSet.Tables(0).Rows.Clear()
            Dim recSelected As Boolean
            Dim whereClause As String = "(Name MATCHES('*"& VendorNameText.Text & "*')) Or (VendorId MATCHES ('*" & VendorNameText.Text & "*'))"
            Dim dsVendorAdapter As System.Data.DataSet = Epicor.Mfg.UI.FormFunctions.SearchFunctions.listLookup(oTrans, "VendorAdapter", recSelected, False, whereClause)
            If [dsVendorAdapter].Tables(0).Rows.Count>0 Then
            Dim Row As DataRow
            For Each Row In [dsVendorAdapter].Tables(0).Rows
                Dim NewRow As DataRow
                NewRow = TempDataSet.Tables(0).newRow()
                NewRow("VendorID") = Row("VendorID")
                NewRow("VendorName") = Row("Name")
                NewRow("VendorNum") = Row("VendorNum")
                NewRow("PhoneNum") = Row("PhoneNum")
                TempDataSet.Tables(0).Rows.Add(NewRow)
            Next Row
            VendorDV = New DataView(TempDataSet.Tables(0))
            VendorDetail.DataSource = VendorDv               
            End If
            ChangeGridCaption()               
    End Sub
    Sub VendorDetail_DoubleClickRow(ByVal sender As Object, ByVal args As Infragistics.Win.UltraWinGrid.DoubleClickRowEventArgs)
        txtSupplierReDefine.Text = VendorDetail.Rows(VendorDetail.ActiveRow.Index).Cells("VendorId").Value
        Dim edvGlbVendor As EpiDataView
        edvGlbVendor = CType(oTrans.EpiDataViews("MtlSug"), EpiDataView)
        edvGlbVendor.DataView.Table.Rows(RowIndex)("VendorID") = VendorDetail.Rows(VendorDetail.ActiveRow.Index).Cells("VendorId").Value
        edvGlbVendor.DataView.table.Rows(RowIndex)("VendorNum")=VendorDetail.Rows(VendorDetail.ActiveRow.Index).Cells("Vendornum").Value
        frm.Close()
    End Sub

    Sub Frm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
            TempDataSet.Tables(0).Rows.Clear()
            Dim recSelected As Boolean
            Dim whereClause As String = String.Empty
            Dim dsVendorAdapter As System.Data.DataSet = Epicor.Mfg.UI.FormFunctions.SearchFunctions.listLookup(oTrans, "VendorAdapter", recSelected, False, whereClause)
            If [dsVendorAdapter].Tables(0).Rows.Count>0 Then
            Dim Row As DataRow
            For Each Row In [dsVendorAdapter].Tables(0).Rows
                Dim NewRow As DataRow
                NewRow = TempDataSet.Tables(0).newRow()
                NewRow("VendorID") = Row("VendorID")
                NewRow("VendorName") = Row("Name")
                NewRow("VendorNum") = Row("VendorNum")
                NewRow("PhoneNum") = Row("PhoneNum")
                TempDataSet.Tables(0).Rows.Add(NewRow)
            Next Row
            VendorDV = New DataView(TempDataSet.Tables(0))
            'VendorDv = New DataView(dsVendorAdapter.Tables(0))
            VendorDetail.DataSource = VendorDv
            End If
        ChangeGridCaption()

    End Sub
    Sub VendorNameText_KeyPress(ByVal sender As Object,ByVal e As System.Windows.Forms.KeyPressEventArgs)
        If e.KeyChar = Chr(13) Then
            TempDataSet.Tables(0).Rows.Clear()
            Dim recSelected As Boolean
            Dim whereClause As String = "(Name MATCHES('*" & CType(sender,epiTextBox).Text & "*')) Or (VendorId MATCHES ('*" & CType(sender,epiTextBox).Text & "*'))"
            Dim dsVendorAdapter As System.Data.DataSet = Epicor.Mfg.UI.FormFunctions.SearchFunctions.listLookup(oTrans, "VendorAdapter", recSelected, False, whereClause)
            If [dsVendorAdapter].Tables(0).Rows.Count>0 Then
            Dim Row As DataRow
            For Each Row In [dsVendorAdapter].Tables(0).Rows
                Dim NewRow As DataRow
                NewRow = TempDataSet.Tables(0).newRow()
                NewRow("VendorID") = Row("VendorID")
                NewRow("VendorName") = Row("Name")
                NewRow("VendorNum") = Row("VendorNum")
                NewRow("PhoneNum") = Row("PhoneNum")
                TempDataSet.Tables(0).Rows.Add(NewRow)
            Next Row
            VendorDV = New DataView(TempDataSet.Tables(0))
            VendorDetail.DataSource = VendorDv               
            End If
            ChangeGridCaption()
        End If      
    End Sub

    Private Sub CreateTempTable()
        Dim TempTable As DataTable = New DataTable
        Dim Column As DataColumn
            TempTable.Columns.Add(New DataColumn("VendorID",GetType(String)))
            TempTable.Columns.Add(New DataColumn("VendorName",GetType(String)))
            TempTable.Columns.Add(New DataColumn("PhoneNum",GetType(String)))
            TempTable.Columns.Add(New DataColumn("Vendornum",GetType(integer)))
        For Each Column In TempTable.Columns
            Column.ReadOnly = True
        Next Column
        TempDataSet.Tables.Add(TempTable)
    End Sub


Private Sub SugPoDtl_DataView_ListChanged(ByVal sender As Object, ByVal args As ListChangedEventArgs)

ChangenewFormBtnAttr()

End Sub



Private Sub MtlSug_AfterRowChange(ByVal args As EpiRowChangedArgs)

'** Argument Properties and Uses **

'args.CurrentView.dataView(args.CurrentRow)("[FieldName]")

'args.LastRow, args.CurrentRow, args.CurrentView

'Add Event Handler Code
        RowIndex=args.CurrentRow

End Sub


End Module


发表于 2010/12/31 16:40:57 | 显示全部楼层
精神可嘉,学习
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|手机版|壹佰网 ERP100 ( 京ICP备19053597号-2 )

Copyright © 2005-2012 北京海之大网络技术有限责任公司 服务器托管由互联互通
手机:13911575376
网站技术点击发送消息给对方83569622   广告&合作 点击发送消息给对方27675401   点击发送消息给对方634043306   咨询及人才点击发送消息给对方138011526

GMT+8, 2025/11/29 02:05 , Processed in 0.012843 second(s), 14 queries , File On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表