예제 #1
0
        }//End of getPostsList

        public List <PostDataCarousel> getTopPostsList(int num)
        {
            String sqlString = "SELECT TOP " + num +
                               "  aaz01,aaz02,aaz03,aaz05" +
                               "  FROM aaz_file" +
                               "  ORDER BY aaz01 DESC" +
                               "";
            List <PostDataCarousel> postsList = new List <PostDataCarousel>();

            OpenConnection();
            actionResult = "SUCCESS";

            try
            {
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                sqlCommand.Connection  = sqlConnection;
                sqlCommand.CommandText = sqlString;

                SqlDataReader dataReader = sqlCommand.ExecuteReader();
                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        PostDataCarousel postdatacarousel = new PostDataCarousel();

                        postdatacarousel.Aaz01 = dataReader.GetString(dataReader.GetOrdinal("Aaz01"));
                        postdatacarousel.Aaz02 = dataReader.GetString(dataReader.GetOrdinal("Aaz02"));
                        postdatacarousel.Aaz03 = dataReader.GetString(dataReader.GetOrdinal("Aaz03"));
                        postdatacarousel.Aaz05 = dataReader.GetString(dataReader.GetOrdinal("Aaz05"));


                        postsList.Add(postdatacarousel);
                    }
                }
            }
            catch (Exception ex)
            {
                string v = "FAIL" + ex.Message;
                actionResult = v;
            }
            finally
            {
                CloseConnection();
            }

            return(postsList);
        }//End of getPostsList
        public ActionResult UpdatePost([Bind(Include = "Aaz01,Aaz02,Aaz03")] PostDataCarousel postdatacarousel)
        {
            SQLServerConnector sqlServerConnector = new SQLServerConnector();

            postdatacarousel.Aaz05 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            String result = sqlServerConnector.ConfirmedEdit(postdatacarousel);
            List <PostDataCarousel> listPosts = new List <PostDataCarousel>();

            if (result == "SUCCESS")
            {
                listPosts = sqlServerConnector.getPostsList();
            }

            ViewBag.ListOfPosts = listPosts;
            return(RedirectToAction("AddNewPost", "Post"));
        }
        public ActionResult Create([Bind(Include = "aaz02,aaz03 ")] PostDataCarousel postdatacarousel)
        {
            SQLServerConnector      sqlServerConnector = new SQLServerConnector();
            List <PostDataCarousel> listPosts;

            listPosts = sqlServerConnector.getPostsList();

            postdatacarousel.Aaz01 = DateTime.Now.ToString("yyyyMMddHHmmss");
            //postdatacarousel.Aaz02 = "";
            //postdatacarousel.Aaz03 = "";
            postdatacarousel.Aaz05 = DateTime.Now.ToString("yyyy-MM-dd ");



            String result = sqlServerConnector.InsertPostData(postdatacarousel);

            return(RedirectToAction("AddNewPost", "Post"));
        }//Create
예제 #4
0
        }//End of getPostsList

        public List <PostDataCarousel> getPostsListOnDemand(String sqlCriteria)
        {
            String sqlString = "SELECT * FROM aaz_file WHERE " + sqlCriteria;
            List <PostDataCarousel> postsList = new List <PostDataCarousel>();

            OpenConnection();
            actionResult = "SUCCESS";
            try
            {
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                sqlCommand.Connection  = sqlConnection;
                sqlCommand.CommandText = sqlString;

                SqlDataReader dataReader = sqlCommand.ExecuteReader();
                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        PostDataCarousel postdatacarousel = new PostDataCarousel();

                        postdatacarousel.Aaz01 = dataReader.GetString(dataReader.GetOrdinal("Aaz01"));
                        postdatacarousel.Aaz02 = dataReader.GetString(dataReader.GetOrdinal("Aaz02"));
                        postdatacarousel.Aaz03 = dataReader.GetString(dataReader.GetOrdinal("Aaz03"));
                        postdatacarousel.Aaz05 = dataReader.GetString(dataReader.GetOrdinal("Aaz05"));


                        postsList.Add(postdatacarousel);
                    }
                }
            }
            catch (Exception ex)
            {
                actionResult = "FAIL" + ex.Message;
            }
            finally
            {
                CloseConnection();
            }

            return(postsList);
        }
예제 #5
0
        public String InsertPostData(PostDataCarousel postdatacarousel)
        {
            String sqlString = "INSERT INTO aaz_file ( " +
                               " aaz01, aaz02, aaz03, aaz05  " +
                               ") VALUES ( " +
                               " @val01, @val02, @val03, @val05   " +
                               ")";

            OpenConnection();
            actionResult = "SUCCESS";

            try
            {
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                sqlCommand.Connection  = sqlConnection;
                sqlCommand.CommandText = sqlString;

                sqlCommand.Parameters.AddWithValue("@val01", postdatacarousel.Aaz01);
                sqlCommand.Parameters.AddWithValue("@val02", postdatacarousel.Aaz02);
                sqlCommand.Parameters.AddWithValue("@val03", postdatacarousel.Aaz03);
                sqlCommand.Parameters.AddWithValue("@val05", postdatacarousel.Aaz05);


                sqlCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                actionResult = "FAIL" + ex.Message;
            }
            finally
            {
                CloseConnection();
            }
            return(actionResult);
        }//End of Insert Into
예제 #6
0
        public String ConfirmedEdit(PostDataCarousel postdatacarousel)
        {
            String sqlString = " UPDATE  aaz_file " +
                               " SET aaz02 =  @val01," + "  aaz03 = @val02  " +
                               " WHERE aaz01 = @val03" +
                               "";



            actionResult = "SUCCESS";

            try
            {
                OpenConnection();
                SqlCommand sqlCommand = new SqlCommand(sqlString, sqlConnection);



                sqlCommand.Parameters.AddWithValue("@val01", postdatacarousel.Aaz02);
                sqlCommand.Parameters.AddWithValue("@val02", postdatacarousel.Aaz03);
                sqlCommand.Parameters.AddWithValue("@val03", postdatacarousel.Aaz01);



                sqlCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                actionResult = "FAIL" + ex.Message;
            }
            finally
            {
                CloseConnection();
            }
            return(actionResult);
        }