-
Notifications
You must be signed in to change notification settings - Fork 4
/
frmProducts.cs
189 lines (173 loc) · 6.45 KB
/
frmProducts.cs
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
using System;
using UpgradeHelpers.DB.ADO;
using UpgradeHelpers.Helpers;
using Mobilize.WebMap.Common.Attributes;
using Mobilize.Web.Extensions;
namespace SKS
{
[Observable]
internal partial class frmProducts
: Mobilize.Web.Form
{
public frmProducts()
: base()
{
if ( m_vb6FormDefInstance is null )
{
if ( m_InitializingDefInstance )
{
m_vb6FormDefInstance = this;
}
else
{
try
{
//For the start-up form, the first instance created is the default instance.
if ( !(System.Reflection.Assembly.GetExecutingAssembly().EntryPoint is null) && System.Reflection.Assembly.GetExecutingAssembly().EntryPoint.DeclaringType == this.GetType() )
{
m_vb6FormDefInstance = this;
}
}
catch
{
}
}
}
//This call is required by the Windows Form Designer.
InitializeComponent();
ReLoadForm(false);
}
private void frmProducts_Activated(System.Object eventSender, System.EventArgs eventArgs)
{
if ( Stub._UpgradeHelpers.Gui.Utils.ActivateHelper.myActiveForm != eventSender )
{
Stub._UpgradeHelpers.Gui.Utils.ActivateHelper.myActiveForm = (Mobilize.Web.Form)eventSender;
}
}
[Intercepted]
private bool NewMode { get; set; } = false;
[Intercepted]
private bool EditMode { get; set; } = false;
[Intercepted]
private bool CancellingMode { get; set; } = false;
[Intercepted]
public string CurrentProductID { get; set; } = "";
//SKS Demo TODO: Go the the designer and change the data binding of _txtField_4 like this:
//_txtField_4.DataBindings.Add("Text", dcProducts, "UnitPrice", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged, null, "C2");
private void cmbCategory_SelectedIndexChanged(Object eventSender, EventArgs eventArgs)
{
if ( cmbCategory.Items.Count == 0 || cmbCategory.SelectedIndex == -1 )
{
return ;
}
txtCategory.Text = cmbCategory.GetItemData(cmbCategory.SelectedIndex).ToString();
}
private void Form_Closed(Object eventSender, EventArgs eventArgs)
{
CurrentProductID = Convert.ToString(dcProducts.Recordset["ProductId"]);
}
private void txtCategory_TextChanged(Object eventSender, EventArgs eventArgs)
{
if ( cmbCategory.Items.Count == 0 )
{
modFunctions.LoadCombo("Categories", cmbCategory, "CategoryName", "CategoryID");
}
//UPGRADE_WARNING: (2080) IsEmpty was upgraded to a comparison and has a new behavior. More Information: https://docs.mobilize.net/vbuc/ewis#2080
if ( String.IsNullOrEmpty(txtCategory.Text) )
{
cmbCategory.SelectedIndex = -1;
return ;
}
int Index = -1;
int tempForEndVar = cmbCategory.Items.Count;
for ( modMain.i = 0; modMain.i <= tempForEndVar; modMain.i++ )
{
if ( cmbCategory.GetItemData(modMain.i) == StringsHelper.ToDoubleSafe(txtCategory.Text) )
{
Index = modMain.i;
break;
}
}
cmbCategory.SelectedIndex = modMain.i;
}
//UPGRADE_WARNING: (2080) Form_Load event was upgraded to Form_Load method and has a new behavior. More Information: https://docs.mobilize.net/vbuc/ewis#2080
private void Form_Load()
{
txtCategory.Height = 0;
txtCategory.Width = 0;
dcProducts.ConnectionString = modMain.ConnectionString;
NewMode = false;
EditMode = false;
CancellingMode = false;
if ( cmbCategory.Items.Count == 0 )
{
modFunctions.LoadCombo("Categories", cmbCategory, "CategoryName", "CategoryID");
}
}
private void Toolbar1_ButtonClick(Object eventSender, EventArgs eventArgs)
{
Mobilize.Web.ToolStripItem Button = (Mobilize.Web.ToolStripItem)eventSender;
object x = null;
//SKS Demo TODO: dcProducts.SetFocus()
switch ( Button.Text )
{
case "Add":
//Add new record
NewMode = true;
dcProducts.Recordset.AddNew();
dcProducts.Recordset["UnitsInStock"] = 0;
dcProducts.Recordset["UnitsOnOrder"] = 0;
dcProducts.Recordset["Discontinued"] = 0;
break;
case "Edit":
//Edit mode
EditMode = true;
//dcProducts.Recordset.EditMode =
break;
case "Save":
//Save data
dcProducts.Recordset.Update();
dcProducts.Recordset.Requery(); // SQLite ODBC driver needs to requery the info
EditMode = false;
NewMode = false;
break;
case "Delete":
//Delete record
if ( Mobilize.Web.MessageBox.Show("Are you sure you want to delete this record?", "Delete record", Mobilize.Web.MessageBoxButtons.YesNo, Mobilize.Web.MessageBoxIcon.Question) == Mobilize.Web.DialogResult.Yes )
{
dcProducts.Recordset.Delete();
dcProducts.Recordset.Requery();
}
break;
case "Search":
//Search for records
modFunctions.SearchShow("Products", "ProductName", "product");
break;
case "Cancel":
CancellingMode = true;
//Cancel edited changes
EditMode = false;
NewMode = false;
dcProducts.Recordset.CancelUpdate();
dcProducts.Recordset.Requery();
CancellingMode = false;
this.Close();
break;
}
}
//Private Sub txtField_KeyPress(Index As Integer, KeyAscii As Integer)
//If Index = 0 Then
// KeyAscii = Asc(UCase(Chr(KeyAscii)))
//ElseIf Index = 4 Or Index = 5 Then
// Select Case KeyAscii
// Case vbKey0 To vbKey9
// Case vbKeyBack, vbKeyClear, vbKeyDelete
// Case vbKeyLeft, vbKeyRight, vbKeyUp, vbKeyDown, vbKeyTab
// Case Else
// KeyAscii = 0
// Beep
// End Select
//End If
//End Sub
}
}