示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(NCPEP.Model.T_Fujian model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_Fujian set ");
            strSql.Append("fjname=@fjname,");
            strSql.Append("fjpath=@fjpath,");
            strSql.Append("fid=@fid,");
            strSql.Append("fjlx=@fjlx");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@fjname", SqlDbType.VarChar,   50),
                new SqlParameter("@fjpath", SqlDbType.NVarChar, 150),
                new SqlParameter("@fid",    SqlDbType.VarChar,   50),
                new SqlParameter("@fjlx",   SqlDbType.VarChar,   50),
                new SqlParameter("@id",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.fjname;
            parameters[1].Value = model.fjpath;
            parameters[2].Value = model.fid;
            parameters[3].Value = model.fjlx;
            parameters[4].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(NCPEP.Model.T_Fujian model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_Fujian(");
            strSql.Append("fjname,fjpath,fid,fjlx)");
            strSql.Append(" values (");
            strSql.Append("@fjname,@fjpath,@fid,@fjlx)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@fjname", SqlDbType.VarChar,   50),
                new SqlParameter("@fjpath", SqlDbType.NVarChar, 150),
                new SqlParameter("@fid",    SqlDbType.VarChar,   50),
                new SqlParameter("@fjlx",   SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.fjname;
            parameters[1].Value = model.fjpath;
            parameters[2].Value = model.fid;
            parameters[3].Value = model.fjlx;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public NCPEP.Model.T_Fujian DataRowToModel(DataRow row)
 {
     NCPEP.Model.T_Fujian model = new NCPEP.Model.T_Fujian();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["fjname"] != null)
         {
             model.fjname = row["fjname"].ToString();
         }
         if (row["fjpath"] != null)
         {
             model.fjpath = row["fjpath"].ToString();
         }
         if (row["fid"] != null)
         {
             model.fid = row["fid"].ToString();
         }
         if (row["fjlx"] != null)
         {
             model.fjlx = row["fjlx"].ToString();
         }
     }
     return(model);
 }
示例#4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            NCPEP.Model.T_News model = new NCPEP.Model.T_News();
            NCPEP.Bll.T_News   bll   = new NCPEP.Bll.T_News();
            if (Request.QueryString["id"] != null)
            {
                model = bll.GetModel(int.Parse(Request.QueryString["id"]));
            }
            model.Content = content1.Value;
            try
            {
                model.CreateDate = DateTime.Parse(this.txtsj.Text);
            }
            catch { }
            model.Editor      = adminUser.AdminName;
            model.IsCheck     = 0;
            model.Keyword     = this.txtKeyword.Text;
            model.NewsContent = this.content1.Value;

            model.Content        = this.txtContent.Text;
            model.NewsSource     = this.txtNewsSource.Text;
            model.NewsSubheading = this.txtNewsSubheading.Text;
            model.NewsTitle      = this.txtNewsTitle.Text;
            try
            {
                model.NewsTypeId = int.Parse(this.txtNewsTypeId.SelectedValue);
            }
            catch { }
            if (fileNewsImg.HasFile)
            {
                string newsImgName = new UpLoadNewsImgPlug().UploadImg("147", "147");
                model.NewsImg = newsImgName == string.Empty ? fileNewsImg.FileName : newsImgName;
            }

            model.NumClicks = 0;
            model.OrgCode   = adminUser.OrgCode;

            bool fid = bll.Update(model);

            if (fid)
            {
                if (!string.IsNullOrEmpty(this.hdfile.Value) && !string.IsNullOrEmpty(this.hdfilename.Value))
                {
                    string[]           strs     = hdfile.Value.Split('|');
                    string[]           strsname = hdfilename.Value.Split('|');
                    NCPEP.Bll.T_Fujian fjbll    = new NCPEP.Bll.T_Fujian();
                    for (int i = 1; i < strs.Length; i++)
                    {
                        NCPEP.Model.T_Fujian fjmodel = new NCPEP.Model.T_Fujian();
                        fjmodel.fid    = model.Id.ToString();
                        fjmodel.fjlx   = "";
                        fjmodel.fjname = strsname[i];
                        fjmodel.fjpath = strs[i];
                        fjbll.Add(fjmodel);
                    }
                }
            }
            MessageBox.ShowAndRedirect(this, "修改成功", "newslist.aspx");
        }
示例#5
0
 protected void repsfz_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "del")
     {
         string strid = e.CommandArgument.ToString();
         NCPEP.Model.T_Fujian model = new NCPEP.Model.T_Fujian();
         NCPEP.Bll.T_Fujian   bll   = new NCPEP.Bll.T_Fujian();
         model = bll.GetModel(int.Parse(strid));
         if (model != null)
         {
             try
             {
                 File.Delete(MapPath("../../newsfile/" + model.fjpath));
             }
             catch { }
             bll.Delete(int.Parse(strid));
             Bindfj();
         }
     }
 }
示例#6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public NCPEP.Model.T_Fujian GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,fjname,fjpath,fid,fjlx from T_Fujian ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            NCPEP.Model.T_Fujian model = new NCPEP.Model.T_Fujian();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(NCPEP.Model.T_Fujian model)
 {
     return(dal.Update(model));
 }
示例#8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(NCPEP.Model.T_Fujian model)
 {
     return(dal.Add(model));
 }