-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrmSearch.cs
More file actions
146 lines (134 loc) · 4.17 KB
/
frmSearch.cs
File metadata and controls
146 lines (134 loc) · 4.17 KB
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
using System;
using System.Windows.Forms;
using UpgradeHelpers.DB.ADO;
using UpgradeHelpers.Gui;
namespace SKS
{
internal partial class frmSearch
: System.Windows.Forms.Form
{
string SearchTable = "";
public frmSearch()
: base()
{
if (m_vb6FormDefInstance == 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 != 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 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://www.mobilize.net/vbtonet/ewis/ewi2080
if (!String.IsNullOrEmpty(itemToSearch))
{
Label20.Text = "Search for a " + itemToSearch;
}
SearchTable = Table;
modConnection.ExecuteSql("Select Top 1 * from " + Table);
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://www.mobilize.net/vbtonet/ewis/ewi2080
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)
{
MessageBox.Show("There are no records with the selected criteria", "Search", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
modMain.LogStatus("There are " + modConnection.rs.RecordCount.ToString() + " that meet with the selected criteria");
frmCustomers.DefInstance.dcCustomers.Recordset = modConnection.rs;
}
}
public void SearchCriteriaProducts(string field, string value)
{
modConnection.ExecuteSql("Select * from Products where " + field + " LIKE '" + value + "%'");
if (modConnection.rs.RecordCount == 0)
{
MessageBox.Show("There are no records with the selected criteria", "Search", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
frmProducts.DefInstance.dcProducts.Recordset = modConnection.rs;
}
}
public void SearchCriteriaProviders(string field, string value)
{
modConnection.ExecuteSql("Select * from Providers where " + field + " LIKE '" + value + "%'");
if (modConnection.rs.RecordCount == 0)
{
MessageBox.Show("There are no records with the selected criteria", "Search", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
modMain.LogStatus("There are " + modConnection.rs.RecordCount.ToString() + " that meet with the selected criteria");
frmProviders.DefInstance.dcProviders.Recordset = modConnection.rs;
}
}
private void Form_Closed(Object eventSender, EventArgs eventArgs)
{
}
}
}