-
Notifications
You must be signed in to change notification settings - Fork 4
/
frmSearch.cs
158 lines (143 loc) · 5.48 KB
/
frmSearch.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
using System;
using UpgradeHelpers.DB.ADO;
using Mobilize.WebMap.Common.Attributes;
using Mobilize.Web.Extensions;
namespace SKS
{
[Observable]
internal partial class frmSearch
: Mobilize.Web.Form
{
public frmSearch()
: 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();
}
private void frmSearch_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]
string SearchTable { get; set; } = "";
private void cboSrchBy_SelectedIndexChanged(Object eventSender, EventArgs eventArgs)
{
lblSrchBy.Text = cboSrchBy.Text;
}
private void cmdClose_Click(Object eventSender, EventArgs eventArgs)
{
this.Close();
}
public void Search(string Table, string fieldToSearch, string itemToSearch)
{
//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(itemToSearch) )
{
Label20.Text = "Search for a " + itemToSearch;
}
SearchTable = Table;
modConnection.ExecuteSql("Select * from " + Table + " limit 1;");
int tempForEndVar = (modConnection.rs.FieldsMetadata.Count - 1);
for ( modMain.i = 0; modMain.i <= tempForEndVar; modMain.i++ )
{
cboSrchBy.AddItem(modConnection.rs.GetField(modMain.i).FieldMetadata.ColumnName);
}
cboSrchBy.Text = fieldToSearch;
}
private void cmdSearch_Click(Object eventSender, EventArgs eventArgs)
{
if ( txtSrchStr.Text.Substring(Math.Max(txtSrchStr.Text.Length - 1, 0)) == "'" )
{
txtSrchStr.Text = "";
}
string txtToSearch = "";
//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(txtSrchStr.Text.Trim()) )
{
txtToSearch = txtSrchStr.Text;
}
else
{
txtToSearch = "%";
}
if ( SearchTable == "Customers" )
{
SearchCriteriaCustomers(lblSrchBy.Text, txtToSearch);
}
else if ( SearchTable == "Products" )
{
SearchCriteriaProducts(lblSrchBy.Text, txtToSearch);
}
else if ( SearchTable == "Providers" )
{
SearchCriteriaProviders(lblSrchBy.Text, txtToSearch);
}
}
//''
public void SearchCriteriaCustomers(string field, string value)
{
modConnection.ExecuteSql("Select * from Customers where " + field + " LIKE '" + value + "%'");
if ( modConnection.rs.RecordCount == 0 )
{
Mobilize.Web.MessageBox.Show("There are no records with the selected criteria", "Search", Mobilize.Web.MessageBoxButtons.OK, Mobilize.Web.MessageBoxIcon.Information);
}
else
{
modMain.LogStatus("There are " + modConnection.rs.RecordCount.ToString() + " that meet with the selected criteria");
frmCustomers.DefInstance.dcCustomers.UpdateRecordSet(modConnection.rs);
}
}
public void SearchCriteriaProducts(string field, string value)
{
modConnection.ExecuteSql("Select * from Products where " + field + " LIKE '" + value + "%'");
if ( modConnection.rs.RecordCount == 0 )
{
Mobilize.Web.MessageBox.Show("There are no records with the selected criteria", "Search", Mobilize.Web.MessageBoxButtons.OK, Mobilize.Web.MessageBoxIcon.Information);
}
else
{
frmProducts.DefInstance.dcProducts.UpdateRecordSet(modConnection.rs);
}
}
public void SearchCriteriaProviders(string field, string value)
{
modConnection.ExecuteSql("Select * from Providers where " + field + " LIKE '" + value + "%'");
if ( modConnection.rs.RecordCount == 0 )
{
Mobilize.Web.MessageBox.Show("There are no records with the selected criteria", "Search", Mobilize.Web.MessageBoxButtons.OK, Mobilize.Web.MessageBoxIcon.Information);
}
else
{
modMain.LogStatus("There are " + modConnection.rs.RecordCount.ToString() + " that meet with the selected criteria");
frmProviders.DefInstance.dcProviders.UpdateRecordSet(modConnection.rs);
}
}
private void Form_Closed(Object eventSender, EventArgs eventArgs)
{
}
}
}