Exemple #1
0
        public static int DeleteWall(string ID)
        {
            crudEntities dbEntities = new crudEntities();

            wall_main entWallMain = null;

            string sID = "";

            if (!string.IsNullOrEmpty(ID))
            {
                sID = ID;

                var q = dbEntities.wall_main.Where(m => m.id == sID);
                dbEntities.wall_main.RemoveRange(q);
                dbEntities.SaveChanges();

                return 0;

                //entWallMain = dbEntities.wall_main.FirstOrDefault(m => m.id == sID);
                //if (entWallMain != null)
                //{
                //    dbEntities.wall_main.Remove(entWallMain);
                //    dbEntities.SaveChanges();

                //    return 0;
                //}
                //else
                //    return -2;
            }
            else
                return -1;
        }
Exemple #2
0
        public static int CreateWall(string Subject, string Content)
        {
            crudEntities dbEntities = new crudEntities();

            try {
                wall_main entWallMain = new wall_main();

                entWallMain.id = System.DateTime.Now.ToString("yyyyMMddHHmmss");
                entWallMain.subject = Subject;
                entWallMain.content = Content;
                entWallMain.datetime = System.DateTime.Now;
                entWallMain.ipaddr = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();

                dbEntities.wall_main.Add(entWallMain);
                dbEntities.SaveChanges();

                return 0;
            }
            catch(Exception ex)
            {
                return -1;
            }
        }
Exemple #3
0
        public static int UpdateWall(string ID, string Subject, string Content)
        {
            crudEntities dbEntities = new crudEntities();

            wall_main entWallMain = null;

            string sID = "";
            string sSubject = "";
            string sContent = "";

            if ((!string.IsNullOrEmpty(ID)) && (!string.IsNullOrEmpty(Subject)) && (!string.IsNullOrEmpty(Content)))
            {
                sID = ID;

                sSubject = Subject;
                sContent = Content;

                entWallMain = dbEntities.wall_main.FirstOrDefault(m => m.id == sID);

                if (entWallMain != null)
                {
                    entWallMain.subject = sSubject;
                    entWallMain.content = sContent;
                    entWallMain.datetime = System.DateTime.Now;
                    entWallMain.ipaddr = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();

                    dbEntities.SaveChanges();

                    return 0;
                }
                else
                    return - 2;
            }
            else
                return -1;
        }