Esempio n. 1
0
        public GameTextItem GetOne(int ID)
        {
            var           item      = new GameTextItem();
            string        sql       = "SELECT * FROM [portal].[dbo].chuchaychay WHERE id = @id";
            SqlConnection conn      = new SqlConnection(Constants.DBConnection);
            SqlCommand    MyCommand = new SqlCommand(sql, conn);

            MyCommand.Parameters.AddWithValue("id", ID);
            SqlDataReader MyReader;

            conn.Open();
            MyReader = MyCommand.ExecuteReader();
            while (MyReader.Read())
            {
                item = new GameTextItem
                {
                    ID        = MyReader.GetInt32(MyReader.GetOrdinal("id")),
                    Title     = MyReader.GetString(MyReader.GetOrdinal("Title")),
                    Link      = MyReader.GetString(MyReader.GetOrdinal("Link")),
                    DataStart = MyReader.GetDateTime(MyReader.GetOrdinal("DataStart")),
                    DateEnd   = MyReader.GetDateTime(MyReader.GetOrdinal("DateEnd")),
                    IsDelete  = MyReader.GetBoolean(MyReader.GetOrdinal("IsDelete")),
                    Order     = MyReader.GetInt32(MyReader.GetOrdinal("Orders")),
                };
            }
            MyReader.Close();
            conn.Close();
            return(item);
        }
Esempio n. 2
0
        /*update 24/03*/

        public List <GameTextItem> GetAll()
        {
            var           lst       = new List <GameTextItem>();
            string        sql       = "SELECT * FROM [portal].[dbo].chuchaychay ORDER BY id DESC";
            SqlConnection conn      = new SqlConnection(Constants.DBConnection);
            SqlCommand    MyCommand = new SqlCommand(sql, conn);
            SqlDataReader MyReader;

            conn.Open();
            MyReader = MyCommand.ExecuteReader();
            while (MyReader.Read())
            {
                var item = new GameTextItem
                {
                    ID              = MyReader.GetInt32(MyReader.GetOrdinal("id")),
                    Title           = MyReader.GetString(MyReader.GetOrdinal("Title")),
                    Link            = MyReader.GetString(MyReader.GetOrdinal("Link")),
                    DataStart       = MyReader.GetDateTime(MyReader.GetOrdinal("DataStart")),
                    DateEnd         = MyReader.GetDateTime(MyReader.GetOrdinal("DateEnd")),
                    IsDelete        = MyReader.GetBoolean(MyReader.GetOrdinal("IsDelete")),
                    Order           = MyReader.GetInt32(MyReader.GetOrdinal("Orders")),
                    DataStartstring = MyReader.GetDateTime(MyReader.GetOrdinal("DataStart")).ToShortDateString(),
                    DateEndstring   = MyReader.GetDateTime(MyReader.GetOrdinal("DateEnd")).ToShortDateString()
                };

                lst.Add(item);
            }
            MyReader.Close();
            conn.Close();
            return(lst);
        }
Esempio n. 3
0
        public ActionResult Action(GameTextItem objSubmit)
        {
            if (objSubmit.ID == 0)
            {
                gamePlayerRepository.InsertTextRun(objSubmit.Title, objSubmit.Link, objSubmit.DataStart, objSubmit.DateEnd, objSubmit.IsDelete, objSubmit.Order);
            }
            else
            {
                gamePlayerRepository.UpdateTextRun(objSubmit.ID, objSubmit.Title, objSubmit.Link, objSubmit.DataStart, objSubmit.DateEnd, objSubmit.IsDelete, objSubmit.Order);
            }

            return(Json(new
            {
                Error = false
            }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        public ActionResult EditForm(int?id)
        {
            var obj = new GameTextItem();

            obj.DataStartstring = DateTime.Now.ToShortDateString();
            obj.DateEndstring   = DateTime.Now.ToShortDateString();
            if (id.HasValue)
            {
                obj = gamePlayerRepository.GetOneTextRunItem(id.Value);
                obj.DataStartstring = obj.DataStart.ToShortDateString();
                obj.DateEndstring   = obj.DateEnd.ToShortDateString();
            }
            return(Json(new
            {
                data = obj
            }, JsonRequestBehavior.AllowGet));
        }