You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Custom classes for Windows Form Application in C# Developed by Wilfred V. Pine
3
+
Custom [Classes](https://github.com/redmalmon/csharp-custom-classes/tree/main/Classes) for Windows Form Application using C# Developed by Wilfred V. Pine
### 1. [Database](https://github.com/redmalmon/csharp-custom-classes/blob/main/Classes/Database.cs) class - this is use for MySqlClient configurations, sql statements, & etc. This will also included the loading of data to a form control including dataGridView and comboBox.
11
-
12
-
* Instantiation - creating an object `db` from a class type `Database` and instantiate using the `new` keyword.
1. Copy the [Classes](https://github.com/redmalmon/csharp-custom-classes/tree/main/Classes) folder into your project folder.
12
+
2. From your project folder root directory, create a class named " [Config](https://github.com/redmalmon/csharp-custom-classes/blob/main/Config.cs) " and create a public instance of all the classes from [Classes](https://github.com/redmalmon/csharp-custom-classes/tree/main/Classes) folder. See the code below:
3. Create an instance of your [Config](https://github.com/redmalmon/csharp-custom-classes/blob/main/Config.cs) class.
16
51
```c#
17
-
// instantiate an object `db` from `Database` class
18
-
Databasedb=newDatabase();
52
+
publicpartialclassFormLogin : Form
53
+
{
54
+
Configconfig=newConfig(); // your Config class
55
+
56
+
publicFormLogin()
57
+
{
58
+
InitializeComponent();
59
+
}
19
60
```
61
+
4. You can now use [Database](https://github.com/redmalmon/csharp-custom-classes/blob/main/Classes/Database.cs) , [Validation](https://github.com/redmalmon/csharp-custom-classes/blob/main/Classes/Validation.cs) , [Visualizer](https://github.com/redmalmon/csharp-custom-classes/blob/main/Classes/Visualizer.cs) , [Upload](https://github.com/redmalmon/csharp-custom-classes/blob/main/Classes/Upload.cs) , [Date_Time](https://github.com/redmalmon/csharp-custom-classes/blob/main/Classes/Str_Date_Time.cs) , & [Form_UI](https://github.com/redmalmon/csharp-custom-classes/blob/main/Classes/Form_UI.cs) Class.
62
+
```c#
63
+
config.db.....
64
+
config.validate......
65
+
config.ui......
66
+
config.visualizer.....
67
+
config.date_time.....
68
+
config.upload.......
69
+
```
70
+
71
+
72
+
### Using [Database](https://github.com/redmalmon/csharp-custom-classes/blob/main/Classes/Database.cs) class - this is use for MySqlClient configurations, sql statements, & etc. This will also included the loading of data to a form control including dataGridView and comboBox.
*`save(string table, string[] column, string[] bind)` or save() method is use for `insert into` statements and does not return a value. This methods display a MessageBox for showing the result of your sql statement.
The `table` parameter is use to pass your table_name from your database, while `column` parameter is use to pass your collection of column_name from your database table, and the `bind` parameter is for the collection of values of the columns.
90
+
The `table` parameterisusetopassyourtable_namefromyourdatabase, while `column` parameterisusetopassyourcollectionofcolumn_namefromyourdatabasetable, andthe `bind` parameterisforthecollectionofvaluesofthecolumns.Sincethe `msg` parameterhasadefaultvalue, itisoptional.
*`cud(string qry, string msg = "")` or cud() method is use for your `insert into` , `update` , and `delete` statements. This method also does not return a value. This methods display a MessageBox for showing the result of your sql statement, or passing your custom notification message (optional) using `msg` parameter.
98
+
* `cud(stringqry, stringmsg="Transaction Completed!")` orcud() methodisuseforyour `insertinto` , `update` , and `delete` statements. Thismethodalsodoesnotreturnavalue. ThismethodsdisplayaMessageBoxforshowingtheresultofyoursqlstatement, orpassingyourcustomnotificationmessage (optional) using `msg` parameter.
*`table(string qry, DataGridView dgv, string[] header = null)` or table() method is use for displaying data to DataGridView Control using the DataSource properties.
58
111
59
-
The `qry` parameter use for your sql satements `select`. The `dgv` parameter is use to pass the name of your DataGridView Control, while the `header` parameter (optional) is use to display the custom header name for your DataGridView display.
### 2. [Date_time](https://github.com/redmalmon/CSharf-Custom-Classes/blob/main/C-Sharf%20Classes/Classes/Date_time.cs) class - for date & time conversion
130
+
```c#
131
+
config.db.list("selectcourse_namefromcourses", cmbCourse); // cmbCourse is the name of your comboBox control
### 3. [Public_variables](https://github.com/redmalmon/CSharf-Custom-Classes/blob/main/C-Sharf%20Classes/Classes/Public_variables.cs) class - stored global variables
config.ui.Show(frmain, this); // or config.ui.Show(new frmMain());
163
+
```
164
+
165
+
* `Dialog(Form frm)` or Dialog() methods use for displaying Form as Dialog.
85
166
86
167
```c#
87
-
UI_eventsui=newUI_events();
168
+
frmMain frmain = new frmMain();
169
+
config.ui.Dialog(frmain); // or config.ui.Show(new frmMain());
88
170
```
171
+
#### The MDI :
89
172
90
173
* `FormShow(Form frm, string dstyle = "Fill")` or FormShow() methods is use for displaying form child to your MdiParent Form.
91
174
@@ -95,33 +178,17 @@ frmDashboard dash = new frmDashboard();
95
178
```
96
179
Passing object `dash` to the first parameter, and "Top" (`DockStyle` property value) to second parameter (Optional). Top property value is use for Dock properties of a form child. The default Dock property value is `DockStyle.Fill` or `Fill`.
97
180
```c#
98
-
ui.FormShow(dash, "Top");
181
+
config.ui.FormShow(dash, "Top");
99
182
```
100
183
101
184
```c#
102
185
// Fill
103
186
frmDashboard dash = new frmDashboard();
104
-
ui.FormShow(dash);
187
+
config.ui.FormShow(dash); // or config.ui.FormShow(new frmDashboard());
105
188
```
106
189
107
-
*`Show(Form frmNew, Form frmOld)` or Show() method is simply use for displaying new Form and hiding active Form.
108
-
109
-
```c#
110
-
frmMainfrmain=newfrmMain();
111
-
ui.Show(frmain, this);
112
-
//behind the methods
113
-
//frmain.Show();
114
-
//this.Hide();
115
-
```
116
-
117
-
*`Dialog(Form frm)` or Dialog() methods use for displaying Form as Dialog.
118
-
119
-
```c#
120
-
frmMainfrmain=newfrmMain();
121
-
ui.Dialog(frmain);
122
-
```
123
190
124
-
#### Chart
191
+
### Using [Visualizer](https://github.com/redmalmon/csharp-custom-classes/blob/main/Classes/Visualizer.cs) - use for visualization of data.
125
192
126
193
* `chart(Chart chart, string SeriesName, string[] x, int[] y, string chartType = "Column")` or chart() method
127
194
@@ -140,15 +207,15 @@ void loadChartSample()
140
207
// Array Value
141
208
int[] Y= { 12, 14, 9 };
142
209
// Pass to Chart Methods = Male Series
143
-
ui.chart(chartUser, "Male", X, Y, "Pie");
210
+
config.visualizer.chart(chartUser, "Male", X, Y, "Pie");
### 6. [Validations](https://github.com/redmalmon/CSharf-Custom-Classes/blob/main/C-Sharf%20Classes/Classes/Validations.cs) class - keyboard events, mouse events, etc.
196
274
197
-
* Instantiate
275
+
### Using [Validations](https://github.com/redmalmon/csharp-custom-classes/blob/main/Classes/Validation.cs) class - use for validationg inputs (keyboard events, mouse events, etc.)
198
276
199
-
```c#
200
-
Validationsvalidate=newValidations();
201
-
```
202
277
203
-
* The `txtRequired(TextBox[] txt, string msg = "")` or txtTequired() method use to validate required input controls.
0 commit comments