コード例 #1
0
ファイル: news.cs プロジェクト: lamjar/shop
        /// <summary>
        /// 得到资讯类别
        /// </summary>
        /// <returns></returns>
        public static List <newsinfo> getnewstype()
        {
            string          sql    = "select ntid,newstype from newstype";
            List <newsinfo> ntlist = new List <newsinfo>();

            try
            {
                DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.connectionstring, CommandType.Text, sql);
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    newsinfo item = new newsinfo();
                    item.ntid     = TypeParse.DbObjToInt(dr["ntid"].ToString(), 0);
                    item.newstype = TypeParse.DbObjToString(dr["newstype"].ToString(), "");
                    ntlist.Add(item);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return(ntlist);
        }
コード例 #2
0
ファイル: EditNews.aspx.cs プロジェクト: lamjar/shop
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["newsid"] != null)
            {
                int      inewsid = TypeParse.DbObjToInt(Request.QueryString["newsid"].ToString(), 0);
                newsinfo data    = news.getnewsinfo(inewsid.ToString());
                newsinfoDATA = data;
                if (!Page.IsPostBack)
                {
                    List <newsinfo> ntlist = news.getnewstype();
                    ntid.DataSource     = ntlist;
                    ntid.DataTextField  = "newstype";
                    ntid.DataValueField = "ntid";
                    ntid.DataBind();
                    for (int i = 0; i < ntid.Items.Count; i++)
                    {
                        if (ntid.Items[i].Value == data.ntid.ToString())
                        {
                            ntid.SelectedIndex = i;
                        }
                    }

                    ListItem l1 = new ListItem();
                    l1.Value = "0";
                    l1.Text  = "普通";
                    ListItem l2 = new ListItem();
                    l2.Value = "1";
                    l2.Text  = "置顶";
                    istop.Items.Add(l1);
                    istop.Items.Add(l2);
                    if (data.istop == 0)
                    {
                        for (int k = 0; k < istop.Items.Count; k++)
                        {
                            if (istop.Items[k].Value == "0")
                            {
                                istop.SelectedIndex = k;
                            }
                        }
                    }
                    if (data.istop == 1)
                    {
                        for (int k = 0; k < istop.Items.Count; k++)
                        {
                            if (istop.Items[k].Value == "1")
                            {
                                istop.SelectedIndex = k;
                            }
                        }
                    }
                    newsfrom.Value   = data.newsfrom;
                    newstitle.Value  = data.newstitle;
                    newswriter.Value = data.newswriter;
                    oldnewsimg.Value = data.newsimg;
                    snewsid.Value    = inewsid.ToString();
                    newsnote.Value   = data.newsnote;
                    editor_id.Value  = data.ninfo;
                }
            }
        }
コード例 #3
0
ファイル: news.cs プロジェクト: lamjar/shop
        /// <summary>
        /// 根据ID读取资讯信息
        /// </summary>
        /// <param name="newsid"></param>
        /// <returns></returns>
        public static newsinfo getnewsinfo(string newsid)
        {
            string   sql  = "select news.newsid,news.newstitle,news.newswriter,news.newsfrom,news.newsnote,news.adddate,news.ntid,newstype.newstype,news.ninfo,news.istop,news.newsimg,news.userid from news,newstype where news.ntid=newstype.ntid and news.newsid=" + newsid + "";
            newsinfo item = new newsinfo();

            try
            {
                SqlDataReader dr = SqlHelper.ExecuteReader(SqlHelper.connectionstring, CommandType.Text, sql);
                if (dr.Read())
                {
                    item.newsid     = TypeParse.DbObjToInt(dr["newsid"].ToString(), 0);
                    item.newstitle  = TypeParse.DbObjToString(dr["newstitle"].ToString(), "");
                    item.newswriter = TypeParse.DbObjToString(dr["newswriter"].ToString(), "");
                    item.ntid       = TypeParse.DbObjToInt(dr["ntid"].ToString(), 1);
                    item.istop      = TypeParse.DbObjToInt(dr["istop"].ToString(), 0);
                    item.newsfrom   = TypeParse.DbObjToString(dr["newsfrom"].ToString(), "");
                    item.newsnote   = TypeParse.DbObjToString(dr["newsnote"].ToString(), "");
                    item.ninfo      = TypeParse.DbObjToString(dr["ninfo"].ToString(), "");
                    item.newstype   = TypeParse.DbObjToString(dr["newstype"].ToString(), "");
                    item.adddate    = TypeParse.DbObjToDateTime(dr["adddate"].ToString(), DateTime.Now);
                    item.newsimg    = TypeParse.DbObjToString(dr["newsimg"].ToString(), "noimg.jpg");
                    item.userid     = TypeParse.DbObjToString(dr["userid"].ToString(), "");
                    dr.Close();
                    dr.Dispose();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return(item);
        }
コード例 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (RouteData.Values["newsid"] != null)
     {
         string   nid  = RouteData.Values["newsid"].ToString();
         newsinfo item = news.getnewsinfo(nid);
         newstitleHTML   = item.newstitle;
         newscontentHTML = item.ninfo;
     }
     else
     {
         Response.Redirect("/Default");
     }
 }
コード例 #5
0
        public string editnewstype(string ntid, string s_newstype)
        {
            newsinfo data = new newsinfo();

            data.newstype = HttpUtility.UrlDecode(TypeParse.DbObjToString(s_newstype, ""));
            data.ntid     = TypeParse.DbObjToInt(ntid, 0);
            bool result = news.editnewstype(data);

            if (result)
            {
                return("t");
            }
            else
            {
                return("f");
            }
        }
コード例 #6
0
        public string addnewstype(string s_newstype)
        {
            string   strit = HttpUtility.UrlDecode(TypeParse.DbObjToString(s_newstype, ""));
            newsinfo data  = new newsinfo();

            data.newstype = strit;
            bool result = news.addnewstype(data);

            if (result)
            {
                return("t");
            }
            else
            {
                return("f");
            }
        }
コード例 #7
0
ファイル: news.cs プロジェクト: lamjar/shop
        /// <summary>
        /// 添加资讯
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static bool addnews(newsinfo data)
        {
            SqlParameter[] parms = new SqlParameter[10];
            parms[0]       = new SqlParameter("@userid", SqlDbType.Int);
            parms[0].Value = data.userid;
            parms[1]       = new SqlParameter("@newstitle", SqlDbType.VarChar, 20);
            parms[1].Value = data.newstitle;
            parms[2]       = new SqlParameter("@newsfrom", SqlDbType.VarChar, 20);
            parms[2].Value = data.newsfrom;
            parms[3]       = new SqlParameter("@newswriter", SqlDbType.VarChar, 50);
            parms[3].Value = data.newswriter;
            parms[4]       = new SqlParameter("@adddate", SqlDbType.DateTime);
            parms[4].Value = data.adddate;
            parms[5]       = new SqlParameter("@istop", SqlDbType.Int);
            parms[5].Value = data.istop;
            parms[6]       = new SqlParameter("@ntid", SqlDbType.Int);
            parms[6].Value = data.ntid;
            parms[7]       = new SqlParameter("@newsnote", SqlDbType.VarChar, 50);
            parms[7].Value = data.newsnote;
            parms[8]       = new SqlParameter("@ninfo", SqlDbType.Text);
            parms[8].Value = data.ninfo;
            parms[9]       = new SqlParameter("@newsimg", SqlDbType.VarChar, 50);
            parms[9].Value = data.newsimg;



            string sql = "insert into news (userid ,newstitle,newsfrom ,newswriter ,adddate ,istop ,ntid,newsnote,ninfo,newsimg) " +
                         "values (@userid,@newstitle,@newsfrom ,@newswriter ,@adddate ,@istop ,@ntid,@newsnote,@ninfo,@newsimg)";

            int result = 0;

            try
            {
                result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms);
            }
            catch (Exception E)
            {
                throw new Exception(E.Message);
                //Console.Write(E.Message);
            }
            finally
            { }
            return(result > 0);
        }
コード例 #8
0
ファイル: news.cs プロジェクト: uwitec/shop
        /// <summary>
        /// 添加资讯
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static bool addnews(newsinfo data)
        {
            SqlParameter[] parms = new SqlParameter[10];
            parms[0] = new SqlParameter("@userid",SqlDbType.Int);
            parms[0].Value = data.userid;
            parms[1] = new SqlParameter("@newstitle", SqlDbType.VarChar, 20);
            parms[1].Value = data.newstitle;
            parms[2] = new SqlParameter("@newsfrom", SqlDbType.VarChar, 20);
            parms[2].Value = data.newsfrom;
            parms[3] = new SqlParameter("@newswriter", SqlDbType.VarChar, 50);
            parms[3].Value = data.newswriter;
            parms[4] = new SqlParameter("@adddate",SqlDbType.DateTime);
            parms[4].Value = data.adddate;
            parms[5] = new SqlParameter("@istop",SqlDbType.Int);
            parms[5].Value = data.istop;
            parms[6] = new SqlParameter("@ntid",SqlDbType.Int);
            parms[6].Value = data.ntid;
            parms[7] = new SqlParameter("@newsnote", SqlDbType.VarChar, 50);
            parms[7].Value = data.newsnote;
            parms[8] = new SqlParameter("@ninfo", SqlDbType.Text);
            parms[8].Value = data.ninfo;
            parms[9] = new SqlParameter("@newsimg", SqlDbType.VarChar, 50);
            parms[9].Value = data.newsimg;

            string sql = "insert into news (userid ,newstitle,newsfrom ,newswriter ,adddate ,istop ,ntid,newsnote,ninfo,newsimg) " +
                        "values (@userid,@newstitle,@newsfrom ,@newswriter ,@adddate ,@istop ,@ntid,@newsnote,@ninfo,@newsimg)";

            int result = 0;
            try
            {
                result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms);

            }
            catch (Exception E)
            {
                throw new Exception(E.Message);
                //Console.Write(E.Message);
            }
            finally
            { }
            return result > 0;
        }
コード例 #9
0
ファイル: news.cs プロジェクト: uwitec/shop
 /// <summary>
 /// 添加资讯类别
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public static bool addnewstype(newsinfo data)
 {
     SqlParameter[] parms = new SqlParameter[1];
     parms[0] = new SqlParameter("@newstype", SqlDbType.VarChar, 20);
     parms[0].Value = data.newstype;
     string sql = "insert into newstype (newstype) values(@newstype)";
     int result = 0;
     try
     {
         result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     finally
     {
     }
     return result > 0;
 }
コード例 #10
0
ファイル: news.cs プロジェクト: lamjar/shop
        /// <summary>
        /// 绑定页面资讯列表
        /// </summary>
        /// <param name="n"></param>
        /// <param name="newstype"></param>
        /// <returns></returns>
        public static List <newsinfo> bindnewslist(int n, string newstype)
        {
            SqlParameter[] parms = new SqlParameter[1];
            parms[0]       = new SqlParameter("@newstype", SqlDbType.VarChar, 50);
            parms[0].Value = newstype;

            List <newsinfo> newslist = new List <newsinfo>();
            string          sql      = "SELECT TOP " + n + " news.newsid,news.newstitle,news.newswriter,news.newsfrom,news.newsnote,news.adddate,news.ntid,newstype.newstype,news.ninfo,news.istop,news.newsimg FROM news,newstype WHERE news.ntid=newstype.ntid AND newstype.newstype=@newstype ORDER BY news.istop desc,news.adddate desc";

            try
            {
                DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.connectionstring, CommandType.Text, sql, parms).Tables[0];
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        newsinfo item = new newsinfo();
                        item.newsid     = TypeParse.DbObjToInt(dr["newsid"].ToString(), 0);
                        item.newstitle  = TypeParse.DbObjToString(dr["newstitle"].ToString(), "");
                        item.newswriter = TypeParse.DbObjToString(dr["newswriter"].ToString(), "");
                        item.ntid       = TypeParse.DbObjToInt(dr["ntid"].ToString(), 1);
                        item.istop      = TypeParse.DbObjToInt(dr["istop"].ToString(), 0);
                        item.newsfrom   = TypeParse.DbObjToString(dr["newsfrom"].ToString(), "");
                        item.newsnote   = TypeParse.DbObjToString(dr["newsnote"].ToString(), "");
                        item.ninfo      = TypeParse.DbObjToString(dr["ninfo"].ToString(), "");
                        item.newstype   = TypeParse.DbObjToString(dr["newstype"].ToString(), "");
                        item.adddate    = TypeParse.DbObjToDateTime(dr["adddate"].ToString(), DateTime.Now);
                        item.newsimg    = TypeParse.DbObjToString(dr["newsimg"].ToString(), "noimg.jpg");
                        newslist.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return(newslist);
        }
コード例 #11
0
ファイル: news.cs プロジェクト: lamjar/shop
        /// <summary>
        /// 添加资讯类别
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static bool addnewstype(newsinfo data)
        {
            SqlParameter[] parms = new SqlParameter[1];
            parms[0]       = new SqlParameter("@newstype", SqlDbType.VarChar, 20);
            parms[0].Value = data.newstype;
            string sql    = "insert into newstype (newstype) values(@newstype)";
            int    result = 0;

            try
            {
                result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return(result > 0);
        }
コード例 #12
0
ファイル: news.cs プロジェクト: lamjar/shop
        /// <summary>
        /// 编辑资讯类别
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static bool editnewstype(newsinfo data)
        {
            SqlParameter[] parms = new SqlParameter[2];
            parms[0]       = new SqlParameter("@newstype", SqlDbType.VarChar, 20);
            parms[0].Value = data.newstype;
            parms[1]       = new SqlParameter("@ntid", SqlDbType.Int);
            parms[1].Value = data.ntid;
            string sql    = "update newstype set newstype=@newstype where ntid=@ntid";
            int    result = 0;

            try
            {
                result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
            }
            return(result > 0);
        }
コード例 #13
0
ファイル: news.cs プロジェクト: lamjar/shop
        /// <summary>
        /// 修改资讯信息
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static bool editnewsinfo(newsinfo data)
        {
            SqlParameter[] parms = new SqlParameter[9];
            parms[0]       = new SqlParameter("@newstitle", SqlDbType.VarChar, 100);
            parms[0].Value = data.newstitle;
            parms[1]       = new SqlParameter("@ninfo", SqlDbType.Text);
            parms[1].Value = data.ninfo;
            parms[2]       = new SqlParameter("@istop", SqlDbType.Int);
            parms[2].Value = data.istop;
            parms[3]       = new SqlParameter("@newswriter", SqlDbType.VarChar, 20);
            parms[3].Value = data.newswriter;
            parms[4]       = new SqlParameter("@newsfrom", SqlDbType.VarChar, 50);
            parms[4].Value = data.newsfrom;
            parms[5]       = new SqlParameter("@newsnote", SqlDbType.VarChar, 500);
            parms[5].Value = data.newsnote;
            parms[6]       = new SqlParameter("@ntid", SqlDbType.Int);
            parms[6].Value = data.ntid;
            parms[7]       = new SqlParameter("@newsimg", SqlDbType.VarChar, 50);
            parms[7].Value = data.newsimg;
            parms[8]       = new SqlParameter("@newsid", SqlDbType.Int);
            parms[8].Value = data.newsid;

            string sql    = "update news set newstitle=@newstitle,ninfo=@ninfo,istop=@istop,newswriter=@newswriter,newsfrom=@newsfrom,newsnote=@newsnote,ntid=@ntid,newsimg=@newsimg where newsid=@newsid";
            int    result = 0;

            try
            {
                result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms);
            }
            catch (Exception E)
            {
                throw new Exception(E.Message);
            }
            finally
            { }
            return(result > 0);
        }
コード例 #14
0
ファイル: news.cs プロジェクト: lamjar/shop
        /// <summary>
        /// 得到资讯列表
        /// </summary>
        /// <param name="pdata"></param>
        /// <returns></returns>
        public static List <newsinfo> getnews(pageinfo pdata)
        {
            List <newsinfo> newslist = new List <newsinfo>();

            try
            {
                DataTable dt = pagehelper.getpagedt(pdata);
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        newsinfo item = new newsinfo();
                        item.newsid     = TypeParse.DbObjToInt(dr["newsid"].ToString(), 0);
                        item.newstitle  = TypeParse.DbObjToString(dr["newstitle"].ToString(), "");
                        item.newswriter = TypeParse.DbObjToString(dr["newswriter"].ToString(), "");
                        item.ntid       = TypeParse.DbObjToInt(dr["ntid"].ToString(), 1);
                        item.istop      = TypeParse.DbObjToInt(dr["istop"].ToString(), 0);
                        item.newsfrom   = TypeParse.DbObjToString(dr["newsfrom"].ToString(), "");
                        item.newsnote   = TypeParse.DbObjToString(dr["newsnote"].ToString(), "");
                        item.ninfo      = TypeParse.DbObjToString(dr["ninfo"].ToString(), "");
                        item.newstype   = TypeParse.DbObjToString(dr["newstype"].ToString(), "");
                        item.adddate    = TypeParse.DbObjToDateTime(dr["adddate"].ToString(), DateTime.Now);
                        item.newsimg    = TypeParse.DbObjToString(dr["newsimg"].ToString(), "noimg.jpg");
                        item.userid     = TypeParse.DbObjToString(dr["userid"].ToString(), "");
                        newslist.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return(newslist);
        }
コード例 #15
0
ファイル: news.cs プロジェクト: uwitec/shop
        /// <summary>
        /// 绑定页面资讯列表
        /// </summary>
        /// <param name="n"></param>
        /// <param name="newstype"></param>
        /// <returns></returns>
        public static List<newsinfo> bindnewslist(int n, string newstype)
        {
            SqlParameter[] parms = new SqlParameter[1];
            parms[0] = new SqlParameter("@newstype", SqlDbType.VarChar, 50);
            parms[0].Value = newstype;

            List<newsinfo> newslist = new List<newsinfo>();
            string sql = "SELECT TOP " + n + " news.newsid,news.newstitle,news.newswriter,news.newsfrom,news.newsnote,news.adddate,news.ntid,newstype.newstype,news.ninfo,news.istop,news.newsimg FROM news,newstype WHERE news.ntid=newstype.ntid AND newstype.newstype=@newstype ORDER BY news.istop desc,news.adddate desc";

            try
            {
                DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.connectionstring, CommandType.Text, sql, parms).Tables[0];
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        newsinfo item = new newsinfo();
                        item.newsid = TypeParse.DbObjToInt(dr["newsid"].ToString(),0);
                        item.newstitle = TypeParse.DbObjToString(dr["newstitle"].ToString(), "");
                        item.newswriter = TypeParse.DbObjToString(dr["newswriter"].ToString(), "");
                        item.ntid = TypeParse.DbObjToInt(dr["ntid"].ToString(), 1);
                        item.istop = TypeParse.DbObjToInt(dr["istop"].ToString(), 0);
                        item.newsfrom = TypeParse.DbObjToString(dr["newsfrom"].ToString(), "");
                        item.newsnote = TypeParse.DbObjToString(dr["newsnote"].ToString(), "");
                        item.ninfo = TypeParse.DbObjToString(dr["ninfo"].ToString(), "");
                        item.newstype = TypeParse.DbObjToString(dr["newstype"].ToString(), "");
                        item.adddate = TypeParse.DbObjToDateTime(dr["adddate"].ToString(), DateTime.Now);
                        item.newsimg = TypeParse.DbObjToString(dr["newsimg"].ToString(), "noimg.jpg");
                        newslist.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return newslist;
        }
コード例 #16
0
ファイル: news.cs プロジェクト: uwitec/shop
 /// <summary>
 /// 得到资讯类别
 /// </summary>
 /// <returns></returns>
 public static List<newsinfo> getnewstype()
 {
     string sql = "select ntid,newstype from newstype";
     List<newsinfo> ntlist = new List<newsinfo>();
     try
     {
         DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.connectionstring, CommandType.Text, sql);
         foreach (DataRow dr in ds.Tables[0].Rows)
         {
             newsinfo item = new newsinfo();
             item.ntid = TypeParse.DbObjToInt(dr["ntid"].ToString(), 0);
             item.newstype = TypeParse.DbObjToString(dr["newstype"].ToString(), "");
             ntlist.Add(item);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     finally
     {
     }
     return ntlist;
 }
コード例 #17
0
ファイル: news.cs プロジェクト: uwitec/shop
 /// <summary>
 /// 根据ID读取资讯信息
 /// </summary>
 /// <param name="newsid"></param>
 /// <returns></returns>
 public static newsinfo getnewsinfo(string newsid)
 {
     string sql = "select news.newsid,news.newstitle,news.newswriter,news.newsfrom,news.newsnote,news.adddate,news.ntid,newstype.newstype,news.ninfo,news.istop,news.newsimg,news.userid from news,newstype where news.ntid=newstype.ntid and news.newsid=" + newsid + "";
     newsinfo item = new newsinfo();
     try
     {
         SqlDataReader dr = SqlHelper.ExecuteReader(SqlHelper.connectionstring, CommandType.Text, sql);
         if (dr.Read())
         {
             item.newsid = TypeParse.DbObjToInt(dr["newsid"].ToString(), 0);
             item.newstitle = TypeParse.DbObjToString(dr["newstitle"].ToString(), "");
             item.newswriter = TypeParse.DbObjToString(dr["newswriter"].ToString(), "");
             item.ntid = TypeParse.DbObjToInt(dr["ntid"].ToString(), 1);
             item.istop = TypeParse.DbObjToInt(dr["istop"].ToString(), 0);
             item.newsfrom = TypeParse.DbObjToString(dr["newsfrom"].ToString(), "");
             item.newsnote = TypeParse.DbObjToString(dr["newsnote"].ToString(), "");
             item.ninfo = TypeParse.DbObjToString(dr["ninfo"].ToString(), "");
             item.newstype = TypeParse.DbObjToString(dr["newstype"].ToString(), "");
             item.adddate = TypeParse.DbObjToDateTime(dr["adddate"].ToString(), DateTime.Now);
             item.newsimg = TypeParse.DbObjToString(dr["newsimg"].ToString(), "noimg.jpg");
             item.userid = TypeParse.DbObjToString(dr["userid"].ToString(), "");
             dr.Close();
             dr.Dispose();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     finally
     {
     }
     return item;
 }
コード例 #18
0
ファイル: news.cs プロジェクト: uwitec/shop
 /// <summary>
 /// 得到资讯列表
 /// </summary>
 /// <param name="pdata"></param>
 /// <returns></returns>
 public static List<newsinfo> getnews(pageinfo pdata)
 {
     List<newsinfo> newslist = new List<newsinfo>();
     try
     {
         DataTable dt = pagehelper.getpagedt(pdata);
         if (dt != null)
         {
             foreach (DataRow dr in dt.Rows)
             {
                 newsinfo item = new newsinfo();
                 item.newsid = TypeParse.DbObjToInt(dr["newsid"].ToString(), 0);
                 item.newstitle = TypeParse.DbObjToString(dr["newstitle"].ToString(), "");
                 item.newswriter = TypeParse.DbObjToString(dr["newswriter"].ToString(), "");
                 item.ntid = TypeParse.DbObjToInt(dr["ntid"].ToString(), 1);
                 item.istop = TypeParse.DbObjToInt(dr["istop"].ToString(), 0);
                 item.newsfrom = TypeParse.DbObjToString(dr["newsfrom"].ToString(), "");
                 item.newsnote = TypeParse.DbObjToString(dr["newsnote"].ToString(), "");
                 item.ninfo = TypeParse.DbObjToString(dr["ninfo"].ToString(), "");
                 item.newstype = TypeParse.DbObjToString(dr["newstype"].ToString(), "");
                 item.adddate = TypeParse.DbObjToDateTime(dr["adddate"].ToString(), DateTime.Now);
                 item.newsimg = TypeParse.DbObjToString(dr["newsimg"].ToString(), "noimg.jpg");
                 item.userid = TypeParse.DbObjToString(dr["userid"].ToString(), "");
                 newslist.Add(item);
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     finally
     {
     }
     return newslist;
 }
コード例 #19
0
ファイル: news.cs プロジェクト: uwitec/shop
 /// <summary>
 /// 编辑资讯类别
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public static bool editnewstype(newsinfo data)
 {
     SqlParameter[] parms = new SqlParameter[2];
     parms[0] = new SqlParameter("@newstype", SqlDbType.VarChar, 20);
     parms[0].Value = data.newstype;
     parms[1] = new SqlParameter("@ntid",SqlDbType.Int);
     parms[1].Value = data.ntid;
     string sql = "update newstype set newstype=@newstype where ntid=@ntid";
     int result = 0;
     try
     {
         result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
     }
     return result > 0;
 }
コード例 #20
0
ファイル: news.cs プロジェクト: uwitec/shop
        /// <summary>
        /// 修改资讯信息
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static bool editnewsinfo(newsinfo data)
        {
            SqlParameter[] parms = new SqlParameter[9];
            parms[0] = new SqlParameter("@newstitle", SqlDbType.VarChar, 100);
            parms[0].Value = data.newstitle;
            parms[1] = new SqlParameter("@ninfo", SqlDbType.Text);
            parms[1].Value = data.ninfo;
            parms[2] = new SqlParameter("@istop",SqlDbType.Int);
            parms[2].Value = data.istop;
            parms[3] = new SqlParameter("@newswriter", SqlDbType.VarChar, 20);
            parms[3].Value = data.newswriter;
            parms[4] = new SqlParameter("@newsfrom", SqlDbType.VarChar, 50);
            parms[4].Value = data.newsfrom;
            parms[5] = new SqlParameter("@newsnote", SqlDbType.VarChar, 500);
            parms[5].Value = data.newsnote;
            parms[6] = new SqlParameter("@ntid",SqlDbType.Int);
            parms[6].Value = data.ntid;
            parms[7] = new SqlParameter("@newsimg", SqlDbType.VarChar, 50);
            parms[7].Value = data.newsimg;
            parms[8] = new SqlParameter("@newsid",SqlDbType.Int);
            parms[8].Value = data.newsid;

            string sql = "update news set newstitle=@newstitle,ninfo=@ninfo,istop=@istop,newswriter=@newswriter,newsfrom=@newsfrom,newsnote=@newsnote,ntid=@ntid,newsimg=@newsimg where newsid=@newsid";
            int result = 0;
            try
            {
                result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms);

            }
            catch (Exception E)
            {
                throw new Exception(E.Message);
            }
            finally
            { }
            return result > 0;
        }
コード例 #21
0
ファイル: EditNews.aspx.cs プロジェクト: lamjar/shop
        protected void EditNewsInfo(object sender, EventArgs e)
        {
            string uid = "";

            if (Request.Cookies["g_adminid"] != null)
            {
                uid = TypeParse.DbObjToString(Request.Cookies["g_adminid"].Value, "");
            }
            else
            {
                Response.Redirect("/Login/AdminLogin.aspx");
            }
            string uploadName = newsimg.Value;            //获取待上传图片的完整路径,包括文件名
            //string uploadName = InputFile.PostedFile.FileName;
            string pictureName = oldnewsimg.Value.Trim(); //上传后的图片名,以当前时间为文件名,确保文件名没有重复

            if (newsimg.Value != "")
            {
                int    idx    = uploadName.LastIndexOf(".");
                string suffix = uploadName.Substring(idx);//获得上传的图片的后缀名
                if (suffix.ToLower() != ".bmp" && suffix.ToLower() != ".jpg" && suffix.ToLower() != ".jpeg" && suffix.ToLower() != ".png" && suffix.ToLower() != ".gif")
                {
                    imgnote.InnerHtml = "<span style=\"color:red\">上传文件必须是图片格式!</span>";
                    return;
                }
                pictureName = DateTime.Now.Ticks.ToString() + suffix;
            }
            try
            {
                if (uploadName != "")
                {
                    string path = Server.MapPath("/Files/NewsImages/");
                    newsimg.PostedFile.SaveAs(path + pictureName);
                }
                newsinfo data = new newsinfo();
                data.newstitle  = newstitle.Value.Trim();
                data.ntid       = TypeParse.DbObjToInt(ntid.SelectedValue, 0);
                data.istop      = TypeParse.DbObjToInt(istop.SelectedValue, 0);
                data.newsfrom   = newsfrom.Value.Trim();
                data.newswriter = newswriter.Value.Trim();
                data.newsnote   = newsnote.Value.Trim();
                data.userid     = uid;
                data.ninfo      = editor_id.Value;
                data.adddate    = DateTime.Now;
                data.newsimg    = pictureName;
                data.newsstate  = 1;
                data.newsid     = TypeParse.DbObjToInt(snewsid.Value, 0);

                bool result = news.editnewsinfo(data);
                if (result)
                {
                    Response.Write("<script>alert('编辑新闻成功!');location.href='/Manager/NewsList.aspx';</script>");
                    return;
                }
                else
                {
                    Response.Write("<script>alert('编辑新闻失败!');location.href='/Manager/NewsList.aspx';</script>");
                    return;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #22
0
ファイル: AddNews.aspx.cs プロジェクト: uwitec/shop
        protected void AddNewsInfo(object sender, EventArgs e)
        {
            string uid="";
            if (Request.Cookies["g_adminid"] != null)
            {
                uid = TypeParse.DbObjToString(Request.Cookies["g_adminid"].Value, "");
            }
            else
            {
                Response.Redirect("/Login/AdminLogin.aspx");
            }
            string uploadName = newsimg.Value;//获取待上传图片的完整路径,包括文件名
            //string uploadName = InputFile.PostedFile.FileName;
            string pictureName = "noimg.jpg";//上传后的图片名,以当前时间为文件名,确保文件名没有重复
            if (newsimg.Value != "")
            {
                int idx = uploadName.LastIndexOf(".");
                string suffix = uploadName.Substring(idx);//获得上传的图片的后缀名
                if (suffix.ToLower() != ".bmp" && suffix.ToLower() != ".jpg" && suffix.ToLower() != ".jpeg" && suffix.ToLower() != ".png" && suffix.ToLower() != ".gif")
                {
                    imgnote.InnerHtml = "<span style=\"color:red\">上传文件必须是图片格式!</span>";
                    return;
                }
                pictureName = DateTime.Now.Ticks.ToString() + suffix;
            }
            try
            {
                if (uploadName != "")
                {
                    string path = Server.MapPath("/Files/NewsImages/");
                    newsimg.PostedFile.SaveAs(path + pictureName);
                }
                newsinfo data = new newsinfo();
                data.newstitle = newstitle.Value.Trim();
                data.ntid = TypeParse.DbObjToInt(ntID.SelectedValue, 0);
                data.istop = TypeParse.DbObjToInt(istop.SelectedValue, 0);
                data.newsfrom = newsfrom.Value.Trim();
                data.newswriter = newswriter.Value.Trim();
                data.newsnote = newsnote.Value.Trim();
                data.userid = uid;
                data.ninfo =editor_id.Value;
                data.adddate = DateTime.Now;
                data.newsimg = pictureName;
                data.newsstate = 1;

                bool result = news.addnews(data);
                if (result)
                {
                    Response.Write("<script>alert('添加新闻成功!');location.href='/Manager/NewsList.aspx';</script>");
                    return;
                }
                else
                {
                    Response.Write("<script>alert('添加新闻失败!');location.href='/Manager/NewsList.aspx';</script>");
                    return;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }