Skip to content

Commit 610a70f

Browse files
authored
Add files via upload
1 parent 8bb56bb commit 610a70f

18 files changed

+17808
-0
lines changed

C-Sharf Classes/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
5+
</startup>
6+
</configuration>
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{C61FFA56-222A-4524-AC7C-9625C2BB50CF}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>C_Sharf_Classes</RootNamespace>
10+
<AssemblyName>C-Sharf Classes</AssemblyName>
11+
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="MySql.Data, Version=8.0.15.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL" />
37+
<Reference Include="System" />
38+
<Reference Include="System.Core" />
39+
<Reference Include="System.Windows.Forms.DataVisualization" />
40+
<Reference Include="System.Xml.Linq" />
41+
<Reference Include="System.Data.DataSetExtensions" />
42+
<Reference Include="Microsoft.CSharp" />
43+
<Reference Include="System.Data" />
44+
<Reference Include="System.Deployment" />
45+
<Reference Include="System.Drawing" />
46+
<Reference Include="System.Net.Http" />
47+
<Reference Include="System.Windows.Forms" />
48+
<Reference Include="System.Xml" />
49+
</ItemGroup>
50+
<ItemGroup>
51+
<Compile Include="Classes\Date_time.cs" />
52+
<Compile Include="Classes\Public_variables.cs" />
53+
<Compile Include="Classes\UI_events.cs" />
54+
<Compile Include="Classes\Upload.cs" />
55+
<Compile Include="Classes\Validatios.cs" />
56+
<Compile Include="Config.cs" />
57+
<Compile Include="Classes\Database.cs" />
58+
<Compile Include="frmLogin.cs">
59+
<SubType>Form</SubType>
60+
</Compile>
61+
<Compile Include="frmLogin.Designer.cs">
62+
<DependentUpon>frmLogin.cs</DependentUpon>
63+
</Compile>
64+
<Compile Include="Program.cs" />
65+
<Compile Include="Properties\AssemblyInfo.cs" />
66+
<Compile Include="View\frmDashboard.cs">
67+
<SubType>Form</SubType>
68+
</Compile>
69+
<Compile Include="View\frmDashboard.Designer.cs">
70+
<DependentUpon>frmDashboard.cs</DependentUpon>
71+
</Compile>
72+
<Compile Include="View\frmDataGridView.cs">
73+
<SubType>Form</SubType>
74+
</Compile>
75+
<Compile Include="View\frmDataGridView.Designer.cs">
76+
<DependentUpon>frmDataGridView.cs</DependentUpon>
77+
</Compile>
78+
<Compile Include="View\frmInputs.cs">
79+
<SubType>Form</SubType>
80+
</Compile>
81+
<Compile Include="View\frmInputs.Designer.cs">
82+
<DependentUpon>frmInputs.cs</DependentUpon>
83+
</Compile>
84+
<Compile Include="View\frmMain.cs">
85+
<SubType>Form</SubType>
86+
</Compile>
87+
<Compile Include="View\frmMain.Designer.cs">
88+
<DependentUpon>frmMain.cs</DependentUpon>
89+
</Compile>
90+
<EmbeddedResource Include="frmLogin.resx">
91+
<DependentUpon>frmLogin.cs</DependentUpon>
92+
</EmbeddedResource>
93+
<EmbeddedResource Include="Properties\Resources.resx">
94+
<Generator>ResXFileCodeGenerator</Generator>
95+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
96+
<SubType>Designer</SubType>
97+
</EmbeddedResource>
98+
<Compile Include="Properties\Resources.Designer.cs">
99+
<AutoGen>True</AutoGen>
100+
<DependentUpon>Resources.resx</DependentUpon>
101+
<DesignTime>True</DesignTime>
102+
</Compile>
103+
<EmbeddedResource Include="View\frmDashboard.resx">
104+
<DependentUpon>frmDashboard.cs</DependentUpon>
105+
</EmbeddedResource>
106+
<EmbeddedResource Include="View\frmDataGridView.resx">
107+
<DependentUpon>frmDataGridView.cs</DependentUpon>
108+
</EmbeddedResource>
109+
<EmbeddedResource Include="View\frmInputs.resx">
110+
<DependentUpon>frmInputs.cs</DependentUpon>
111+
</EmbeddedResource>
112+
<EmbeddedResource Include="View\frmMain.resx">
113+
<DependentUpon>frmMain.cs</DependentUpon>
114+
</EmbeddedResource>
115+
<None Include="Properties\Settings.settings">
116+
<Generator>SettingsSingleFileGenerator</Generator>
117+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
118+
</None>
119+
<Compile Include="Properties\Settings.Designer.cs">
120+
<AutoGen>True</AutoGen>
121+
<DependentUpon>Settings.settings</DependentUpon>
122+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
123+
</Compile>
124+
</ItemGroup>
125+
<ItemGroup>
126+
<None Include="App.config" />
127+
</ItemGroup>
128+
<ItemGroup>
129+
<None Include="Resources\confired 2 dark.png" />
130+
</ItemGroup>
131+
<ItemGroup />
132+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
133+
</Project>
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
/**
2+
* __________________________________________________________________
3+
*
4+
* C-Sharf Custom Classes
5+
* __________________________________________________________________
6+
*
7+
* MIT License
8+
*
9+
* Copyright (c) 2020 Wilfred V. Pine
10+
*
11+
* Permission is hereby granted, free of charge, to any person obtaining a copy
12+
* of this software and associated documentation files (the "Software"), to deal
13+
* in the Software without restriction, including without limitation the rights
14+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15+
* copies of the Software, and to permit persons to whom the Software is
16+
* furnished to do so, subject to the following conditions:
17+
*
18+
* The above copyright notice and this permission notice shall be included in
19+
* all copies or substantial portions of the Software.
20+
*
21+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27+
* THE SOFTWARE.
28+
*
29+
* @package C-Sharf Custom Classes
30+
* @author Wilfred V. Pine <only.master.red@gmail.com>
31+
* @copyright Copyright 2020 (https://red.confired.com)
32+
* @link https://confired.com
33+
* @license https://opensource.org/licenses/MIT MIT License
34+
*/
35+
36+
using System;
37+
using System.Data;
38+
using System.Windows.Forms;
39+
using MySql.Data.MySqlClient;
40+
41+
namespace C_Sharf_Classes.Classes
42+
{
43+
class Database : Config
44+
{
45+
// instantiate public variable
46+
Public_variables public_vars = new Public_variables();
47+
48+
// connection string
49+
private static string constring = "server=localhost;uid=" + dbuser + ";pwd='" + dbpassword + "';database=" + dbname;
50+
public MySqlConnection con = new MySqlConnection(constring);
51+
MySqlCommand cmd;
52+
MySqlDataReader reader;
53+
MySqlDataAdapter da;
54+
DataTable dt;
55+
56+
// Check Database Connection
57+
public Database()
58+
{
59+
con = new MySqlConnection(constring);
60+
try
61+
{
62+
if(con.State == ConnectionState.Closed)
63+
con.Open();
64+
}
65+
catch (Exception ex)
66+
{
67+
Application.Exit();
68+
MessageBox.Show(ex.Message);
69+
}
70+
}
71+
72+
// select or search = return a row
73+
public MySqlDataReader select(string qry)
74+
{
75+
76+
con = new MySqlConnection(constring);
77+
con.Open();
78+
79+
cmd = new MySqlCommand(qry, con);
80+
reader = cmd.ExecuteReader();
81+
return reader;
82+
83+
}
84+
85+
// create / update / delete
86+
public void cud(string qry, string msg = "")
87+
{
88+
89+
con = new MySqlConnection(constring);
90+
con.Open();
91+
92+
cmd = new MySqlCommand(qry, con);
93+
if (cmd.ExecuteNonQuery() > 0)
94+
{
95+
if (msg == "")
96+
MessageBox.Show("Transaction Complete!");
97+
else
98+
MessageBox.Show(msg);
99+
}
100+
else
101+
{
102+
MessageBox.Show("Sorry! There's something wrong.");
103+
}
104+
105+
}
106+
107+
// Save
108+
public void save(string table, string[] column, string[] bind)
109+
{
110+
111+
con = new MySqlConnection(constring);
112+
con.Open();
113+
114+
string fields = "";
115+
foreach (string col in column)
116+
{
117+
fields = fields + col + ',';
118+
}
119+
120+
string value = "";
121+
foreach (string val in bind)
122+
{
123+
value = value + "'" + val + "',";
124+
}
125+
126+
var qry = "INSERT INTO " + table + "(" + fields.TrimEnd(',') + ") VALUES(" + value.TrimEnd(',') + ")";
127+
128+
cmd = new MySqlCommand(qry, con);
129+
if (cmd.ExecuteNonQuery() > 0)
130+
{
131+
MessageBox.Show("Successfully saved.");
132+
}
133+
else
134+
{
135+
MessageBox.Show("Sorry! There's something wrong.");
136+
}
137+
}
138+
139+
// datasource / select rows / for DataGridView
140+
public void table(string qry, DataGridView dgv, string[] header = null)
141+
{
142+
143+
dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
144+
dgv.MultiSelect = false;
145+
dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
146+
147+
con = new MySqlConnection(constring);
148+
con.Open();
149+
150+
da = new MySqlDataAdapter(qry, con);
151+
dt = new DataTable();
152+
da.Fill(dt);
153+
dgv.DataSource = dt;
154+
155+
if (header != null)
156+
{
157+
foreach (DataGridViewColumn dgvcolumn in dgv.Columns)
158+
{
159+
dgvcolumn.HeaderText = header[dgvcolumn.Index];
160+
}
161+
}
162+
163+
}
164+
165+
// select & add to combo box
166+
public void list(string qry, ComboBox comboBox)
167+
{
168+
con = new MySqlConnection(constring);
169+
con.Open();
170+
171+
cmd = new MySqlCommand(qry, con);
172+
reader = cmd.ExecuteReader();
173+
174+
comboBox.Items.Clear();
175+
while (reader.Read())
176+
{
177+
comboBox.Items.Add(reader[0].ToString());
178+
comboBox.AutoCompleteCustomSource.Add(reader[0].ToString());
179+
}
180+
181+
}
182+
183+
// check data if exist
184+
public bool exist(string qry)
185+
{
186+
187+
con = new MySqlConnection(constring);
188+
con.Open();
189+
190+
cmd = new MySqlCommand(qry, con);
191+
reader = cmd.ExecuteReader();
192+
if (reader.Read())
193+
return true;
194+
else
195+
return false;
196+
197+
}
198+
199+
//MAx ID
200+
public void maxid(String column, String tbl)
201+
{
202+
con = new MySqlConnection(constring);
203+
con.Open();
204+
205+
var cmd = new MySqlCommand("SELECT MAX(" + column + ") from " + tbl + "", con);
206+
207+
var reader = cmd.ExecuteReader();
208+
if (reader.Read())
209+
{
210+
try
211+
{
212+
public_vars.maxid = reader.GetInt32(0) + 1;
213+
}
214+
catch (Exception)
215+
{
216+
public_vars.maxid = 1;
217+
}
218+
}
219+
}
220+
221+
222+
}
223+
}

0 commit comments

Comments
 (0)