예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.NewPort.Table_notice model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Table_notice set ");
            strSql.Append("notice_time=@notice_time,");
            strSql.Append("notice_topic=@notice_topic,");
            strSql.Append("notice_content=@notice_content,");
            strSql.Append("notice_attachmentPath=@notice_attachmentPath");
            strSql.Append(" where notice_id=@notice_id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@notice_time",           SqlDbType.DateTime),
                new SqlParameter("@notice_topic",          SqlDbType.NVarChar,   30),
                new SqlParameter("@notice_content",        SqlDbType.NText),
                new SqlParameter("@notice_attachmentPath", SqlDbType.VarChar,   255),
                new SqlParameter("@notice_id",             SqlDbType.Char, 10)
            };
            parameters[0].Value = model.notice_time;
            parameters[1].Value = model.notice_topic;
            parameters[2].Value = model.notice_content;
            parameters[3].Value = model.notice_attachmentPath;
            parameters[4].Value = model.notice_id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.NewPort.Table_notice model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Table_notice(");
            strSql.Append("notice_id,notice_time,notice_topic,notice_content,notice_attachmentPath)");
            strSql.Append(" values (");
            strSql.Append("@notice_id,@notice_time,@notice_topic,@notice_content,@notice_attachmentPath)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@notice_id",             SqlDbType.Char,      10),
                new SqlParameter("@notice_time",           SqlDbType.DateTime),
                new SqlParameter("@notice_topic",          SqlDbType.NVarChar,  30),
                new SqlParameter("@notice_content",        SqlDbType.NText),
                new SqlParameter("@notice_attachmentPath", SqlDbType.VarChar, 255)
            };
            parameters[0].Value = model.notice_id;
            parameters[1].Value = model.notice_time;
            parameters[2].Value = model.notice_topic;
            parameters[3].Value = model.notice_content;
            parameters[4].Value = model.notice_attachmentPath;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.NewPort.Table_notice DataRowToModel(DataRow row)
 {
     Maticsoft.Model.NewPort.Table_notice model = new Maticsoft.Model.NewPort.Table_notice();
     if (row != null)
     {
         if (row["notice_id"] != null)
         {
             model.notice_id = row["notice_id"].ToString();
         }
         if (row["notice_time"] != null && row["notice_time"].ToString() != "")
         {
             model.notice_time = DateTime.Parse(row["notice_time"].ToString());
         }
         if (row["notice_topic"] != null)
         {
             model.notice_topic = row["notice_topic"].ToString();
         }
         if (row["notice_content"] != null)
         {
             model.notice_content = row["notice_content"].ToString();
         }
         if (row["notice_attachmentPath"] != null)
         {
             model.notice_attachmentPath = row["notice_attachmentPath"].ToString();
         }
     }
     return(model);
 }
예제 #4
0
        private void ShowInfo(string strid)
        {
            Maticsoft.BLL.NewPort.Table_notice   nobll = new Maticsoft.BLL.NewPort.Table_notice();
            Maticsoft.Model.NewPort.Table_notice model = nobll.GetModel(strid);

            this.lbl_number.Text    = model.notice_id.ToString();
            this.lbl_time.Text      = model.notice_time.ToString();
            this.lbl_completed.Text = model.notice_topic.ToString();
            this.lbl_process.Text   = model.notice_content.ToString();
            filePath = model.notice_attachmentPath.ToString();
            if (filePath == "")
            {
                btnDownLoad.Visible = false;
            }
        }
예제 #5
0
        protected void btneSubmit_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                //指定上传文件在服务器上的保存路径
                savePath = Server.MapPath("~/upload/");
                //检查服务器上是否存在这个物理路径,如果不存在则创建
                if (!System.IO.Directory.Exists(savePath))
                {
                    //需要注意的是,需要对这个物理路径有足够的权限,否则会报错
                    //另外,这个路径应该是在网站之下,而将网站部署在C盘却把上传文件保存在D盘
                    System.IO.Directory.CreateDirectory(savePath);
                }
                savePath = savePath + "//" + FileUpload1.FileName;
                FileUpload1.SaveAs(savePath);//保存文件
                //literal.Text = string.Format("<a href='upload/{0}'>upload/{0}</a>", FileUpload1.FileName);
            }


            Maticsoft.Model.NewPort.Table_notice model = new Maticsoft.Model.NewPort.Table_notice();

            model.notice_id             = txtnono.Text.Trim();
            model.notice_content        = txtcontent.Text.Trim();
            model.notice_topic          = txttitle.Text.Trim();
            model.notice_time           = System.DateTime.Now;
            model.notice_attachmentPath = savePath.ToString();

            try
            {
                Maticsoft.BLL.NewPort.Table_notice nobll = new Maticsoft.BLL.NewPort.Table_notice();
                nobll.Add(model);
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "Notice.aspx");
            }
            catch (Exception e2) {
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "填写错误,请重新填写!", "Notice_Add.aspx");
            }
        }
예제 #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.NewPort.Table_notice GetModel(string notice_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 notice_id,notice_time,notice_topic,notice_content,notice_attachmentPath from Table_notice ");
            strSql.Append(" where notice_id=@notice_id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@notice_id", SqlDbType.Char, 10)
            };
            parameters[0].Value = notice_id;

            Maticsoft.Model.NewPort.Table_notice model = new Maticsoft.Model.NewPort.Table_notice();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }