Beispiel #1
0
        public void testAfModel() {
            Cashier c = new Cashier(42, "Morten", 59000m, "51255919");
            CashierCollection cc = new CashierCollection();
            cc.Add(c);

            foreach (Cashier tmpc in cc) { 
            }
        }
Beispiel #2
0
        public Facade()
        {
            dbf = new DBFacadeCashier("Data Source=10.165.150.52;Initial Catalog=nextgenPOS;Persist Security Info=True;User ID=dm122;Password=dm122");
            dbf.connectDB();
            cashierCollection = new CashierCollection();
            Cashier c = new Cashier(42, "Morten", 59000m, "51255919");
            cashierCollection.Add(c);
            //            dbf.closeDB();

        }
Beispiel #3
0
        public ICashier CreateCashier(string name, decimal salery, string telephone) 
        {
            int cashier_id = -42;

            // Bruges til at lave sql commandoer mod DMBMS'et
            // "createCashier" - Navn på den gemte procedure i DB'en
            SqlCommand cmd = new SqlCommand("createCashier", dbconn);
            cmd.CommandType = CommandType.StoredProcedure; // VIGTIG!!!!
           
            SqlParameter parameter;

            parameter = new SqlParameter("@cashier_id", SqlDbType.Int);
            //parameter.Value = DBNull.Value;
            parameter.Direction = ParameterDirection.Output;
            cmd.Parameters.Add(parameter);

            parameter = new SqlParameter("@name", SqlDbType.NVarChar, 30);
            parameter.Value = name;
            cmd.Parameters.Add(parameter);

            parameter = new SqlParameter("@salery", SqlDbType.Decimal);
            parameter.Value = salery;
            cmd.Parameters.Add(parameter);

            parameter = new SqlParameter("@telephone", SqlDbType.VarChar, 200);
            parameter.Value = telephone;
            cmd.Parameters.Add(parameter);
            cmd.ExecuteNonQuery();

            cashier_id = (int) cmd.Parameters["@cashier_id"].Value;

            ICashier theCashier = new Cashier(cashier_id, name, salery, telephone);


            //createCashier
            return theCashier;
        }
Beispiel #4
0
        public List<ICashier> LoadCashiers()
        {
            List<ICashier> cashiers = new List<ICashier>();

            SqlCommand cmd = new SqlCommand("LoadCashiers", dbconn);
            cmd.CommandType = CommandType.StoredProcedure; // VIGTIG!!!!

          
           

            SqlDataReader myreader = cmd.ExecuteReader();

            while (myreader.Read())
            {
                ICashier c = new Cashier(
                    (int) myreader["cashier_id"],
                    (string) myreader["name"],
                    (decimal) myreader["salery"],
                    (string) myreader["telephone"]);
                cashiers.Add(c);
            }
            myreader.Close();
            return cashiers;
        }