Exemplo n.º 1
0
        public Equipment(Character character, Dictionary <string, EquipmentItem> initDict)
        {
            AttachedCharacter = character;
            this.Slot         = initDict;

            ItemDAO = new ItemJsonDAO(jsonPath);
        }
        public bool Update(IItemDAO dao)
        {
            bool res = false;

            try
            {
                using (DataModel.DatabaseEntities db = new DataModel.DatabaseEntities())
                {
                    DataModel.tblItem item = db.tblItems.Where(x => x.ID == dao.ID).FirstOrDefault();
                    if (item != null)
                    {
                        item.Name       = dao.Name;
                        item.ParameterA = dao.ParameterA;
                        item.ParameterB = dao.ParameterB;

                        int i = db.SaveChanges();
                        res = true;
                    }
                }
            }
            catch
            {
                res = false;
            }

            return(res);
        }
        public bool Update(IItemDAO dao)
        {
            bool res = false;

            string sql = "UPDATE tblItems SET [Name]=@name, [ParameterA]=@parametera, [ParameterB]=@parameterb WHERE [ID]=@id";

            using (SQLiteConnection con = new SQLiteConnection(this.cs))
            {
                SQLiteCommand   cmd        = new SQLiteCommand(sql, con);
                SQLiteParameter id         = new SQLiteParameter("id", dao.ID);
                SQLiteParameter name       = new SQLiteParameter("name", dao.Name);
                SQLiteParameter parametera = new SQLiteParameter("parametera", dao.ParameterA);
                SQLiteParameter parameterb = new SQLiteParameter("parameterb", dao.ParameterB);
                cmd.Parameters.Add(id);
                cmd.Parameters.Add(name);
                cmd.Parameters.Add(parametera);
                cmd.Parameters.Add(parameterb);
                try
                {
                    con.Open();
                    int rows = cmd.ExecuteNonQuery();
                    if (rows == 1)
                    {
                        res = true;
                    }
                    con.Close();
                }
                catch (Exception ex)
                {
                    con.Close();
                }
            }

            return(res);
        }
        public long Add(IItemDAO dao)
        {
            object r = null;

            string sql = "INSERT INTO tblItems ([Name], [ParameterA], [ParameterB]) VALUES (@name, @parametera, @parameterb); SELECT last_insert_rowid();";

            using (SQLiteConnection con = new SQLiteConnection(this.cs))
            {
                SQLiteCommand   cmd        = new SQLiteCommand(sql, con);
                SQLiteParameter name       = new SQLiteParameter("name", dao.Name);
                SQLiteParameter parametera = new SQLiteParameter("parametera", dao.ParameterA);
                SQLiteParameter parameterb = new SQLiteParameter("parameterb", dao.ParameterB);
                cmd.Parameters.Add(name);
                cmd.Parameters.Add(parametera);
                cmd.Parameters.Add(parameterb);
                try
                {
                    con.Open();
                    r = cmd.ExecuteScalar();
                    con.Close();
                }
                catch
                {
                    con.Close();
                }
            }

            if (r != null)
            {
                return((long)r);
            }

            return(0);
        }
        public long Add(IItemDAO dao)
        {
            long id = 0;

            DataModel.tblItem item = new DataModel.tblItem();
            item.Name       = dao.Name;
            item.ParameterA = dao.ParameterA;
            item.ParameterB = dao.ParameterB;

            try
            {
                using (DataModel.DatabaseEntities db = new DataModel.DatabaseEntities())
                {
                    db.tblItems.Add(item);
                    int i = db.SaveChanges();
                    id = item.ID;
                }
            }
            catch
            {
                id = 0;
            }

            return(id);
        }
Exemplo n.º 6
0
        public ItemBO(IDALItemManager itemManager, IItemDAO dao)
        {
            this.itemManager = itemManager;

            this.id         = dao.ID;
            this.name       = dao.Name;
            this.parameterA = dao.ParameterA;
            this.parameterB = dao.ParameterB;
        }
        public IItemBO GetItem(long id)
        {
            IItemDAO dao = this.itemManager.Get(id);

            if (dao == null)
            {
                return(null);
            }

            return(new ItemBO(this.itemManager, dao));
        }
Exemplo n.º 8
0
        public Equipment(Character character, EquipmentItem main, EquipmentItem off,
                         EquipmentItem body, EquipmentItem charm1, EquipmentItem charm2)
        {
            Slot["MainHand"] = main;
            Slot["OffHand"]  = off;
            Slot["Body"]     = body;
            Slot["Charm 1"]  = charm1;
            Slot["Charm 2"]  = charm2;

            AttachedCharacter = character;

            ItemDAO = new ItemJsonDAO(jsonPath);
        }
        public IItemDAO Get(long id)
        {
            IItemDAO res = null;

            try
            {
                using (DataModel.DatabaseEntities db = new DataModel.DatabaseEntities())
                {
                    res = db.tblItems.Where(x => x.ID == id).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                res = null;
            }

            return(res);
        }
        public bool IsExist(long id)
        {
            bool res = false;

            try
            {
                using (DataModel.DatabaseEntities db = new DataModel.DatabaseEntities())
                {
                    IItemDAO item = db.tblItems.Where(x => x.ID == id).FirstOrDefault();
                    if (item != null)
                    {
                        res = true;
                    }
                }
            }
            catch
            {
                res = false;
            }

            return(res);
        }
        public IItemDAO Get(long id)
        {
            IItemDAO res = null;

            string sql = "SELECT * FROM tblItems WHERE [ID]=@id";

            using (SQLiteConnection con = new SQLiteConnection(this.cs))
            {
                SQLiteCommand   cmd = new SQLiteCommand(sql, con);
                SQLiteParameter p   = new SQLiteParameter("id", id);
                cmd.Parameters.Add(p);
                try
                {
                    con.Open();
                    using (SQLiteDataReader r = cmd.ExecuteReader())
                    {
                        if (r.HasRows)
                        {
                            r.Read();
                            res            = new ItemDAO();
                            res.ID         = Convert.ToInt64(r["ID"]);
                            res.Name       = Convert.ToString(r["Name"]);
                            res.ParameterA = Convert.ToDouble(r["ParameterA"]);
                            res.ParameterB = Convert.ToDouble(r["ParameterB"]);
                        }
                        r.Close();
                    }
                    con.Close();
                }
                catch
                {
                    con.Close();
                    res = null;
                }
            }

            return(res);
        }
Exemplo n.º 12
0
 public Requirements()
 {
     ItemDAO = new ItemJsonDAO(jsonPath);
 }
Exemplo n.º 13
0
 public Profession()
 {
     ItemDAO = new ItemJsonDAO(jsonPath);
 }
Exemplo n.º 14
0
 public ItemController(IItemDAO itemDAO, IBidDAO bidDAO)
 {
     this.itemDao = itemDAO;
     this.bidDao  = bidDAO;
 }
Exemplo n.º 15
0
 public ItemCreation()
 {
     ItemDAO = new ItemJsonDAO(jsonPath);
 }
Exemplo n.º 16
0
 public EquipmentBehavior()
 {
     ItemDAO = new ItemJsonDAO(jsonPath);
 }
Exemplo n.º 17
0
 public InventoryBehavior()
 {
     ItemDAO = new ItemJsonDAO(jsonPath);
 }
Exemplo n.º 18
0
 public ComandaBussines(IComandaDAO comandaDAO, IItemDAO itemDAO)
 {
     _comandaDAO = comandaDAO;
     _itemDAO    = itemDAO;
 }
Exemplo n.º 19
0
 public Equipment()
 {
     ItemDAO = new ItemJsonDAO(jsonPath);
 }