private void Form2_Load(object sender, EventArgs e) { try { // Storage Panel Query...// SqlConnection MyConnection = new SqlConnection(Form1.Conn_String); MyConnection.Open(); string cmd = "Select B_ID, B_NAME, B_TITLE, CATEGORY, AUTHOR, PUBLICATION, PUB_DATE from Storage_Panel Order by B_ID ASC"; SqlCommand mycmd = new SqlCommand(cmd, MyConnection); SqlDataAdapter DAdap = new SqlDataAdapter(mycmd); DataTable DT = new DataTable(); DAdap.Fill(DT); dataGridView1.DataSource = DT; MyConnection.Close(); DAdap.Dispose(); DT.Dispose(); // Issue_Master Query...// MyConnection = new SqlConnection(Form1.Conn_String); MyConnection.Open(); cmd = "Select Issue_Master.U_ID,Issue_Master.B_ID, Storage_Panel.B_NAME, Storage_Panel.CATEGORY, Storage_Panel.ONLINE_LOCATION, Issue_Master.ISSUE_DATE, Issue_Master.DUES from Issue_Master inner join Storage_Panel on Issue_Master.U_ID = " + Form1.U_ID + " and Issue_Master.B_ID = Storage_Panel.B_ID Order by B_ID ASC"; mycmd = new SqlCommand(cmd, MyConnection); DAdap = new SqlDataAdapter(mycmd); DT = new DataTable(); DAdap.Fill(DT); dataGridView2.DataSource = DT; MyConnection.Close(); DAdap.Dispose(); DT.Dispose(); //Selection Query for Storage_Panel// MyConnection.Open(); cmd = "Select B_ID,B_NAME from dbo.Storage_Panel"; mycmd = new SqlCommand(cmd, MyConnection); SqlDataReader reader = null; reader = mycmd.ExecuteReader(); while (reader.Read()) { comboBox1.Items.Add(reader["B_NAME"]); } reader.Dispose(); mycmd.Dispose(); } catch (Exception RetExcep) { MessageBox.Show(RetExcep.ToString()); } }
private void Supplier_Load(object sender, EventArgs e) { try { // Storage Panel Query...// SqlConnection MyConnection = new SqlConnection(Form1.Conn_String); MyConnection.Open(); string cmd = "Select * from Storage_Panel Order by B_ID ASC"; SqlCommand mycmd = new SqlCommand(cmd, MyConnection); SqlDataAdapter DAdap = new SqlDataAdapter(mycmd); DataTable DT = new DataTable(); DAdap.Fill(DT); dataGridView1.DataSource = DT; MyConnection.Close(); DAdap.Dispose(); //Selection Query for Supplier// MyConnection.Open(); cmd = "Select SUP_ID from dbo.Supplier"; mycmd = new SqlCommand(cmd, MyConnection); SqlDataReader reader = null; reader = mycmd.ExecuteReader(); while (reader.Read()) { comboBox1.Items.Add(reader["SUP_ID"]); comboBox2.Items.Add(reader["SUP_ID"]); } reader.Dispose(); mycmd.Dispose(); } catch (Exception RetExcep) { MessageBox.Show(RetExcep.ToString()); } }