-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm36.cs
76 lines (67 loc) · 2.59 KB
/
Form36.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data;
using MySql.Data.MySqlClient;
namespace ECAMS
{
public partial class Form36 : Form
{
int i, id, part_id, inventory_id;
String ut;
MySqlConnection connectionstring = new MySqlConnection("server = localhost;" + "user id = root;" +
"database=ecams_database;" + "password=facebook2018;");
public Form36(int society_id,String user_type)
{
InitializeComponent();
id=society_id;
ut = user_type.ToString();
}
private void Form36_Load(object sender, EventArgs e)
{
try
{
if (connectionstring.State != ConnectionState.Open)
{
connectionstring.Open();
}
MySqlCommand cmd = connectionstring.CreateCommand();
cmd.CommandType = CommandType.Text;
if (ut == "society")
{
cmd.CommandText = "select * from society where society_id='" + id + "'";
}
else if (ut == "sport")
{
cmd.CommandText = "select * from sport where sport_id='" + id + "'";
}
DataTable dt = new DataTable();
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
da.Fill(dt);
cmd.ExecuteNonQuery();
inventory_id = Convert.ToInt32(dt.Rows[0]["inventory_inventory_id"].ToString());
dt.Rows.Clear();
cmd.CommandText = "select * from part where inventory_inventory_id='"+ inventory_id+"' ";
MySqlDataAdapter da1 = new MySqlDataAdapter(cmd);
da1.Fill(dt);
cmd.ExecuteNonQuery();
i = Convert.ToInt32(dt.Rows.Count.ToString());
for (int j = 0; j < i; j++)
{
dataGridView1.Rows.Add(dt.Rows[j]["part_id"].ToString(), dt.Rows[j]["part_name"].ToString(), dt.Rows[j]["quantity"].ToString(),
dt.Rows[j]["donate"].ToString());
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
}
}
}
}