private void btnUpdate_Book_Click(object sender, EventArgs e) { String booktitleSearch = this.textBox1.Text; SqlConnection conn = DB_Connection.GetConnection(); conn.Open(); string query = "SPUpdateBook"; SqlCommand newCmd = conn.CreateCommand(); newCmd.Connection = conn; newCmd.Parameters.AddWithValue("@title", this.textBox1.Text); newCmd.Parameters.AddWithValue("@topic", this.txtBTopic.Text); newCmd.Parameters.AddWithValue("@pname", this.txtBPName.Text); newCmd.Parameters.AddWithValue("@ctype", this.txtBCType.Text); newCmd.Parameters.AddWithValue("@notes", this.txtBNote.Text); newCmd.Parameters.AddWithValue("@pprice", this.txtBPPrice.Text); newCmd.Parameters.AddWithValue("@author", this.txtBAuthor.Text); newCmd.Parameters.AddWithValue("@enum", this.txtBENumber.Text); newCmd.Parameters.AddWithValue("@cyear", this.txtBCYear.Text); newCmd.Parameters.AddWithValue("@dpur", this.txtBDPurchased.Text); newCmd.Parameters.AddWithValue("@page", this.txtBPages.Text); newCmd.Parameters.AddWithValue("@sno", this.txtBSNo.Text); // newCmd.Parameters.Add("@booktitleSearch", this.textBox1.Text); newCmd.CommandType = CommandType.StoredProcedure; newCmd.CommandText = query; MessageBox.Show("no of rows effected" + newCmd.ExecuteNonQuery().ToString()); conn.Close(); }
private void button1_Click(object sender, EventArgs e) { SqlConnection conn = DB_Connection.GetConnection(); conn.Open(); ///////////////////////////// string query = "Select * from Authors Where AuthorID=" + int.Parse(this.textBox1.Text); SqlCommand cmd = new SqlCommand(query, conn); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { this.txtAID.Text = dr.GetInt32(0).ToString(); this.txtfName.Text = dr.GetString(1); this.txtLname.Text = dr.GetString(2); this.txtNationality.Text = dr.GetString(3); this.txtbDate.Text = dr.GetString(4); this.txtbPlace.Text = dr.GetString(5); this.txtTLoc.Text = dr.GetString(6); this.txtMInfluence.Text = dr.GetString(7); this.txtNotes.Text = dr.GetString(8); } //////////////////////////// conn.Close(); }
private void Searchbtn_Click(object sender, EventArgs e) { string tid = Convert.ToString(SearchBox.SelectedValue); // int tid = (SearchBox.SelectedValue); if (SearchBox.SelectedIndex != -1) { MessageBox.Show("" + SearchBox.SelectedValue); dataGridView.Show(); view1databtn.Show(); viewallbtn.Show(); SearchBox.Hide(); Searchbtn.Hide(); if (conn.State.ToString() == "Closed") { conn = DB_Connection.GetConnection(); conn.Open(); } string query = "Select * from Topic Where TopicID=" + tid; SqlDataAdapter sqlda = new SqlDataAdapter(query, conn); DataTable dt = new DataTable(); sqlda.Fill(dt); dataGridView.DataSource = dt; } else { MessageBox.Show("No Select"); } }
private void btnSubmitClick_Click(object sender, EventArgs e) { int idtosearch = int.Parse(this.textBox1.Text); SqlConnection conn = DB_Connection.GetConnection(); conn.Open(); string query = "SPUpdateAuthor"; SqlCommand newCmd = conn.CreateCommand(); newCmd.Connection = conn; newCmd.Parameters.AddWithValue("@aid", int.Parse(this.textBox1.Text)); newCmd.Parameters.AddWithValue("@fname", this.txtfName.Text); newCmd.Parameters.AddWithValue("@lname", this.txtLname.Text); newCmd.Parameters.AddWithValue("@nat", this.txtNationality.Text); newCmd.Parameters.AddWithValue("@bdate", this.txtbDate.Text); newCmd.Parameters.AddWithValue("@bplace", this.txtbPlace.Text); newCmd.Parameters.AddWithValue("@tloc", this.txtTLoc.Text); newCmd.Parameters.AddWithValue("@minf", this.txtMInfluence.Text); newCmd.Parameters.AddWithValue("@notes", this.txtNotes.Text); //newCmd.Parameters.Add("@idtosearch", int.Parse(this.textBox1.Text) ); newCmd.CommandType = CommandType.StoredProcedure; newCmd.CommandText = query; newCmd.ExecuteNonQuery(); MessageBox.Show("no of rows effected" + newCmd.ExecuteNonQuery().ToString()); conn.Close(); }
private void Search_Click(object sender, EventArgs e) { SqlConnection conn = DB_Connection.GetConnection(); conn.Open(); ///////////////////////////// string query = "Select * from Books Where Tittle Like '%" + this.textBox1.Text + "%'"; SqlCommand cmd = new SqlCommand(query, conn); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { this.txtBTitle.Text = dr.GetString(0); this.txtBTopic.Text = dr.GetString(1); this.txtBPName.Text = dr.GetString(2); this.txtBCType.Text = dr.GetString(3); this.txtBNote.Text = dr.GetString(4); this.txtBPPrice.Text = dr.GetString(5); this.txtBAuthor.Text = dr.GetString(6); this.txtBENumber.Text = dr.GetString(7); this.txtBCYear.Text = dr.GetString(8); this.txtBDPurchased.Text = dr.GetString(9); int aa = dr.GetInt32(10); this.txtBPages.Text = "" + aa; this.txtBSNo.Text = dr.GetString(11); } //////////////////////////// conn.Close(); }
public DB_Access() { try { conn = DB_Connection.GetConnection(); conn.Open(); } catch (System.TypeInitializationException) { } }
public ViewTopic() { InitializeComponent(); try { conn = DB_Connection.GetConnection(); conn.Open(); } catch (System.TypeInitializationException) { } //this.Width = Screen.PrimaryScreen.Bounds.Width; //this.Height = Screen.PrimaryScreen.Bounds.Height; this.Hide(); }
public void viewallbtn_Click(object sender, EventArgs e) { if (conn.State.ToString() == "Closed") { conn = DB_Connection.GetConnection(); conn.Open(); } //string query = "Select * from Topic"; SqlDataAdapter _sqlda = new SqlDataAdapter("ViewTopic", conn); DataTable dt = new DataTable(); _sqlda.Fill(dt); dataGridView.DataSource = dt; }
private void button1_Click(object sender, EventArgs e) { SqlConnection conn = DB_Connection.GetConnection(); conn.Open(); string query = "SPDelAuthor"; SqlCommand newCmd = conn.CreateCommand(); newCmd.Connection = conn; newCmd.Parameters.AddWithValue("@aid", int.Parse(this.textBox1.Text)); newCmd.CommandType = CommandType.StoredProcedure; newCmd.CommandText = query; MessageBox.Show("no of rows effected" + newCmd.ExecuteNonQuery().ToString()); conn.Close(); }
public DataTable getTable(string sp) { if (conn.State.ToString() == "Closed") { conn = DB_Connection.GetConnection(); conn.Open(); } SqlDataAdapter _sqlda = new SqlDataAdapter(sp, conn); DataTable dt = new DataTable(); _sqlda.Fill(dt); conn.Close(); return(dt); }
public void viewauthor() { if (conn.State.ToString() == "Closed") { conn = DB_Connection.GetConnection(); conn.Open(); } // string query = "Select * from Authors"; SqlDataAdapter _sqlda = new SqlDataAdapter("ViewAuthor", conn); DataTable dt = new DataTable(); _sqlda.Fill(dt); View_Author_Database vadb = new View_Author_Database(); vadb.datas(dt); conn.Close(); }
public void rptTitlesByTopic() { if (conn.State.ToString() == "Closed") { conn = DB_Connection.GetConnection(); conn.Open(); } //string query = "Select * from Quotations"; SqlDataAdapter _sqlda = new SqlDataAdapter("SPRptTitleByTopic", conn); DataTable dt = new DataTable(); _sqlda.Fill(dt); ViewQuotations vq = new ViewQuotations(); vq.datas(dt); conn.Close(); }
public void view_books() { if (conn.State.ToString() == "Closed") { conn = DB_Connection.GetConnection(); conn.Open(); } // string query = "Select * from Books"; SqlDataAdapter _sqlda = new SqlDataAdapter("ViewBooks", conn); DataTable dt = new DataTable(); _sqlda.Fill(dt); ViewBookDB vadb = new ViewBookDB(); vadb.datas(dt); conn.Close(); }
private void btnUpdate_Click(object sender, EventArgs e) { int SearchID = int.Parse(this.textBox1.Text); SqlConnection conn = DB_Connection.GetConnection(); conn.Open(); string query = "SpTopicUpdate"; SqlCommand newCmd = conn.CreateCommand(); newCmd.Connection = conn; newCmd.Parameters.AddWithValue("@id", int.Parse(this.textBox1.Text)); newCmd.Parameters.AddWithValue("@name", this.txtTopic.Text); // newCmd.Parameters.Add("@SearchID", int.Parse(this.textBox1.Text)); newCmd.CommandType = CommandType.StoredProcedure; newCmd.CommandText = query; MessageBox.Show("no of rows effected" + newCmd.ExecuteNonQuery().ToString()); conn.Close(); }
private void btnSearch_Click(object sender, EventArgs e) { SqlConnection conn = DB_Connection.GetConnection(); conn.Open(); ///////////////////////////// string query = "Select * from Topic Where TopicID=" + int.Parse(this.textBox1.Text); SqlCommand cmd = new SqlCommand(query, conn); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { this.txtTID.Text = dr.GetInt32(0).ToString(); this.txtTopic.Text = dr.GetString(1); } //////////////////////////// conn.Close(); }
/* public void datas(DataTable dt) * { * this.Show(); * this.dataGridView.DataSource = dt; * * }*/ private void ViewTopic_Load(object sender, EventArgs e) { if (conn.State.ToString() == "Closed") { conn = DB_Connection.GetConnection(); conn.Open(); } string query = "Select * from Topic"; SqlDataAdapter _sqlda = new SqlDataAdapter(query, conn); DataTable dt = new DataTable(); _sqlda.Fill(dt); SearchBox.DataSource = dt; SearchBox.Hide(); Searchbtn.Hide(); SearchBox.ValueMember = "TopicID"; SearchBox.DisplayMember = "Topic"; SearchBox.SelectedIndex = -1; }
private void button1_Click(object sender, EventArgs e) { SqlConnection conn = DB_Connection.GetConnection(); conn.Open(); ///////////////////////////// string query = "Select * from Quotations Where QuoteID=" + int.Parse(this.textBox1.Text); SqlCommand cmd = new SqlCommand(query, conn); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { this.txtQID.Text = dr.GetInt32(0).ToString(); this.txtBook.Text = dr.GetString(1); this.txtAuthor.Text = dr.GetString(2); this.txtPNo.Text = dr.GetString(3); this.txtQuote.Text = dr.GetString(4); } //////////////////////////// conn.Close(); }
private void btnUpdate_Click(object sender, EventArgs e) { int qidtosearch = int.Parse(this.textBox1.Text); SqlConnection conn = DB_Connection.GetConnection(); conn.Open(); string query = "SPUpdateQuotation"; SqlCommand newCmd = conn.CreateCommand(); newCmd.Connection = conn; newCmd.Parameters.AddWithValue("@qtid", int.Parse(this.textBox1.Text)); newCmd.Parameters.AddWithValue("@book", this.txtBook.Text); newCmd.Parameters.AddWithValue("@author", this.txtAuthor.Text); newCmd.Parameters.AddWithValue("@pno", this.txtPNo.Text); newCmd.Parameters.AddWithValue("@quote", this.txtQuote.Text); // newCmd.Parameters.Add("@qidtosearch", int.Parse(this.textBox1.Text)); newCmd.CommandType = CommandType.StoredProcedure; newCmd.CommandText = query; MessageBox.Show("no of rows effected" + newCmd.ExecuteNonQuery().ToString()); conn.Close(); }