Advertisement
Guest User

Untitled

a guest
Jul 10th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 8.19 KB | None | 0 0
  1. Imports CrystalDecisions.CrystalReports.Engine
  2. Imports CrystalDecisions.Shared
  3.  
  4. Public Class rptStockPickingNote
  5.  
  6.     Private Sub rptStockPickingNote_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  7.         BindCombobox(cboItemSubCategoryFrom, "SUBCATEGORY", "SUBCATEGORY", "SELECT SUBCATEGORY, DESP FROM SUBCATEGORY ORDER BY SUBCATEGORY")
  8.         BindCombobox(cboItemSubCategoryTo, "SUBCATEGORY", "SUBCATEGORY", "SELECT SUBCATEGORY, DESP FROM SUBCATEGORY ORDER BY SUBCATEGORY")
  9.         'BindCombobox(cboStatus, "ITEMCONFIRMFLAG", "ITEMCONFIRMFLAG", "SELECT DISTINCT ITEMCONFIRMFLAG FROM SPNDTL(NOLOCK)")
  10.         BindCombobox(cboStatus, "YESNOVALUE", "YESNODESC", "SELECT 'Y' AS YESNOVALUE, 'Y' AS YESNODESC UNION ALL SELECT 'N' AS YESNOVALUE, 'N or E' AS YESNODESC")
  11.         ClearFields()
  12.     End Sub
  13.  
  14.     Private Sub ClearFields()
  15.         dtpSPNDateFrom.Value = DateAdd(DateInterval.Month, -1, Now.Date)
  16.         dtpSPNDateTo.Value = Date.Now
  17.         txtFromItem.Text = ""
  18.         txtToItem.Text = ""
  19.         rdbReportDetail.Checked = True
  20.         rdbSortSPN.Checked = True
  21.     End Sub
  22.  
  23.     Private Function ChkValid() As Boolean
  24.         Dim strMsg As String = ""
  25.         ChkValid = False
  26.  
  27.         If dtpSPNDateFrom.Value > dtpSPNDateTo.Value Then
  28.             strMsg = strMsg & "From SPN Date cannot greater than To SPN Date." & vbCrLf
  29.         End If
  30.  
  31.         If txtFromItem.Text <> "" Then
  32.             If CheckIsExist("ITEM", "ITEMNO = " & CSql(txtFromItem.Text)) = False Then
  33.                 strMsg = strMsg & "Invalid From Item #." & vbCrLf
  34.             End If
  35.         End If
  36.  
  37.         If txtToItem.Text <> "" Then
  38.             If CheckIsExist("ITEM", "ITEMNO = " & CSql(txtToItem.Text)) = False Then
  39.                 strMsg = strMsg & "Invalid To Item #." & vbCrLf
  40.             End If
  41.         End If
  42.  
  43.         If strMsg <> "" Then
  44.             DisplayMessage(strMsg, "")
  45.             ChkValid = False
  46.         Else
  47.             ChkValid = True
  48.         End If
  49.         Return ChkValid
  50.     End Function
  51.  
  52.     Private Sub btnFromItem_Click(sender As Object, e As EventArgs) Handles btnFromItem.Click
  53.         With frmPopUpMasterK
  54.             .txtTable.Text = "ITEM"
  55.             .txtForm.Text = Me.Name
  56.             .txtField.Text = "F"
  57.             .BindGrid()
  58.             .BringToFront()
  59.             .Show()
  60.         End With
  61.     End Sub
  62.  
  63.     Private Sub btnToItem_Click(sender As Object, e As EventArgs) Handles btnToItem.Click
  64.         With frmPopUpMasterK
  65.             .txtTable.Text = "ITEM"
  66.             .txtForm.Text = Me.Name
  67.             .txtField.Text = "T"
  68.             .BindGrid()
  69.             .BringToFront()
  70.             .Show()
  71.         End With
  72.     End Sub
  73.  
  74.     Private Sub dtpSPNDateFrom_KeyDown(sender As Object, e As KeyEventArgs) Handles dtpSPNDateFrom.KeyDown
  75.         SetNextFocusManual(e, dtpSPNDateTo)
  76.     End Sub
  77.  
  78.     Private Sub dtpSPNDateFrom_KeyPress(sender As Object, e As KeyPressEventArgs) Handles dtpSPNDateFrom.KeyPress
  79.         e.KeyChar = Chr(KeyAscCode(Asc(e.KeyChar)))
  80.     End Sub
  81.  
  82.     Private Sub dtpSPNDateTo_KeyDown(sender As Object, e As KeyEventArgs) Handles dtpSPNDateTo.KeyDown
  83.         SetNextFocusManual(e, txtFromItem)
  84.     End Sub
  85.  
  86.     Private Sub dtpSPNDateTo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles dtpSPNDateFrom.KeyPress
  87.         e.KeyChar = Chr(KeyAscCode(Asc(e.KeyChar)))
  88.     End Sub
  89.  
  90.     Private Sub txtFromItem_KeyDown(sender As Object, e As KeyEventArgs) Handles txtFromItem.KeyDown
  91.         SetNextFocusManual(e, txtToItem)
  92.     End Sub
  93.  
  94.     Private Sub txtFromItem_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtFromItem.KeyPress
  95.         e.KeyChar = Chr(KeyAscCode(Asc(e.KeyChar)))
  96.     End Sub
  97.  
  98.     Private Sub txtToItem_KeyDown(sender As Object, e As KeyEventArgs) Handles txtToItem.KeyDown
  99.         SetNextFocusManual(e, cboItemSubCategoryFrom)
  100.     End Sub
  101.  
  102.     Private Sub txtToItem_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtToItem.KeyPress
  103.         e.KeyChar = Chr(KeyAscCode(Asc(e.KeyChar)))
  104.     End Sub
  105.  
  106.     Private Sub cboItemSubCategoryFrom_KeyDown(sender As Object, e As KeyEventArgs) Handles cboItemSubCategoryFrom.KeyDown
  107.         SetNextFocusManual(e, cboItemSubCategoryTo)
  108.     End Sub
  109.  
  110.     Private Sub cboItemSubCategoryFrom_KeyPress(sender As Object, e As KeyPressEventArgs) Handles cboItemSubCategoryFrom.KeyPress
  111.         e.KeyChar = Chr(KeyAscCode(Asc(e.KeyChar)))
  112.     End Sub
  113.  
  114.     Private Sub cboItemSubCategoryTo_KeyDown(sender As Object, e As KeyEventArgs) Handles cboItemSubCategoryTo.KeyDown
  115.         SetNextFocusManual(e, cboStatus)
  116.     End Sub
  117.  
  118.     Private Sub cboItemSubCategoryTo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles cboItemSubCategoryTo.KeyPress
  119.         e.KeyChar = Chr(KeyAscCode(Asc(e.KeyChar)))
  120.     End Sub
  121.  
  122.     Private Sub cboStatus_KeyDown(sender As Object, e As KeyEventArgs) Handles cboStatus.KeyDown
  123.         SetNextFocusManual(e, dtpSPNDateFrom)
  124.     End Sub
  125.  
  126.     Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
  127.         Me.Close()
  128.     End Sub
  129.  
  130.     Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles btnPrint.Click
  131.         If ChkValid() = True Then
  132.             Dim strSPNDateFrom As Date = ConvertDate(dtpSPNDateFrom.Value)
  133.             Dim strSPNDateTo As Date = ConvertDate(dtpSPNDateTo.Value)
  134.             Dim strSPNDateFromString As String = ConvertDate(dtpSPNDateFrom.Value)
  135.             Dim strSPNDateToString As String = ConvertDate(dtpSPNDateTo.Value)
  136.             Dim strFromItem As String = txtFromItem.Text
  137.             Dim strToItem As String = txtToItem.Text
  138.             Dim strItemSubCategoryFrom As String = cboItemSubCategoryFrom.Text
  139.             Dim strItemSubCategoryTo As String = cboItemSubCategoryTo.Text
  140.             Dim strOrderBy As String = "Order By "
  141.             Dim strStoredProcedureName As String = ""
  142.             Dim rpt As New ReportDocument
  143.  
  144.             Try
  145.                 If strToItem = "" Then
  146.                     strToItem = SetMaxToValue()
  147.                 End If
  148.  
  149.                 If strItemSubCategoryTo = "" Then
  150.                     strItemSubCategoryTo = SetMaxToValue()
  151.                 End If
  152.  
  153.                 If rdbReportDetail.Checked = True Then
  154.                     rpt.Load(GetReportPath() & "rptStockPickingNoteDetail.rpt")
  155.                     strStoredProcedureName = "SPN_rpTransactionListing;1"
  156.                 End If
  157.  
  158.                 RptPastParameter(rpt, "@fdate", strSPNDateFromString)
  159.                 RptPastParameter(rpt, "@tdate", strSPNDateToString)
  160.                 RptPastParameter(rpt, "@fitem", strFromItem)
  161.                 RptPastParameter(rpt, "@titem", strToItem)
  162.                 RptPastParameter(rpt, "@fitemsubcat", strItemSubCategoryFrom)
  163.                 RptPastParameter(rpt, "@titemsubcat", strItemSubCategoryTo)
  164.  
  165.                
  166.                     Dim strSQL As String = "{SPN_rpTransactionListing;1.ItemConfirmFlag} = 'Y' OR {SPN_rpTransactionListing;1.ItemConfirmFlag} = 'N' "
  167.                     rpt.DataDefinition.RecordSelectionFormula = strSQL
  168.  
  169.  
  170.                     If rdbSortSPN.Checked = True Then
  171.                         strOrderBy = strOrderBy & rdbSortSPN.Text
  172.                         RptPastSortFormula(rpt, "fnSortField", "{" & strStoredProcedureName & ".SPNNo}")
  173.                     ElseIf rdbSortSPNDate.Checked = True Then
  174.                         strOrderBy = strOrderBy & rdbSortSPNDate.Text
  175.                         RptPastSortFormula(rpt, "fnSortField", "{" & strStoredProcedureName & ".SPNDate}")
  176.                     Else
  177.                         strOrderBy = strOrderBy & rdbSortItemCode.Text
  178.                         RptPastSortFormula(rpt, "fnSortField", "{" & strStoredProcedureName & ".ItemNo}")
  179.                     End If
  180.  
  181.                     SetRptCompany(rpt, True, False, False, False, False, False, False, False)
  182.                     RptPastFormula(rpt, "strUserName", strGlobalUserName)
  183.                     RptPastFormula(rpt, "strOrderBy", strOrderBy)
  184.                     SetReportDataSource(rpt)
  185.                     PreviewReport(rpt)
  186.  
  187.             Catch ex As Exception
  188.                 InsertSysErrorLog(Me.Name, "btnPrint_Click", ex.Message, "")
  189.             End Try
  190.         End If
  191.     End Sub
  192. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement