private void button9_Click(object sender, EventArgs e) { Admin_Options ob = new Admin_Options(); ob.Show(); this.Hide(); }
private void butCancel_Click(object sender, EventArgs e) { Admin_Options ados = new Admin_Options(); ados.Show(); this.Hide(); }
private void button10_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "") { MessageBox.Show("Fill up all the fields for Login"); return; } try { connection CN = new connection(); CN.thisConnection.Open(); OracleCommand thisCommand = new OracleCommand(); thisCommand.Connection = CN.thisConnection; thisCommand.CommandText = "SELECT * FROM admin WHERE username='******' AND password='******'"; OracleDataReader thisReader = thisCommand.ExecuteReader(); if (thisReader.Read()) { Admin_Options oform = new Admin_Options(); oform.Show(); this.Hide(); } else { MessageBox.Show("username or password incorrect"); } CN.thisConnection.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void button6_Click(object sender, EventArgs e) { connection sv = new connection(); sv.thisConnection.Open(); OracleCommand thisCommand = sv.thisConnection.CreateCommand(); thisCommand.CommandText = "update admin set username = '******',password= '******'where password= '******'"; thisCommand.Connection = sv.thisConnection; thisCommand.CommandType = CommandType.Text; try { int a = thisCommand.ExecuteNonQuery(); if (a == 1) { MessageBox.Show("Updated Successfully"); } else { MessageBox.Show("Not Updated...Insert your old Password Perfectly"); return; } } catch (Exception ex) { MessageBox.Show("Not Updated"); } sv.thisConnection.Close(); this.Close(); Admin_Options ob = new Admin_Options(); ob.Show(); this.Hide(); }
private void button9_Click(object sender, EventArgs e) { if (textBox5.Text == "") { MessageBox.Show("Fill Up all fields then press update..."); return; } connection sv = new connection(); sv.thisConnection.Open(); int newItems = int.Parse(textBox5.Text); if (textBox5.Text == "") { newItems = 0; } OracleCommand thisCommand = sv.thisConnection.CreateCommand(); thisCommand.CommandText = "update bookstore set AvaliableBook=AvaliableBook+" + newItems + ",QuantityOfBook=QuantityOfBook+" + newItems + " where BookName= '" + textBox1.Text + "'"; thisCommand.Connection = sv.thisConnection; thisCommand.CommandType = CommandType.Text; try { thisCommand.ExecuteNonQuery(); MessageBox.Show("Stock Updated Successfully"); } catch (Exception ex) { MessageBox.Show("Book is not Avaliable"); return; } Admin_Options ob = new Admin_Options(); ob.Show(); this.Hide(); }
private void button10_Click(object sender, EventArgs e) { connection sv = new connection(); sv.thisConnection.Open(); OracleCommand thisCommand = sv.thisConnection.CreateCommand(); thisCommand.CommandText = "select BookId from bookstore where BookId= '" + textBox4.Text + "'"; thisCommand.Connection = sv.thisConnection; thisCommand.CommandType = CommandType.Text; try { OracleDataReader thisReader = thisCommand.ExecuteReader(); while (thisReader.Read()) { string sp = thisReader["BookId"].ToString(); try { if (sp != "") { MessageBox.Show("Book Id Already exists try another code then press ok!!!"); sv.thisConnection.Close(); // textBox3.Text = ""; return; } } catch { MessageBox.Show("Failure"); } } thisReader.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); return; } if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" || comboBox2.Text == "") { MessageBox.Show("Fill up fields then press ok"); return; } OracleDataAdapter thisAdapter = new OracleDataAdapter("SELECT * FROM bookstore", sv.thisConnection); OracleCommandBuilder thisBuilder = new OracleCommandBuilder(thisAdapter); DataSet thisDataSet = new DataSet(); thisAdapter.Fill(thisDataSet, "bookstore"); DataRow thisRow = thisDataSet.Tables["bookstore"].NewRow(); try { thisRow["BookId"] = textBox4.Text; thisRow["BookName"] = textBox1.Text; thisRow["BookPublishYear"] = textBox5.Text; thisRow["WriterName"] = textBox2.Text; thisRow["QuantityOfBook"] = textBox3.Text; thisRow["CatagoryName"] = comboBox2.Text; thisRow["EntryDate"] = dateTimePicker1.Value.Date.ToString(); //dateTimePicker1.Value.Year.ToString(); thisRow["AvaliableBook"] = textBox3.Text; thisRow["SaleBook"] = 0; thisDataSet.Tables["bookstore"].Rows.Add(thisRow); thisAdapter.Update(thisDataSet, "bookstore"); MessageBox.Show("Add"); Admin_Options ob = new Admin_Options(); ob.Show(); this.Hide(); } catch (Exception ex) { Console.WriteLine(ex.Message); MessageBox.Show("Fill up all fields"); } sv.thisConnection.Close(); }