private static Tab_UserArticle_ViewLog ToModel(DataRow row)
        {
            Tab_UserArticle_ViewLog model = new Tab_UserArticle_ViewLog();

            model.Idx = row.IsNull("Idx")?null:(System.Int32?)row["Idx"];
            model.UserArticlesId_Fx = row.IsNull("UserArticlesId_Fx")?null:(System.Int32?)row["UserArticlesId_Fx"];
            model.IpAddress         = row.IsNull("IpAddress")?null:(System.String)row["IpAddress"];
            model.AccessDate        = row.IsNull("AccessDate")?null:(System.DateTime?)row["AccessDate"];
            return(model);
        }
        public int AddNew(Tab_UserArticle_ViewLog model)
        {
            string sql = "insert into Tab_UserArticle_ViewLog(UserArticlesId_Fx,IpAddress,AccessDate)  values(@UserArticlesId_Fx,@IpAddress,@AccessDate); select @@identity ;";
            int    Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql
                                                                 , new SqlParameter("@UserArticlesId_Fx", model.UserArticlesId_Fx)
                                                                 , new SqlParameter("@IpAddress", model.IpAddress)
                                                                 , new SqlParameter("@AccessDate", model.AccessDate)
                                                                 ));

            return(Idx);
        }
        public bool Update(Tab_UserArticle_ViewLog model)
        {
            string sql  = "update Tab_UserArticle_ViewLog set UserArticlesId_Fx=@UserArticlesId_Fx,IpAddress=@IpAddress,AccessDate=@AccessDate where Idx=@Idx";
            int    rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql
                                                    , new SqlParameter("@UserArticlesId_Fx", model.UserArticlesId_Fx)
                                                    , new SqlParameter("@IpAddress", model.IpAddress)
                                                    , new SqlParameter("@AccessDate", model.AccessDate)
                                                    , new SqlParameter("Idx", model.Idx)
                                                    );

            return(rows > 0);
        }
        public Tab_UserArticle_ViewLog Get(string Idx)
        {
            DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_UserArticle_ViewLog  where Idx=@Idx",
                                                    new SqlParameter("Idx", Idx)).Tables[0];

            if (dt.Rows.Count > 1)
            {
                throw new Exception("more than 1 row was found");
            }

            if (dt.Rows.Count <= 0)
            {
                return(null);
            }

            DataRow row = dt.Rows[0];
            Tab_UserArticle_ViewLog model = ToModel(row);

            return(model);
        }