コード例 #1
0
ファイル: Form1.cs プロジェクト: shubhamid/lendabook
        private void button1_Click(object sender, EventArgs e)
        {
            connect1();
            comm = new MySqlCommand();
            comm.CommandText = "select * from database.login";
            ds=new DataSet();
            da = new MySqlDataAdapter(comm.CommandText, conn);
            da.Fill(ds, "login");
            dt=ds.Tables["login"];
            String username=textBox1.Text;
            String password=textBox2.Text;
            for(i=0;i<dt.Rows.Count;i++)
            {

                dr=dt.Rows[i];
                String u = dr["username"].ToString();
                String p = dr["password"].ToString();
                int id= int.Parse(dr["userid"].ToString());
                if (username.Equals(u))
                {
                    if (password.Equals(Decrypt(p)))
                    {
                        //MessageBox.Show(""+id);
                        menu m = new menu(id);
                        m.Show();
                        this.Hide();
                        break;

                    }
                }
            }
            if (i >= dt.Rows.Count)
            {
                Dialog1 d = new Dialog1();
                d.Show();
                conn.Close();
            }
        }
コード例 #2
0
ファイル: Browse.cs プロジェクト: shubhamid/lendabook
 private void button1_Click(object sender, EventArgs e)
 {
     menu m = new menu(id);
     this.Close();
     m.Show();
 }
コード例 #3
0
ファイル: Payment.cs プロジェクト: shubhamid/lendabook
 private void button2_Click(object sender, EventArgs e)
 {
     this.Hide();
     menu m = new menu(userid);
     m.Show();
 }
コード例 #4
0
ファイル: Payment.cs プロジェクト: shubhamid/lendabook
        private void button1_Click(object sender, EventArgs e)
        {
            connect1();
            comm2 = new MySqlCommand();
            comm2.Connection = conn;
            comm2.CommandText = "update database.userinfo1 SET points = points - '" + points + "' where userid = '" + userid + "'";
            comm2.CommandType = CommandType.Text;
            comm2.ExecuteNonQuery();
            conn.Close();

            connect1();
            comm2 = new MySqlCommand();
            comm2.Connection = conn;
            comm2.CommandText = "update database.books1 SET available = 'N' where bookid = '" + bookid + "'";
            comm2.CommandType = CommandType.Text;
            comm2.ExecuteNonQuery();
            conn.Close();

            connect1();
            comm = new MySqlCommand();
            comm.CommandText = "select * from database.courier";
            ds = new DataSet();
            da = new MySqlDataAdapter(comm.CommandText, conn);
            da.Fill(ds, "database.courier");
            dt = ds.Tables["database.courier"];
            i = dt.Rows.Count;
            int courierid = (i + 1);
            // MessageBox.Show("");
            comm2 = new MySqlCommand();
            comm2.Connection = conn;
            comm2.CommandText = "insert into database.courier(courierid,couriername,lender_id,borrower_id) values ('" + courierid + "','" + textBox1.Text + "','" + lenderid + "','" + userid + "')";
            comm2.CommandType = CommandType.Text;
            comm2.ExecuteNonQuery();
            comm2 = new MySqlCommand();
            comm2.Connection = conn;
            comm2.CommandText = "insert into database.bookborrow(bookid,userid) values ('" + bookid + "','" + userid + "')";
            comm2.CommandType = CommandType.Text;
            comm2.ExecuteNonQuery();
            comm2 = new MySqlCommand();
            comm2.Connection = conn;
            comm2.CommandText = "insert into database.dispatch(bookid,courierid,userid) values ('" + bookid + "','" + courierid + "','" + userid + "')";
            comm2.CommandType = CommandType.Text;
            comm2.ExecuteNonQuery();

            conn.Close();
            connect1();
            comm1 = new MySqlCommand();
            comm1.Connection = conn;
            comm1.CommandText = "select * from database.books1 where bookid =" + bookid;
            comm1.CommandType = CommandType.Text;
            MySqlDataReader read1 = comm1.ExecuteReader();
            while (read1.Read())
            {
                bookname = ((read1["bookname"]).ToString());
            }
            //label3.Text = "Points to be used : " + points;
            read1.Close();
            conn.Close();

            MessageBox.Show("Thanks for using the Lend A Book System to borrow " + bookname + "! \nIt will take 3-4 days for the courier to deliver the product to your address.\n\nWe look forward to helping you again!");
            this.Hide();
            menu m = new menu(userid);
            m.Show();
        }
コード例 #5
0
ファイル: Lend.cs プロジェクト: shubhamid/lendabook
        private void button1_Click(object sender, EventArgs e)
        {
            int j=0;
            String bookname = textBox1.Text;
            String author = textBox2.Text;
            int point = (int.Parse(textBox3.Text)) / 10;
            int year = int.Parse(comboBox1.SelectedItem.ToString());
            if(radioButton1.Checked)
               binding=radioButton1.Text;
            if(radioButton2.Checked)
               binding=radioButton2.Text;
            if (binding.Equals("Hard Bound"))
                point += 20;
            if (binding.Equals("Paper Bound"))
                point += 10;
            if (year > 2000)
                point += 10;
            String[] arr = new String[6];
            if (checkBox1.Checked)
                arr[j++] = checkBox1.Text;
            if (checkBox2.Checked)
                arr[j++] = checkBox2.Text;
            if (checkBox3.Checked)
                arr[j++] = checkBox3.Text;
            if (checkBox4.Checked)
                arr[j++] = checkBox4.Text;
            if (checkBox5.Checked)
                arr[j++] = checkBox5.Text;
            if (checkBox6.Checked)
                arr[j++] = checkBox6.Text;

            connect1();
            comm = new MySqlCommand();
            comm.CommandText = "select * from database.books1";
            ds = new DataSet();
            da = new MySqlDataAdapter(comm.CommandText, conn);
            da.Fill(ds, "database.books1");
            dt = ds.Tables["database.books1"];
            i = dt.Rows.Count;
            int bookid = (i + 1);
            // MessageBox.Show("");
            comm2 = new MySqlCommand();
            comm2.Connection = conn;
            comm2.CommandText = "insert into database.books1(bookid,bookname,points,binding,pubyear) values ('" + bookid + "','" + bookname + "','" + point + "','" + binding + "','" + year + "')";
            comm2.CommandType = CommandType.Text;
            comm2.ExecuteNonQuery();
            //MessageBox.Show("");
            for (int k = 0; k < j;k++ )
            {
                comm3 = new MySqlCommand();
                comm3.Connection = conn;
                comm3.CommandText = "insert into database.books3(bookid,genre) values ('" + bookid + "','" + arr[k] + "')";
                comm3.CommandType = CommandType.Text;
                comm3.ExecuteNonQuery();
            }
            comm1 = new MySqlCommand();
            comm1.Connection = conn;
            comm1.CommandText = "insert into database.books2(bookid,author) values ('" + bookid + "','" + author + "')";
            comm1.CommandType = CommandType.Text;
            comm1.ExecuteNonQuery();

            if(ans==true && textBox4.Text!=null)
            {
                comm1 = new MySqlCommand();
                comm1.Connection = conn;
                comm1.CommandText = "insert into database.books2(bookid,author) values ('" + bookid + "','" + textBox4.Text + "')";
                comm1.CommandType = CommandType.Text;
                comm1.ExecuteNonQuery();
            }
            //comm1 = new MySqlCommand();
            //comm1.Connection = conn;
            //comm1.CommandText = "insert into database.booklender(bookid,userid) values ('" + bookid + "','" + id + "')";
            //comm1.CommandType = CommandType.Text;
            //comm1.ExecuteNonQuery();
            comm1 = new MySqlCommand();
            comm1.Connection = conn;
            comm1.CommandText = "update database.userinfo1 SET points = points + '" + point + "' where userid = '" + id + "'";
            comm1.CommandType = CommandType.Text;
            comm1.ExecuteNonQuery();
            MessageBox.Show("Thanks for Lending a book! \n" + point + " points have been added to your account! ");
            menu m = new menu(id);
            this.Close();
            m.Show();
        }