Example #1
0
        public int DeleteWithSql(entities.Cashier cashier)
        {
            entities.Cashier hasCashier = FindOne(cashier.GetId());

            SQLiteCommand command;

            command = new SQLiteCommand("DELETE FROM cashier WHERE id = @id", db.connection);

            command.Parameters.AddWithValue("@id", cashier.GetId());

            int num = command.ExecuteNonQuery();

            return(num);
        }
Example #2
0
        public int SaveWithSql(entities.Cashier cashier)
        {
            entities.Cashier hasCashier = FindOne(cashier.GetId());

            SQLiteCommand command;

            if (cashier.GetId() == 0 | hasCashier == null)
            {
                Add(cashier);
                command = new SQLiteCommand("INSERT INTO cashier(name) VALUES(@name)", db.connection);
            }
            else
            {
                command = new SQLiteCommand("UPDATE cashier SET name = @name WHERE id = @id ", db.connection);
            }

            command.Parameters.AddWithValue("@id", cashier.GetId());
            command.Parameters.AddWithValue("@name", cashier.GetName());

            int num = command.ExecuteNonQuery();

            return(num);
        }