-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProductFormApp.vb
914 lines (587 loc) · 25.9 KB
/
ProductFormApp.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
Imports System.Data.SqlClient
Imports System.Linq
Imports System.Transactions
Imports CrystalDecisions.CrystalReports.Engine
Imports MasterDetailsWithADO.MasterDetailsWithADO
Public Enum Action
None = 0
Search = 1
Filter = 2
Refresh = 3
Add = 4
Edit = 5
Acept = 6
Cancel = 7
Delete = 8
Print = 9
Close = 10
End Enum
Public Enum State
None = 0
Query = 1
Insert = 2
Edit = 3
End Enum
Public Class ProductFormApp
Private Navigator As New BindingNavigator
Private Binding As New BindingSource
Dim itemsText As IEnumerable(Of TextBox)
Private _CurrentAction As Action
Private CurrentPositions As Integer = 0
Public Property CurrentAction() As Action
Get
Return _CurrentAction
End Get
Set(ByVal value As Action)
If value <> _CurrentAction OrElse
_CurrentAction = Action.Filter OrElse
_CurrentAction = Action.Refresh Then
Dim isCancel As Boolean
RaiseEvent BeforeExecuteAction(
_CurrentAction, value, isCancel)
If Not isCancel AndAlso Not ExecuteAction(value) Then Return
_CurrentAction = value
RaiseEvent AfterExecuteAction(_CurrentAction)
End If
End Set
End Property
Private _State As State
Public Property State() As State
Get
Return _State
End Get
Set(ByVal value As State)
If value <> _State Then
Dim isCancel As Boolean
RaiseEvent BeforeStateChange(
_State, value, isCancel)
If isCancel Then Return
_State = value
ChangeState()
RaiseEvent AfterStateChange(_State)
End If
End Set
End Property
Public Function IsExitRegit() As Boolean
Return If(_dset?.Tables(0).Rows?.Count > 0, False)
End Function
Function ChangeState() As Boolean
Select Case State
Case State.Insert
itemsText.ToList().ForEach(Sub(c)
c.BackColor = Color.AliceBlue
c.Enabled = True
End Sub)
Case State.Edit
itemsText.ToList().ForEach(Sub(c)
c.BackColor = Color.LightYellow
c.Enabled = True
End Sub)
Case State.Query
itemsText.ToList().ForEach(Sub(c)
c.BackColor = Color.LightYellow
c.Enabled = True
c.Clear()
End Sub)
Case State.None
itemsText.ToList().ForEach(Sub(c)
c.BackColor = Color.White
c.Enabled = False
End Sub)
End Select
Return True
End Function
Sub BindingObject()
itemsText.ToList().ForEach(Sub(c)
c.DataBindings.Clear()
End Sub)
txtCodigo.DataBindings.Add("Text", Binding, "CategoryId")
txtNombre.DataBindings.Add("Text", Binding, "CategoryName")
txtDescripcion.DataBindings.Add("Text", Binding, "CategoryDescription")
' picImage.DataBindings.Add("Image", Binding, "CategoryPicture")
End Sub
Private Sub ClearObj()
itemsText.ToList().ForEach(Sub(c)
c.Clear()
End Sub)
picImage.Image = Nothing
End Sub
Private Function ExecuteAction(pCurrentAction As Action) As Boolean
Try
Dim _existReg As Boolean = IsExitRegit()
Dim _search As Boolean, _filte As Boolean, _refresh As Boolean, _add As Boolean, _edit As Boolean,
_acept As Boolean, _cancel As Boolean, _delete As Boolean, _print As Boolean, _close As Boolean
Dim _readOnlyDtGrid As Boolean = True
Dim _enableImage As Boolean
Select Case pCurrentAction
Case Action.None
_search = True
_filte = _existReg
_refresh = _existReg
_add = True
_edit = _existReg
_delete = _existReg
_print = _existReg
_close = True
State = State.None
Case Action.Search
_acept = True
_cancel = True
Navigator.BeginInit()
btnMoveFirst.Enabled = False
btnMovePreview.Enabled = False
btnMoveNext.Enabled = False
btnMoveLast.Enabled = False
picImage.Image = Nothing
State = State.Query
dtgDetails.DataSource = Nothing
Case Action.Filter
If Not ExecuteFilter() Then
Return False
End If
CurrentAction = Action.None
Return True
Case Action.Refresh
ExecuteRefreshQuery()
CurrentAction = Action.None
Return True
Case Action.Add
_acept = True
_cancel = True
State = State.Insert
_readOnlyDtGrid = False
dtgDetails.AllowUserToAddRows = True
'dtgMaster.AllowUserToAddRows = True
_enableImage = True
txtCodigo.Enabled = False
picImage.Image = Nothing
'Navigator.MoveFirstItem = btnMoveFirst
'Navigator.MovePreviousItem = btnMovePreview
'Navigator.MoveNextItem = btnMoveNext
''Navigator.MoveLastItem = btnMoveLast
Navigator.BeginInit()
DetailsTable.BeginInit()
btnMoveFirst.Enabled = False
btnMovePreview.Enabled = False
btnMoveNext.Enabled = False
btnMoveLast.Enabled = False
' Navigator.EndInit()
_readOnlyDtGrid = False
Case Action.Edit
_acept = True
_cancel = True
Navigator.BeginInit()
DetailsTable.BeginInit()
btnMoveFirst.Enabled = False
btnMovePreview.Enabled = False
btnMoveNext.Enabled = False
btnMoveLast.Enabled = False
State = State.Edit
_enableImage = True
txtCodigo.Enabled = False
_readOnlyDtGrid = False
Case Action.Acept
AllowLoadChildData = True
Select Case State
Case State.Query
If Not ExecuteQuery() Then
Throw New Exception
End If
Navigator.EndInit()
' SetImage()
Case State.Insert
If Not ExecuteInsert() Then
Throw New Exception
End If
Navigator.EndInit()
DetailsTable.EndInit()
Case State.Edit
If Not ExecuteEdit() Then
Throw New Exception
End If
Navigator.EndInit()
DetailsTable.EndInit()
End Select
CurrentAction = Action.None
Return True
Case Action.Cancel
If State = State.Edit OrElse
State = State.Insert Then
Dim m As MsgBoxResult = MessageBox.Show("Esta seguro que deseas cancelar la Accion", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If m = MsgBoxResult.No Then
Return False
End If
dtgDetails.AllowUserToAddRows = False
End If
AllowLoadChildData = True
AllowLoadChildData = True
DetailsTable.EndInit()
Navigator.EndInit()
If State <> State.Edit Then
ClearObj()
End If
Binding.CancelEdit()
CurrentAction = Action.None
'BindingObject()
Return True
Case Action.Delete
If Not ExecuteDelete() Then
Return False
End If
Return True
Case Action.Print
ExecutePrint()
' CurrentAction = Action.None
Return False
Case Action.Close
Close()
End Select
btnSearch.Enabled = _search
btnFilter.Enabled = _filte
BtnRefresh.Enabled = _refresh
BtnNew.Enabled = _add
btnEdit.Enabled = _edit
btnAcept.Enabled = _acept
btnCancel.Enabled = _cancel
btnDelete.Enabled = _delete
btnPrint.Enabled = _print
btnClose.Enabled = _close
picImage.Enabled = _enableImage
btnExaminar.Enabled = _enableImage
dtgDetails.ReadOnly = _readOnlyDtGrid
Return True
Catch ex As Exception
Return False
End Try
End Function
Private Function ExecuteFilter() As Boolean
'_dsetFilter
'Dim frm As New Frmfilter(_dset.Tables(0).AsEnumerable)
'frm.SetDesktopLocation(Cursor.Position.X, Cursor.Position.Y)
'If frm.ShowDialog() = DialogResult.OK Then
' _dsetFilter = _dset.Tables(0).Rows.Find(frm.filteredId)
' Return True
'End If
Return False
End Function
Private Sub ExecuteRefreshQuery()
Try
BtnRefresh.Enabled = False
If _dset?.Tables(0)?.Rows?.Count > 0 Then
_dset = Data.GetAllData($" CategoryId IN({String.Join(",", _idsCurrentfilter.ToArray())})")
LoadChildData()
Binding.DataSource = _dset.Tables(0)
Navigator.BindingSource = Binding
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error in Refresh Action", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
BtnRefresh.Enabled = True
End Try
End Sub
Private Function ExecuteDelete() As Boolean
Try
Dim m As MsgBoxResult = MessageBox.Show($"Esta seguro que deseas Eliminar el Registro id {txtCodigo.Text}", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If m = MsgBoxResult.No Then
Return False
End If
Using s As New TransactionScope
'delete Master
If Not Data.Delete($"DELETE FROM Categories WHERE CategoryId={txtCodigo.Text}") Then
Throw New Exception
End If
'Delete Detail
If Not Data.Delete($"DELETE FROM Products WHERE CategoryId={txtCodigo.Text}") Then
Throw New Exception
End If
s.Complete()
MessageBox.Show($"El registro id {txtCodigo.Text} se ha eliminado con exito!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Question)
CurrentAction = Action.Refresh
End Using
Return True
Catch ex As Exception
MessageBox.Show(ex.Message, "Error in Delete Action", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return False
End Try
End Function
Private Sub ExecutePrint()
Try
Dim Reporte = New ReportClass()
Dim r As New report()
Reporte = r
'Reporte.da
Reporte.SetDataSource(_dset)
Dim reportview As New CrystalDecisions.Windows.Forms.CrystalReportViewer With {
.ReportSource = Reporte
}
reportview.Refresh()
reportview.Dock = DockStyle.Fill
Dim frm As New frmCrystalReportViewer()
frm.Controls.Add(reportview)
frm.ShowDialog()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error in Print Action", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
'Private Function ExecuteQuery() As Boolean
' If LoadData() Then
' Return True
' End If
' Return False
'End Function
Private Function ExecuteInsert() As Boolean
Try
''Inser master
Using t As New TransactionScope
Dim pars As New List(Of Parameter)
If String.IsNullOrEmpty(txtNombre.Text) Then
Throw New Exception("")
End If
pars.Add(New Parameter("CategoryName", txtNombre.Text))
pars.Add(New Parameter("CategoryDescription", txtDescripcion.Text))
If Not picImage.Image Is Nothing Then
pars.Add(New Parameter("CategoryPicture", picImage.Image.ConvertImageToByteArray(), SqlDbType.VarBinary))
End If
Dim _r = Data.Insert("Categories", pars)
If _r <= 0 Then
Throw New Exception()
End If
txtCodigo.Text = _r.ToString()
t.Complete()
End Using
MessageBox.Show("Registro Insertado con exito", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return True
Catch ex As Exception
MessageBox.Show(ex.Message, "Error in execute insert Action", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return False
End Try
End Function
Private Function ExecuteEdit() As Boolean
Try
''Edit master
Using t As New TransactionScope
Dim pars As New List(Of Parameter)
Dim parsFilter As New List(Of Parameter)
If String.IsNullOrEmpty(txtNombre.Text) Then
Throw New Exception("")
End If
pars.Add(New Parameter("CategoryName", txtNombre.Text))
pars.Add(New Parameter("CategoryDescription", txtDescripcion.Text))
If picImage.Image IsNot Nothing Then
pars.Add(New Parameter("CategoryPicture", picImage.Image.ConvertImageToByteArray(), SqlDbType.VarBinary))
End If
parsFilter.Add(New Parameter("CategoryId", txtCodigo.Text, SqlDbType.Int))
Dim _r = Data.Update("Categories", parsFilter, pars)
If Not _r Then
Throw New Exception()
End If
'Edit details
pars.Clear()
parsFilter.Clear()
dtgDetails.BindingContext(dtgDetails.DataSource).EndCurrentEdit()
dtgDetails.CommitEdit(DataGridViewDataErrorContexts.Commit)
DetailsTable.AcceptChanges()
Dim DetailsChanged As DataTable = DetailsTable.GetChanges
DetailsChanged?.AsEnumerable.ToList().ForEach(Sub(r)
pars.Add(New Parameter("ProductName", r("ProductName")))
pars.Add(New Parameter("QuantityPerUnitId", r("QuantityPerUnitId"), SqlDbType.Int))
pars.Add(New Parameter("UnitPrice", r("UnitPrice"), SqlDbType.Decimal))
pars.Add(New Parameter("UnitInStock", r("UnitInStock"), SqlDbType.Int))
pars.Add(New Parameter("MaxStock", r("MaxStock"), SqlDbType.Int))
pars.Add(New Parameter("MinStock", r("MinStock"), SqlDbType.Int))
parsFilter.Add(New Parameter("ProductId", r("ProductId")))
_r = Data.Update("Products", parsFilter, pars)
If Not _r Then
Throw New Exception()
End If
End Sub)
t.Complete()
End Using
MessageBox.Show($"El registro id {txtCodigo.Text} se ha actualido con exito!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return True
Catch ex As Exception
MessageBox.Show(ex.Message, "Error in execute edit Action", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return False
End Try
End Function
Dim _sqlAdapter As SqlDataAdapter
Dim _dset As DataSet
Dim _dsetFilter As DataSet
Private Data As IData
#Region "Events"
Public Event BeforeExecuteAction(ByVal oldValue As Action, ByVal NewValue As Action,
ByRef Cancel As Boolean)
Public Event AfterExecuteAction(CurrentValue As Action)
Public Event BeforeStateChange(ByVal oldValue As State, ByVal NewValue As State,
ByRef Cancel As Boolean)
Public Event AfterStateChange(CurrentValue As State)
#End Region
Private Function ExecuteQuery() As Boolean
Dim _rv As Boolean
Try
Dim _strwhere As String = "1=1"
If Not String.IsNullOrEmpty(txtCodigo.Text) Then
_strwhere = $"{_strwhere} AND CategoryId={txtCodigo.Text}"
End If
If Not String.IsNullOrEmpty(txtNombre.Text) Then
_strwhere = $"{_strwhere} AND CategoryName LIKE '%{txtNombre.Text}%'"
End If
If Not String.IsNullOrEmpty(txtDescripcion.Text) Then
_strwhere = $"{_strwhere} AND CategoryDescription LIKE '%{txtDescripcion.Text}%'"
End If
_idsCurrentfilter.Clear()
_dset = Data.GetAllData(_strwhere)
cbox.DataSource = _dset.Tables("QuantityPerUnits")
If _dset.Tables("Categories").Rows.Count > 0 Then
_idsCurrentfilter.AddRange(_dset.Tables(0).AsEnumerable.Select(Function(x) CInt(x("CategoryId"))).Distinct().ToArray)
LoadChildData()
_rv = True
Else
MessageBox.Show("No existen registros con esa condición", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
_rv = False
End If
Binding.DataSource = _dset.Tables("Categories")
masterCount.Text = _dset.Tables("Categories").Rows.Count
DetailsCount.Text = _dset.Tables("Products").Rows.Count
Navigator.BindingSource = Binding
BindingObject()
'tsCurrentPosition = Navigator.PositionItem
Catch ex As Exception
MessageBox.Show(ex.Message, "Error in execute query Action", MessageBoxButtons.OK, MessageBoxIcon.Error)
_rv = False
End Try
Return _rv
End Function
Dim _idsCurrentfilter As New List(Of Integer)
Private Sub ProductFormApp_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Navigator.MoveFirstItem = btnMoveFirst
Navigator.MovePreviousItem = btnMovePreview
Navigator.MoveNextItem = btnMoveNext
Navigator.MoveLastItem = btnMoveLast
Navigator.AddNewItem = BtnNew
Navigator.PositionItem = tsCurrentPosition
Navigator.BindingSource = Binding
AddHandler Binding.CurrentChanged, AddressOf ChangeHandler
itemsText = Me.GetAllControls(GetType(TextBox)).Cast(Of TextBox)
Services.ConfigureDefaultServices()
Data = Services.Get(Of IData)
'LoadData()
cbox.HeaderText = "Cant/ Unit"
cbox.DataPropertyName = "QuantityPerUnitId"
cbox.DisplayMember = "QuantityPerUnitName"
cbox.ValueMember = "QuantityPerUnitId"
dtgDetails.AutoGenerateColumns = False
dtgDetails.Columns.Add(cbox)
'
ExecuteAction(Action.None)
' ChangeState()
End Sub
Private Sub ChangeHandler(sender As Object, e As EventArgs)
SetImage()
CurrentPositions = Binding.Position
'If Not State = State.Query Then
' LoadChildData()
'End If
End Sub
Dim cbox As New DataGridViewComboBoxColumn
Dim DetailsTable As New DataTable()
Public Sub LoadChildData(Optional IdMaster As Integer = 0)
dtgDetails.DataSource = Nothing
If _dset.Tables("Categories").Rows.Count > 0 Then
Dim _parentRow As DataRow = Nothing
If IdMaster > 0 Then
_parentRow = _dset.Tables("Categories").Rows.Find(IdMaster)
End If
'If State = State.Query Then
' _parentRow = _dset.Tables("Categories").Rows(0)
'Else
' Dim litp As New List(Of Integer)
' litp = _dset.Tables("Categories").AsEnumerable().Select(Function(t) _dset.Tables("Categories").Rows.IndexOf(t)).ToList()
' If litp.Contains(Binding.Position) Then
' _parentRow = _dset.Tables("Categories").Rows(Binding.Position)
' End If
'End If
If _parentRow IsNot Nothing Then
Dim _childRows = _parentRow.GetChildRows("CategoryProduct")
DetailsTable = _dset.Tables("Products").Clone()
_childRows.ToList().ForEach(Function(v)
DetailsTable.ImportRow(v)
Return True
End Function)
DetailsTable.AcceptChanges()
dtgDetails.DataSource = DetailsTable
' FillCbox()
End If
End If
End Sub
Private Sub btnCerrar_Click(sender As Object, e As EventArgs) Handles btnClose.Click
CurrentAction = Action.Close
End Sub
Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
CurrentAction = Action.Search
End Sub
Private Sub BtnRefresh_Click(sender As Object, e As EventArgs) Handles BtnRefresh.Click
CurrentAction = Action.Refresh
End Sub
Private Sub BntNew_Click(sender As Object, e As EventArgs) Handles BtnNew.Click
CurrentAction = Action.Add
End Sub
Private Sub btnEdit_Click(sender As Object, e As EventArgs) Handles btnEdit.Click
CurrentAction = Action.Edit
End Sub
Private Sub btnAcept_Click(sender As Object, e As EventArgs) Handles btnAcept.Click
CurrentAction = Action.Acept
End Sub
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
CurrentAction = Action.Cancel
End Sub
Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click
CurrentAction = Action.Delete
End Sub
Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles btnPrint.Click
CurrentAction = Action.Print
End Sub
Private Sub btnMoveFirst_Click(sender As Object, e As EventArgs) Handles btnMoveFirst.Click
End Sub
Private Sub btnExaminar_Click(sender As Object, e As EventArgs) Handles btnExaminar.Click
Dim file As New OpenFileDialog()
file.Filter = "Archivo JPG|*.jpg"
If file.ShowDialog() = DialogResult.OK Then
picImage.Image = Image.FromFile(file.FileName)
End If
End Sub
Private Sub SetImage()
Dim _arr = Binding?.Current()?(3)
If _arr IsNot DBNull.Value AndAlso
_arr IsNot Nothing AndAlso
_arr.Length > 0 Then
picImage.Image = ConvertByteArrayToImage(_arr)
Else
picImage.Image = Nothing
End If
End Sub
Dim AllowLoadChildData As Boolean = True
Private Sub txtCodigo_TextChanged(sender As Object, e As EventArgs) Handles txtCodigo.TextChanged
If Not String.IsNullOrEmpty(txtCodigo.Text) AndAlso AllowLoadChildData Then
LoadChildData(CInt(txtCodigo.Text))
Else
LoadChildData()
End If
End Sub
Private Sub QuitarElFiltroToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles QuitarElFiltroToolStripMenuItem.Click
Refresh()
End Sub
Private Sub ProductFormApp_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
End Sub
Private Sub ProductFormApp_Activated(sender As Object, e As EventArgs) Handles MyBase.Activated
End Sub
Private Sub txtCodigo_Enter(sender As Object, e As EventArgs) Handles txtCodigo.Enter
AllowLoadChildData = False
End Sub
Private Sub txtCodigo_Leave(sender As Object, e As EventArgs) Handles txtCodigo.Leave
AllowLoadChildData = True
End Sub
Private Sub btnFilter_ButtonClick(sender As Object, e As EventArgs) Handles btnFilter.ButtonClick
CurrentAction = Action.Filter
End Sub
End Class