Esempio n. 1
0
 public Costumer CostumerObject(Costumer phoneNo, Costumer cosFname, Costumer cosLname, Costumer email)
 {
     Costumer cost = new Costumer(phoneNo);
     cost.cosFname = cosFname;
     cost.cosLname = cosLname;
     cost.cosEmail = email;
     return cost;
 }
Esempio n. 2
0
 public Order(int p1, string p2, int p3, Screen screen, int p4, double p5, Person person, Costumer costumer1, Costumer costumer2)
 {
     // TODO: Complete member initialization
     this.p1 = p1;
     this.p2 = p2;
     this.p3 = p3;
     this.screen = screen;
     this.p4 = p4;
     this.p5 = p5;
     this.person = person;
     this.costumer1 = costumer1;
     this.costumer2 = costumer2;
 }
Esempio n. 3
0
 public Order(Movie title, String date, int time, Screen screenNo, int seatAmount, double price, int orderId, Person empId, Costumer cosId, Costumer phoneNo)
 {
     this.title = title;
     this.date = date;
     this.time = time;
     this.screenNo = screenNo;
     this.seatAmount = seatAmount;
     this.price = price;
     this.orderId = orderId;
     this.empId = empId;
     this.cosId = cosId;
     this.phoneNo = phoneNo;
 }
Esempio n. 4
0
 //Method to delete a Costumer.
 //same lazy errorhandling as InsertCos
 public int DeleteCos(Costumer cost)
 {
     int result = 0;
     try
     {
         dbConn.Open();
         SqlCommand command = new SqlCommand("DELETE FROM CinemaCostumer WHERE VALUES (@cosPhoneNo)", dbConn);
         command.Parameters.Add("@cosPhoneNo", SqlDbType.VarChar).Value = cost.cosPhoneNo;
         result = command.ExecuteNonQuery();
     }
     catch (SqlException)
     {
         result = -1;
     }
     finally
     {
         if (dbConn != null) { dbConn.Close(); }
     }
     return result;
 }
Esempio n. 5
0
 //Method to insert Costumer. Takes phoneNo, fname, lname and email as patameters - though only a phonenumber is needed.
 // 0 = default state. 1 = success. -1 = error. Perhaps should implement more usefull errorhandling.
 //(See SQLException class on msdn)
 public int InsertCos(Costumer cost)
 {
     int result = 0;
     try
     {
         dbConn.Open();
         SqlCommand command = new SqlCommand("INSERT INTO CinemaCostumer VALUES (@cosPhoneNo, @cosFname, @cosLname, @cosEmail)", dbConn);
         command.CommandType = CommandType.Text;
         command.Parameters.Add("@CosPhoneNo", SqlDbType.VarChar).Value = cost.cosPhoneNo;
         command.Parameters.Add("@cosFname", SqlDbType.Text).Value = cost.cosFname;
         command.Parameters.Add("@cosLname", SqlDbType.Text).Value = cost.cosLname;
         command.Parameters.Add("@CosEmail", SqlDbType.Text).Value = cost.cosEmail;
         result = command.ExecuteNonQuery();
     }
     catch (SqlException)
     {
         result = -1;
     }
     finally
     {
         if (dbConn != null) { dbConn.Close(); }
     }
     return result;
 }
Esempio n. 6
0
        //Method to insert Costumer. Takes phoneNo, fname, lname and email as patameters - though only a phonenumber is needed.
        // 0 = default state. 1 = success. -1 = error. Perhaps should implement more usefull errorhandling.
        //(See SQLException class on msdn)
        public int InsertCos(Costumer cost)
        {
            int result = 0;
            try
            {
                dbConn.Open();
                SqlCommand command = new SqlCommand("INSERT INTO CinemaCostumer (cosPhoneNo, cosFname, cosLname, cosEmal) VALUES ((@cosPhoneNo), (@cosFname), (@cosLname), (@cosEmail))", dbConn);

                command.Parameters.Add("@CosPhoneNo", SqlDbType.Int).Value = cost.cosPhoneNo;
                command.Parameters.Add("@cosFname", SqlDbType.VarChar).Value = cost.cosFname;
                command.Parameters.Add("@cosLname", SqlDbType.VarChar).Value = cost.cosLname;
                command.Parameters.Add("@CosEmail", SqlDbType.VarChar).Value = cost.cosEmail;
                result = command.ExecuteNonQuery();
            }
            catch (SqlException)
            {
                throw;
            }
            finally
            {
                dbConn.Close();
            }
            return result;
        }
Esempio n. 7
0
        //private string selectEmp = "SELECT empFname, empLname, empId FROM CinemaEmployee";
        //private string deleteCos = "DELETE FROM CinemaCostumer";
        //private string deleteEmp = "DELETE FROM CinemaEmployee";
        //Method to return costumer by phonenumber as input.
        public List<Costumer> ReadCos(int phoneNo)
        {
            Costumer cost;
            SqlDataReader reader = null;
            List<Costumer> cosList = new List<Costumer>();
            try
            {
                dbConn.Open();
                SqlCommand command = new SqlCommand(("SELECT (@phoneNo) FROM CinemaPerson"), dbConn);
                command.Parameters.Add("@phoneNo", SqlDbType.VarChar).Value = "%" + phoneNo + "%";
                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    cost = new Costumer((Costumer)reader["phoneNo"]);

                    //if (reader["fname" + "lname"] != null)
                    //{
                    //    cost.fname = (Costumer)reader["fname"];
                    //    cost.lname = (Costumer)reader["lname"];
                    //}
                    //if (reader["email"] != null)
                    //{
                    //    cost.cosEmail = (Costumer)reader["email"];
                    //}
                    cosList.Add(cost);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (dbConn != null)
                {
                    dbConn.Close();
                }
            }
            return cosList;
        }
Esempio n. 8
0
        //Method to return all Costumers.
        public List<Costumer> ReadAllCos()
        {
            Costumer cost;
            SqlDataReader reader = null;
            List<Costumer> allCosList = new List<Costumer>();

            try
            {
                dbConn.Open();
                SqlCommand command = new SqlCommand(selectCos, dbConn);
                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    cost = new Costumer((Costumer)reader["phoneNo"]);
                    //if (reader["fname" + "lname"] != null)
                    //{
                    //    cost.fname = (Costumer)reader["fname"];
                    //    cost.lname = (Costumer)reader["lname"];
                    //}
                    //if (reader["email"] != null)
                    //{
                    //    cost.cosEmail = (Costumer)reader["email"];

                    //}
                    allCosList.Add(cost);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (dbConn != null)
                {
                    dbConn.Close();
                }
            }
            return allCosList;
        }
 public int InsertCostumer(Costumer cost)
 {
     return pctrlh.InsertCos(cost);
 }
Esempio n. 10
0
 public int InsertCos(Costumer cost)
 {
     // insert costumer not made in PersonDB yet
     return pDB.InsertCos(cost);
 }
Esempio n. 11
0
        //Method to return costumer by phonenumber as input.
        public List<Costumer> ReadCos(int phoneNo)
        {
            Costumer cost = null;
            SqlDataReader reader = null;
            List<Costumer> cosList = new List<Costumer>();
            try
            {
                dbConn.Open();
                SqlCommand command = new SqlCommand(("SELECT * FROM CinemaCostumer WHERE (@cosPhoneNo) = (cosPhoneNo)"), dbConn);
                command.Parameters.Add("@phoneNo", SqlDbType.VarChar).Value = cost.cosPhoneNo;
                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    cost = new Costumer((int)reader["CosPhoneNo"], (string)reader["CosFname"], (string)reader["CosLname"], (string)reader["CosEmail"]);

                    cosList.Add(cost);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (dbConn != null)
                {
                    dbConn.Close();
                }
            }
            return cosList;
        }
Esempio n. 12
0
        //Method to return all Costumers.
        public List<Costumer> ReadAllCos()
        {
            Costumer cost;
            SqlDataReader reader = null;
            List<Costumer> allCosList = new List<Costumer>();

            try
            {
                dbConn.Open();
                SqlCommand command = new SqlCommand(("SELECT * FROM CinemaCostumer"), dbConn);
                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    cost = new Costumer((int)reader["CosPhoneNo"], (string)reader["CosFname"], (string)reader["CosLname"], (string)reader["CosEmail"]);

                    allCosList.Add(cost);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {

                    reader.Close();

                    dbConn.Close();

            }
            return allCosList;
        }
Esempio n. 13
0
 public int DeleteCos(Costumer cost)
 {
     //delete a costumer, not made in personDB yet
     return pDB.DeleteCos(cost);
 }