Exemplo n.º 1
0
        public static void registerMember(string ti, string fn, string ln, string a, string c, string p, string te, string ty)
        {
            try
            {
                OleDbConnection myConnection = DBConnectivity.GetConnection();
                String          myQuery      = "INSERT INTO Member(Title, FirstName, Surname, Address, County, PostCode, Telephone, TypeOfMember) VALUES (@ti, @fn, @ln, @a, @c, @p, @te, @t)";
                OleDbCommand    myCommand    = new OleDbCommand(myQuery, myConnection);


                myCommand.Parameters.Add("@ti", OleDbType.VarChar).Value = ti;
                myCommand.Parameters.Add("@fn", OleDbType.VarChar).Value = fn;
                myCommand.Parameters.Add("@ln", OleDbType.VarChar).Value = ln;
                myCommand.Parameters.Add("@a", OleDbType.VarChar).Value  = a;
                myCommand.Parameters.Add("@c", OleDbType.VarChar).Value  = c;
                myCommand.Parameters.Add("@p", OleDbType.VarChar).Value  = p;
                myCommand.Parameters.Add("@te", OleDbType.VarChar).Value = te;
                myCommand.Parameters.Add("@ty", OleDbType.VarChar).Value = ty;

                try
                {
                    myConnection.Open();
                    myCommand.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception in DBHandler", ex);
                }
                finally
                {
                    myConnection.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error connecting to database");
            }
        }
Exemplo n.º 2
0
//Aquire information to edit the Stock field in the database
        public void stock()
        {
            String DVDminus = cboLoanDVDID.Text;
            String DVDadd   = cboReturnLoanID.Text;

            if (tabControl1.SelectedIndex == 1)
            {
                OleDbConnection myConnection = DBConnectivity.GetConnection();
                String          myQuery      = "SELECT DVDID FROM DVD WHERE DVDID=" + DVDminus + "";
                OleDbCommand    myCommand    = new OleDbCommand(myQuery, myConnection);
                int             DVDID;
                String          DVDIDStr;
                try
                {
                    myConnection.Open();
                    OleDbDataReader reader = myCommand.ExecuteReader();
                    while (reader.Read())
                    {
                        DVDID    = Int32.Parse(reader["DVDID"].ToString());
                        DVDIDStr = DVDID.ToString();
                        Loan.stockMinus(DVDminus);
                    }
                    reader.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
                finally
                {
                    myConnection.Close();
                }
            }
            if (tabControl1.SelectedIndex == 2)
            {
                OleDbConnection myConnection = DBConnectivity.GetConnection();
                String          myQuery      = "SELECT DVDID FROM Loan WHERE LoanID=" + DVDadd + "";
                OleDbCommand    myCommand    = new OleDbCommand(myQuery, myConnection);
                String          DVDIDStr;
                try
                {
                    myConnection.Open();
                    OleDbDataReader reader = myCommand.ExecuteReader();
                    while (reader.Read())
                    {
                        DVDIDStr = reader["DVDID"].ToString();
                        Loan.stockAdd(DVDIDStr);
                    }
                    reader.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
                finally
                {
                    myConnection.Close();
                }
            }

            refreshTable();
        }
Exemplo n.º 3
0
 public void fillFilmTitle(string cS)
 {
     OleDbConnection myConnection = DBConnectivity.GetConnection();
     DataTable       dt           = new DataTable();
     String          myQuery      = "SELECT DVDTitle FROM DVD WHERE DVDID=" + cS + "";
 }