예제 #1
0
        protected void btnok_Click(object sender, EventArgs e)
        {
            int index = int.Parse(Request.QueryString["JishuID"].ToString());

            Maticsoft.BLL.JiShuInfo   jishubll   = new Maticsoft.BLL.JiShuInfo();
            Maticsoft.Model.JiShuInfo jishumodel = jishubll.GetModel(index);
            if (txtJishuTitle.Text.Trim() == null)
            {
                lbltitle.Text = "请填写文件名称";
                return;
            }
            jishumodel.JishuTitle = txtJishuTitle.Text.Trim();
            lbltitle.Text         = "";
            jishumodel.JishuPath  = lblinfo1.Text;
            if (txttime.Text.Trim() == null)
            {
                lbltime.Text = "请填写发布时间";
                return;
            }
            lbltime.Text      = "";
            jishumodel.Fatime = Convert.ToDateTime(txttime.Text.Trim());
            if (txtleib.Text.Trim() == null)
            {
                lbltype.Text = "请填写文件类别";
                return;
            }
            lbltype.Text            = "";
            jishumodel.jishuType    = txtleib.Text.Trim();
            jishumodel.ImageURL     = Image1.ImageUrl;
            jishumodel.Jishucontent = txtcontent.Text.Trim();
            jishubll.Update(jishumodel);
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('信息提交成功')</script>");
            bind();
        }
예제 #2
0
 protected void btnok_Click(object sender, EventArgs e)
 {
     Maticsoft.BLL.JiShuInfo   jishubll   = new Maticsoft.BLL.JiShuInfo();
     Maticsoft.Model.JiShuInfo jishumodel = new Maticsoft.Model.JiShuInfo();
     if (txtJishuTitle.Text.Trim() == null)
     {
         lbltitle.Text = "请填写文件名称";
         return;
     }
     jishumodel.JishuTitle = txtJishuTitle.Text.Trim();
     lbltitle.Text         = "";
     jishumodel.JishuPath  = lblinfo1.Text;
     if (txttime.Text.Trim() == null)
     {
         lbltime.Text = "请填写发布时间";
         return;
     }
     lbltime.Text      = "";
     jishumodel.Fatime = Convert.ToDateTime(txttime.Text.Trim());
     if (txtleib.Text.Trim() == null)
     {
         lbltype.Text = "请填写文件类别";
         return;
     }
     lbltype.Text            = "";
     jishumodel.jishuType    = txtleib.Text.Trim();
     jishumodel.ImageURL     = Image1.ImageUrl;
     jishumodel.Jishucontent = txtcontent.Text.Trim();
     jishubll.Add(jishumodel);
     Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('信息提交成功')</script>");
     txtcontent.Text    = string.Empty;
     txtJishuTitle.Text = string.Empty;
     txtleib.Text       = string.Empty;
     txttime.Text       = string.Empty;
 }
예제 #3
0
 protected void datajishu_ItemCommand(object source, DataListCommandEventArgs e)
 {//CommandName
     if (e.CommandName == "download")
     {
         int jishuid = int.Parse(e.CommandArgument.ToString());
         Maticsoft.BLL.JiShuInfo   jishubll   = new Maticsoft.BLL.JiShuInfo();
         Maticsoft.Model.JiShuInfo jishumodel = jishubll.GetModel(jishuid);
         string   fileName  = jishumodel.JishuTitle;
         string   filePath  = Server.MapPath(jishumodel.JishuPath);
         string   kzhanming = Path.GetExtension(jishumodel.JishuPath);
         FileInfo fileinfo  = new FileInfo(filePath);
         if (fileinfo.Exists == true)
         {
             const long ChunkSize = 102400;//100K 每次读取文件,只读取100K,这样可以缓解服务器的压力
             byte[]     buffer    = new byte[ChunkSize];
             Response.Clear();
             FileStream iSteam           = File.OpenRead(filePath);
             long       dataLengthToRead = iSteam.Length;//获取下载的文件总大小
             Response.ContentType = "application/octet-stream";
             Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName) + "." + kzhanming + "");
             while (dataLengthToRead > 0 && Response.IsClientConnected)
             {
                 int lengthRead = iSteam.Read(buffer, 0, Convert.ToInt32(ChunkSize));//读取的大小
                 Response.OutputStream.Write(buffer, 0, lengthRead);
                 Response.Flush();
                 dataLengthToRead = dataLengthToRead - lengthRead;
             }
             Response.Close();
         }
     }
 }
예제 #4
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtJishuTitle.Text.Trim().Length == 0)
            {
                strErr += "JishuTitle不能为空!\\n";
            }
            if (this.txtJishuNum.Text.Trim().Length == 0)
            {
                strErr += "JishuNum不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtFatime.Text))
            {
                strErr += "Fatime格式错误!\\n";
            }
            if (this.txtjishuType.Text.Trim().Length == 0)
            {
                strErr += "jishuType不能为空!\\n";
            }
            if (this.txtImageURL.Text.Trim().Length == 0)
            {
                strErr += "ImageURL不能为空!\\n";
            }
            if (this.txtJishuPath.Text.Trim().Length == 0)
            {
                strErr += "JishuPath不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      JishuID    = int.Parse(this.lblJishuID.Text);
            string   JishuTitle = this.txtJishuTitle.Text;
            string   JishuNum   = this.txtJishuNum.Text;
            DateTime Fatime     = DateTime.Parse(this.txtFatime.Text);
            string   jishuType  = this.txtjishuType.Text;
            string   ImageURL   = this.txtImageURL.Text;
            string   JishuPath  = this.txtJishuPath.Text;


            Maticsoft.Model.JiShuInfo model = new Maticsoft.Model.JiShuInfo();
            model.JishuID    = JishuID;
            model.JishuTitle = JishuTitle;
            model.JishuNum   = JishuNum;
            model.Fatime     = Fatime;
            model.jishuType  = jishuType;
            model.ImageURL   = ImageURL;
            model.JishuPath  = JishuPath;

            Maticsoft.BLL.JiShuInfo bll = new Maticsoft.BLL.JiShuInfo();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
예제 #5
0
        protected void bind()
        {
            int index = int.Parse(Request.QueryString["JishuID"].ToString());

            Maticsoft.BLL.JiShuInfo   jishubll   = new Maticsoft.BLL.JiShuInfo();
            Maticsoft.Model.JiShuInfo jishumodel = jishubll.GetModel(index);
            txtcontent.Text    = jishumodel.Jishucontent;
            Image1.ImageUrl    = jishumodel.ImageURL;
            txtJishuTitle.Text = jishumodel.JishuTitle;
            txtleib.Text       = jishumodel.jishuType;
            txttime.Text       = Convert.ToDateTime(jishumodel.Fatime.ToString()).ToString("yyyy-MM-dd");
        }
예제 #6
0
 private void ShowInfo(int JishuID)
 {
     Maticsoft.BLL.JiShuInfo   bll   = new Maticsoft.BLL.JiShuInfo();
     Maticsoft.Model.JiShuInfo model = bll.GetModel(JishuID);
     this.lblJishuID.Text    = model.JishuID.ToString();
     this.lblJishuTitle.Text = model.JishuTitle;
     this.lblJishuNum.Text   = model.JishuNum;
     this.lblFatime.Text     = model.Fatime.ToString();
     this.lbljishuType.Text  = model.jishuType;
     this.lblImageURL.Text   = model.ImageURL;
     this.lblJishuPath.Text  = model.JishuPath;
 }
예제 #7
0
        private void bind()
        {
            Maticsoft.BLL.JiShuInfo jishubll = new Maticsoft.BLL.JiShuInfo();
            int index = int.Parse(Request.QueryString["JishuID"].ToString());

            Maticsoft.Model.JiShuInfo jishumodel = jishubll.GetModel(index);
            lbltime.Text       = Convert.ToDateTime(jishumodel.Fatime.ToString()).ToString("yyyy-MM-dd");
            lbltitle.Text      = jishumodel.JishuTitle;
            lbltype.Text       = jishumodel.jishuType;
            lblwenjian.Text    = jishumodel.JishuPath;
            Image1.ImageUrl    = jishumodel.ImageURL;
            txtNewContent.Text = jishumodel.Jishucontent;
        }
예제 #8
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.JiShuInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update JiShuInfo set ");
            strSql.Append("JishuTitle=@JishuTitle,");
            strSql.Append("JishuNum=@JishuNum,");
            strSql.Append("Fatime=@Fatime,");
            strSql.Append("jishuType=@jishuType,");
            strSql.Append("ImageURL=@ImageURL,");
            strSql.Append("JishuPath=@JishuPath,");
            strSql.Append("Jishucontent=@Jishucontent");
            strSql.Append(" where JishuID=@JishuID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@JishuID",      SqlDbType.Int,         4),
                new SqlParameter("@JishuTitle",   SqlDbType.VarChar,   200),
                new SqlParameter("@JishuNum",     SqlDbType.VarChar,   200),
                new SqlParameter("@Fatime",       SqlDbType.DateTime),
                new SqlParameter("@jishuType",    SqlDbType.VarChar,   200),
                new SqlParameter("@ImageURL",     SqlDbType.Text),
                new SqlParameter("@JishuPath",    SqlDbType.Text),
                new SqlParameter("@Jishucontent", SqlDbType.Text)
            };
            parameters[0].Value = model.JishuID;
            parameters[1].Value = model.JishuTitle;
            parameters[2].Value = model.JishuNum;
            parameters[3].Value = model.Fatime;
            parameters[4].Value = model.jishuType;
            parameters[5].Value = model.ImageURL;
            parameters[6].Value = model.JishuPath;
            parameters[7].Value = model.Jishucontent;

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

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

            strSql.Append("insert into JiShuInfo(");
            strSql.Append("JishuTitle,JishuNum,Fatime,jishuType,ImageURL,JishuPath,Jishucontent)");
            strSql.Append(" values (");
            strSql.Append("@JishuTitle,@JishuNum,@Fatime,@jishuType,@ImageURL,@JishuPath,@Jishucontent)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@JishuTitle",   SqlDbType.VarChar,   200),
                new SqlParameter("@JishuNum",     SqlDbType.VarChar,   200),
                new SqlParameter("@Fatime",       SqlDbType.DateTime),
                new SqlParameter("@jishuType",    SqlDbType.VarChar,   200),
                new SqlParameter("@ImageURL",     SqlDbType.Text),
                new SqlParameter("@JishuPath",    SqlDbType.Text),
                new SqlParameter("@Jishucontent", SqlDbType.Text)
            };
            parameters[0].Value = model.JishuTitle;
            parameters[1].Value = model.JishuNum;
            parameters[2].Value = model.Fatime;
            parameters[3].Value = model.jishuType;
            parameters[4].Value = model.ImageURL;
            parameters[5].Value = model.JishuPath;
            parameters[6].Value = model.Jishucontent;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #10
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.JiShuInfo GetModel(int JishuID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 JishuID,JishuTitle,JishuNum,Fatime,jishuType,ImageURL,JishuPath,Jishucontent from JiShuInfo ");
            strSql.Append(" where JishuID=@JishuID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@JishuID", SqlDbType.Int, 4)
            };
            parameters[0].Value = JishuID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["JishuID"].ToString() != "")
                {
                    model.JishuID = int.Parse(ds.Tables[0].Rows[0]["JishuID"].ToString());
                }
                model.JishuTitle = ds.Tables[0].Rows[0]["JishuTitle"].ToString();
                model.JishuNum   = ds.Tables[0].Rows[0]["JishuNum"].ToString();
                if (ds.Tables[0].Rows[0]["Fatime"].ToString() != "")
                {
                    model.Fatime = DateTime.Parse(ds.Tables[0].Rows[0]["Fatime"].ToString());
                }
                model.jishuType    = ds.Tables[0].Rows[0]["jishuType"].ToString();
                model.ImageURL     = ds.Tables[0].Rows[0]["ImageURL"].ToString();
                model.JishuPath    = ds.Tables[0].Rows[0]["JishuPath"].ToString();
                model.Jishucontent = ds.Tables[0].Rows[0]["Jishucontent"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }