/// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static EtNet_Models.AnnouncementFiles GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * ");
            strSql.Append("  from AnnouncementFiles ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;


            EtNet_Models.AnnouncementFiles model = new EtNet_Models.AnnouncementFiles();
            DataTable tbl = EtNet_DAL.DBHelper.GetDataSet(strSql.ToString(), parameters);

            if (tbl.Rows.Count > 0)
            {
                model.id             = int.Parse(tbl.Rows[0]["id"].ToString());
                model.announcementid = int.Parse(tbl.Rows[0]["announcementid"].ToString());
                model.cname          = tbl.Rows[0]["cname"].ToString();
                model.path           = tbl.Rows[0]["path"].ToString();
                model.uptime         = DateTime.Parse(tbl.Rows[0]["uptime"].ToString());
                model.founderid      = int.Parse(tbl.Rows[0]["founderid"].ToString());
                model.remark         = tbl.Rows[0]["remark"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
        /// 删除附件
        /// </summary>
        private void DelFile(HttpContext context)
        {
            int id = int.Parse(context.Request.Params["fileid"]);

            EtNet_Models.AnnouncementFiles model = EtNet_BLL.AnnouncementFilesManager.GetModel(id);
            if (model != null)
            {
                //删除服务器上的相应的文件
                File.Delete(context.Server.MapPath(model.path));
                EtNet_BLL.AnnouncementFilesManager.Delete(model.id);
                context.Response.Write("删除成功_1");
            }
            else
            {
                context.Response.Write("删除失败_0");
            }
        }
Example #3
0
 /// <summary>
 /// 保存附件的路径
 /// </summary>
 /// <param name="filelist">附件的路径的列表</param>
 /// <param name="id">公告的id值</param>
 private void CreateFile(string[] filelist, int id)
 {
     EtNet_Models.AnnouncementFiles model = null;
     EtNet_Models.LoginInfo         login = (EtNet_Models.LoginInfo)Session["login"];
     for (int i = 1; i < 6; i++)
     {
         if (filelist[i] != "")
         {
             model                = new EtNet_Models.AnnouncementFiles();
             model.path           = filelist[i].Substring(0, filelist[i].IndexOf("|"));
             model.uptime         = DateTime.Now;
             model.cname          = filelist[i].Substring(filelist[i].LastIndexOf('|') + 1);
             model.announcementid = id;
             model.founderid      = login.Id;
             model.remark         = "";
             EtNet_BLL.AnnouncementFilesManager.Add(model);
         }
     }
 }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static bool Update(EtNet_Models.AnnouncementFiles model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update AnnouncementFiles set ");
            strSql.Append(" announcementid = @announcementid , ");
            strSql.Append(" cname = @cname , ");
            strSql.Append(" path = @path , ");
            strSql.Append(" uptime = @uptime , ");
            strSql.Append(" founderid = @founderid , ");
            strSql.Append(" remark = @remark  ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",             SqlDbType.Int,         4),
                new SqlParameter("@announcementid", SqlDbType.Int,         4),
                new SqlParameter("@cname",          SqlDbType.VarChar,   100),
                new SqlParameter("@path",           SqlDbType.VarChar,   200),
                new SqlParameter("@uptime",         SqlDbType.DateTime),
                new SqlParameter("@founderid",      SqlDbType.Int,         4),
                new SqlParameter("@remark",         SqlDbType.VarChar, 200)
            };

            parameters[0].Value = model.id;
            parameters[1].Value = model.announcementid;
            parameters[2].Value = model.cname;
            parameters[3].Value = model.path;
            parameters[4].Value = model.uptime;
            parameters[5].Value = model.founderid;
            parameters[6].Value = model.remark;
            int result = EtNet_DAL.DBHelper.ExecuteCommand(strSql.ToString(), parameters);

            if (result >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static bool Add(EtNet_Models.AnnouncementFiles model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into AnnouncementFiles(");
            strSql.Append("announcementid,cname,path,uptime,founderid,remark");
            strSql.Append(") values (");
            strSql.Append("@announcementid,@cname,@path,@uptime,@founderid,@remark");
            strSql.Append(") ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@announcementid", SqlDbType.Int,         4),
                new SqlParameter("@cname",          SqlDbType.VarChar,   100),
                new SqlParameter("@path",           SqlDbType.VarChar,   200),
                new SqlParameter("@uptime",         SqlDbType.DateTime),
                new SqlParameter("@founderid",      SqlDbType.Int,         4),
                new SqlParameter("@remark",         SqlDbType.VarChar, 200)
            };

            parameters[0].Value = model.announcementid;
            parameters[1].Value = model.cname;
            parameters[2].Value = model.path;
            parameters[3].Value = model.uptime;
            parameters[4].Value = model.founderid;
            parameters[5].Value = model.remark;

            int result = EtNet_DAL.DBHelper.ExecuteCommand(strSql.ToString(), parameters);

            if (result >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static bool Update(EtNet_Models.AnnouncementFiles model)
 {
     return(EtNet_DAL.AnnouncementFilesService.Update(model));
 }
Example #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static bool  Add(EtNet_Models.AnnouncementFiles model)
 {
     return(EtNet_DAL.AnnouncementFilesService.Add(model));
 }