public ActionResult Create([Bind(Include = "zza02,zza03")] PostDataPhoneBook postDataPhoneBook)
        {
            PhoneBookSQLConnector    phoneBookSQLConnector = new PhoneBookSQLConnector();
            List <PostDataPhoneBook> listPhoneBooks;

            listPhoneBooks = phoneBookSQLConnector.getPostPhoneBookList();

            String result = phoneBookSQLConnector.InsertPostData(postDataPhoneBook);

            return(RedirectToAction("AddNewPhoneBookPost", "Post"));
        }
        public List <PostDataPhoneBook> getPostPhoneBookList()
        {
            String sqlString = "Select *from zza_file" +
                               " order by zza_file desc" +
                               "";
            List <PostDataPhoneBook> phoneBookList = new List <PostDataPhoneBook>();

            OpenConnection();
            actionResult = "SUCCESS";

            try
            {
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

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

                SqlDataReader dataReader = sqlCommand.ExecuteReader();
                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        PostDataPhoneBook postDataPhoneBook = new PostDataPhoneBook();

                        postDataPhoneBook.Zza01 = dataReader.GetString(dataReader.GetOrdinal("Zza01"));
                        postDataPhoneBook.Zza02 = dataReader.GetString(dataReader.GetOrdinal("Zza02"));
                        postDataPhoneBook.Zza03 = dataReader.GetString(dataReader.GetOrdinal("Zza03"));
                        postDataPhoneBook.Zza04 = dataReader.GetString(dataReader.GetOrdinal("Zza04"));
                        postDataPhoneBook.Zza05 = dataReader.GetString(dataReader.GetOrdinal("Zza05"));
                        postDataPhoneBook.Zza06 = dataReader.GetString(dataReader.GetOrdinal("Zza06"));
                        postDataPhoneBook.Zza07 = dataReader.GetString(dataReader.GetOrdinal("Zza07"));
                        postDataPhoneBook.Zza08 = dataReader.GetString(dataReader.GetOrdinal("Zza08"));
                        postDataPhoneBook.Zza09 = dataReader.GetString(dataReader.GetOrdinal("Zza09"));

                        phoneBookList.Add(postDataPhoneBook);
                    }
                }
            }
            catch (Exception ex)
            {
                actionResult = "FAIL" + ex.Message;
            }
            finally
            {
                CloseConnection();
            }
            return(phoneBookList);
        }
        public List <PostDataPhoneBook> getPostsListOnDemand(String sqlCriteria)
        {
            String sqlString = "SELECT * FROM aaz_file WHERE " + sqlCriteria;
            List <PostDataPhoneBook> phoneBookList = new List <PostDataPhoneBook>();

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

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

                SqlDataReader dataReader = sqlCommand.ExecuteReader();
                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        PostDataPhoneBook postDataPhoneBook = new PostDataPhoneBook();

                        postDataPhoneBook.Zza01 = dataReader.GetString(dataReader.GetOrdinal("Zza01"));
                        postDataPhoneBook.Zza02 = dataReader.GetString(dataReader.GetOrdinal("Zza02"));
                        postDataPhoneBook.Zza03 = dataReader.GetString(dataReader.GetOrdinal("Zza03"));
                        postDataPhoneBook.Zza04 = dataReader.GetString(dataReader.GetOrdinal("Zza04"));


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

            return(phoneBookList);
        }
        public String InsertPostData(PostDataPhoneBook postDataPhoneBook)
        {
            String sqlString = " Insert into zza_file (  " +
                               " zza01, zza02 , zza03, zza04, zza05 ,  zza06 , zza07 , zza08 , zza09 " +
                               "  ) VALUES ( " +
                               " @val01 , @val02 , @val03 , @val04 , @val05 , @val06 , @val07, @val08 ,@val09" +
                               ")";

            OpenConnection();
            actionResult = "SUCCESS";

            try
            {
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

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

                sqlCommand.Parameters.AddWithValue("@val01", postDataPhoneBook.Zza01);
                sqlCommand.Parameters.AddWithValue("@val02", postDataPhoneBook.Zza02);
                sqlCommand.Parameters.AddWithValue("@val03", postDataPhoneBook.Zza03);
                sqlCommand.Parameters.AddWithValue("@val04", postDataPhoneBook.Zza04);
                sqlCommand.Parameters.AddWithValue("@val05", postDataPhoneBook.Zza05);
                sqlCommand.Parameters.AddWithValue("@val06", postDataPhoneBook.Zza06);
                sqlCommand.Parameters.AddWithValue("@val07", postDataPhoneBook.Zza07);
                sqlCommand.Parameters.AddWithValue("@val08", postDataPhoneBook.Zza08);
                sqlCommand.Parameters.AddWithValue("@val09", postDataPhoneBook.Zza09);

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