コード例 #1
0
        private void button2_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 New_User_SignIn WHERE username='******' AND password='******'";
                OracleDataReader thisReader = thisCommand.ExecuteReader();

                if (thisReader.Read())
                {
                    User_Options oform = new User_Options();
                    oform.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("username or password incorrect");
                }
                CN.thisConnection.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #2
0
        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            try
            {
                textBox1.Text   = "";
                textBox2.Text   = "";
                button6.Enabled = false;

                connection CN = new connection();
                CN.thisConnection.Open();

                OracleCommand thisCommand = CN.thisConnection.CreateCommand();

                thisCommand.CommandText =
                    "SELECT * FROM New_User_SignIn where password= '******'";

                OracleDataReader thisReader = thisCommand.ExecuteReader();


                while (thisReader.Read())
                {
                    textBox1.Text = thisReader["email"].ToString();
                    textBox2.Text = thisReader["mobile"].ToString();
                }
                if (textBox1.Text != "")
                {
                    button6.Enabled = true;
                }

                CN.thisConnection.Close();
            }
            catch (Exception ex)
            {
            }
        }
コード例 #3
0
        private void button9_Click(object sender, EventArgs e)
        {
            try
            {
                if (cb_searchby.Text == "AvaliableBook")
                {
                }
                else if (cb_searchby.Text == "" || textBox1.Text == "")
                {
                    MessageBox.Show("Fill up fields then press ok");
                    return;
                }

                if (cb_searchby.SelectedIndex != 0)
                {
                    connection CN = new connection();
                    CN.thisConnection.Open();



                    OracleCommand thisCommand = new OracleCommand("select BookId,BookName,WriterName,BookPublishYear,QuantityOfBook,CatagoryName,AvaliableBook from bookstore where " + cb_searchby.Text + " like'%" + textBox1.Text + "%'order by BookName");

                    thisCommand.Connection  = CN.thisConnection;
                    thisCommand.CommandType = CommandType.Text;

                    OracleDataReader thisReader = thisCommand.ExecuteReader();

                    listView1.Items.Clear();

                    while (thisReader.Read())
                    {
                        ListViewItem lsvItem = new ListViewItem();
                        lsvItem.Text = thisReader["BookId"].ToString();
                        lsvItem.SubItems.Add(thisReader["BookName"].ToString());
                        lsvItem.SubItems.Add(thisReader["WriterName"].ToString());
                        lsvItem.SubItems.Add(thisReader["BookPublishYear"].ToString());
                        lsvItem.SubItems.Add(thisReader["QuantityOfBook"].ToString());
                        lsvItem.SubItems.Add(thisReader["CatagoryName"].ToString());
                        lsvItem.SubItems.Add(thisReader["AvaliableBook"].ToString());

                        listView1.Items.Add(lsvItem);
                    }



                    // thisCommand.Dispose();

                    CN.thisConnection.Close();
                }
            }
            catch (Exception dx)
            {
                MessageBox.Show(dx.ToString());
            }
        }
コード例 #4
0
        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text        = "";
            textBox6.Text        = "";
            textBox2.Text        = "";
            comboBox2.Text       = "";
            dateTimePicker1.Text = "";
            textBox3.Text        = "";

            if (textBox4.Text == "" || cb_searchby.Text == "")
            {
                MessageBox.Show("Fill Up all fields then press ok...");
                return;
            }

            connection CN = new connection();

            CN.thisConnection.Open();

            OracleCommand thisCommand = CN.thisConnection.CreateCommand();

            thisCommand.CommandText =
                "SELECT * FROM bookstore where  " + cb_searchby.Text + "= '" + textBox4.Text + "'";

            //where " + cb_searchby.Text + " like'%" + textBox1.Text + "%'order by BookId");

            OracleDataReader thisReader = thisCommand.ExecuteReader();


            while (thisReader.Read())
            {
                textBox1.Text        = thisReader["BookName"].ToString();
                textBox6.Text        = thisReader["BookPublishYear"].ToString();
                textBox2.Text        = thisReader["WriterName"].ToString();
                comboBox2.Text       = thisReader["CatagoryName"].ToString();
                dateTimePicker1.Text = thisReader["EntryDate"].ToString();
                textBox3.Text        = thisReader["QuantityOfBook"].ToString();


                try
                {
                    //string filePath = thisReader["picture"].ToString();
                    //this.pb_profilepics.Image = Image.FromFile(filePath);
                }
                catch
                { MessageBox.Show("successfull"); }
            }


            CN.thisConnection.Close();
        }
コード例 #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            usernamExistCheck();


            //////////////////////////////
            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "")
            {
                MessageBox.Show("Fill up all the fields");
                return;
            }

            try
            {
                connection cn = new connection();
                cn.thisConnection.Open();

                OracleCommand cmnd;

                string query;

                query = "insert into New_User_SignIn (username,password,email,mobile) values('" + textBox1.Text.ToString() + "'," + "'" + textBox2.Text.ToString() + "'," + "'" + textBox3.Text.ToString() + "'," + "'" + textBox4.Text.ToString() + "')";

                cmnd = new OracleCommand(query, cn.thisConnection);

                cmnd.ExecuteNonQuery();

                MessageBox.Show("add in database");

                cmnd.Dispose();

                cn.thisConnection.Close();

                cn.thisConnection.Dispose();

                Form1 ob = new Form1();
                ob.Show();
                this.Hide();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageBox.Show("Fill up all fields");
            }
        }
コード例 #6
0
        private void usernamExistCheck()
        {
            connection sv = new connection();

            sv.thisConnection.Open();

            OracleCommand thisCommand = sv.thisConnection.CreateCommand();

            thisCommand.CommandText = "select username from New_User_SignIn where username= '******'";

            thisCommand.Connection  = sv.thisConnection;
            thisCommand.CommandType = CommandType.Text;

            try
            {
                OracleDataReader thisReader = thisCommand.ExecuteReader();

                while (thisReader.Read())
                {
                    string sp = thisReader["username"].ToString();


                    try
                    {
                        if (sp != "")
                        {
                            MessageBox.Show("Username Id Already exists try another username then press ok!!!");
                            sv.thisConnection.Close();
                            return;
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Failure");
                    }
                }
                thisReader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Username is not Avaliable");
                return;
            }
        }
コード例 #7
0
        private void cb_searchby_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cb_searchby.SelectedIndex == 0)
            {
                textBox1.Text = "";

                connection CN = new connection();
                CN.thisConnection.Open();



                OracleCommand thisCommand = new OracleCommand("select BookId,BookName,WriterName,BookPublishYear,QuantityOfBook,CatagoryName,AvaliableBook from bookstore where AvaliableBook>0");

                thisCommand.Connection  = CN.thisConnection;
                thisCommand.CommandType = CommandType.Text;

                OracleDataReader thisReader = thisCommand.ExecuteReader();

                listView1.Items.Clear();

                while (thisReader.Read())
                {
                    ListViewItem lsvItem = new ListViewItem();
                    lsvItem.Text = thisReader["BookId"].ToString();
                    lsvItem.SubItems.Add(thisReader["BookName"].ToString());
                    lsvItem.SubItems.Add(thisReader["WriterName"].ToString());
                    lsvItem.SubItems.Add(thisReader["BookPublishYear"].ToString());
                    lsvItem.SubItems.Add(thisReader["QuantityOfBook"].ToString());
                    lsvItem.SubItems.Add(thisReader["CatagoryName"].ToString());
                    lsvItem.SubItems.Add(thisReader["AvaliableBook"].ToString());

                    listView1.Items.Add(lsvItem);
                }



                // thisCommand.Dispose();

                CN.thisConnection.Close();
            }
        }
コード例 #8
0
        private void button6_Click(object sender, EventArgs e)
        {
            connection sv = new connection();

            sv.thisConnection.Open();
            OracleCommand thisCommand = sv.thisConnection.CreateCommand();

            thisCommand.CommandText = "update New_User_SignIn set email = '" + textBox1.Text + "',mobile= '" + textBox2.Text + "'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();

            User_Options ob = new User_Options();

            ob.Show();
            this.Hide();
        }
コード例 #9
0
        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();
        }
コード例 #10
0
        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();
        }