Ejemplo n.º 1
0
        protected void btn_download_Click(object sender, EventArgs e)
        {
            if (SucCookie.Exists("username"))
            {
                try
                {
                    id       = SucCookie.Read("fileid");
                    FilePath = db.GetList(string.Format("SELECT FILEPATH FROM SUC_FILES WHERE ID={0}", id))[0];
                    Name     = db.GetList(string.Format("SELECT NAME FROM SUC_FILES WHERE ID={0}", id))[0];
                    string fileName = Name + FilePath.Substring(FilePath.LastIndexOf('.')); //客户端保存的文件名
                    string filePath = Server.MapPath(FilePath);                             //路径

                    //以字符流的形式下载文件
                    FileStream fs    = new FileStream(filePath, FileMode.Open);
                    byte[]     bytes = new byte[(int)fs.Length];
                    fs.Read(bytes, 0, bytes.Length);
                    fs.Close();
                    Response.ContentType = "application/octet-stream";
                    //通知浏览器下载文件而不是打开
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
                    Response.BinaryWrite(bytes);
                    Response.Flush();
                    Response.End();
                }
                catch (Exception ex)
                {
                    JsUtil.ShowMsg("文件保存出错,请联系网站管理员!");
                }
            }
            else
            {
                JsUtil.ShowMsg("您尚未登陆,请先登录然后才能下载!", "UserLogin.aspx");
            }
        }
Ejemplo n.º 2
0
 protected void btn_upload_Click(object sender, EventArgs e)
 {
     if (file_open.HasFile)
     {
         try
         {
             if (file_open.FileContent.Length > 0)
             {
                 string   filename = file_open.FileName;
                 string   ext      = System.IO.Path.GetExtension(filename);
                 DateTime dt       = DateTime.Now;
                 string   newname  = dt.ToString("yyyyMMddHHmmssffff") + ext;
                 string   path     = "~/Files/" + newname;
                 file_open.SaveAs(System.Web.HttpContext.Current.Server.MapPath(path));
                 string usern = SucCookie.Read("username");
                 if (!string.IsNullOrEmpty(usern))
                 {
                     DataTable userDT = db.GetDataTable(string.Format(@"SELECT * FROM SUC_USER WHERE LOGIN_NAME='{0}'", usern));
                     if (userDT.Rows.Count > 0)
                     {
                         DateTime publicdate = DateTime.Now;
                         string   type       = sComb.Value;
                         string   fromwhere  = userDT.Rows[0]["Unit"].ToString();
                         string   userid     = userDT.Rows[0]["ID"].ToString();
                         string   filesize   = (file_open.PostedFile.ContentLength / 1000).ToString() + "kb";
                         string   filepath   = path;
                         string   gradeclass = sTree.Value;
                         db.ExecuteNonQuery(string.Format(@"INSERT INTO SUC_FILES (NAME, USER_ID,BROWNUM,TYPE,FROMWHERE,DOWNLOADNUM,FILETYPE,FILEPATH,FILESIZE,GRADE_CLASS,PUBLISH_DATE) VALUES ('" + tname.Text + "','" + userid + "','0','" + ext + "','" + fromwhere + "','0','" + type + "','" + filepath + "','" + filesize + "','" + gradeclass + "',GETDATE())"));
                         JsUtil.ShowMsg("上传成功!", "../FP/FileUpload.aspx");//Default
                         return;
                     }
                     else
                     {
                         JsUtil.ShowMsg("该用户不存在!");
                         return;
                     }
                 }
                 else
                 {
                     JsUtil.ShowMsg("请重新登录!");
                     return;
                 }
             }
             else
             {
                 JsUtil.ShowMsg("请选择要上传的文件!");
                 return;
             }
         }
         catch (Exception ex)
         {
             //JsUtil.ShowMsg("上传失败,请重新上传!");
             return;
         }
     }
     JsUtil.ShowMsg(" 您还没有选择文件或您选择的文件大小为0,请先选择文件!");
 }
Ejemplo n.º 3
0
        public static SUC_USER GetCurrentUser()
        {
            int      id = Convert.ToInt32(SucCookie.Read("UserID"));
            SUC_USER u  = new SUC_USER().FindByCondition(new SUC_USER()
            {
                ID = id
            })[0];

            return(u);
        }
Ejemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (SucCookie.Exists("username"))
     {
         username = SucCookie.Read("username");
     }
     else
     {
         Response.Redirect("Login.aspx");
     }
 }
Ejemplo n.º 5
0
        protected void lk_loginstate_Click(object sender, EventArgs e)
        {
            string UserN = SucCookie.Read("username");

            if (!string.IsNullOrEmpty(UserN))
            {
                JsUtil.ShowMsg("您已经成功登录!");
                return;
            }
            Response.Redirect("UserLogin.aspx");
        }
Ejemplo n.º 6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         string UserN = SucCookie.Read("username");
         if (!string.IsNullOrEmpty(UserN))
         {
             lk_loginstate.Text = UserN;
         }
         Bind_FileList();
     }
 }
Ejemplo n.º 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         string UserN = SucCookie.Read("username");
         if (!string.IsNullOrEmpty(UserN))
         {
             lk_loginstate.Text   = UserN;
             lk_quitlogin.Visible = true;
             lk_modifypwd.Visible = false;
             lk_upload.Text       = "上传文件";
         }
         Bind_FileList();
     }
 }
Ejemplo n.º 8
0
        public static string checkUser(string usern, string userp, string code)
        {
            IDBHelp db = DBFactory.Create();

            if (!SucCookie.Read("CheckCode").Equals(code.ToUpper()))
            {
                return("codeerror");
            }
            if (db.IsExists(string.Format(@"SELECT * FROM SUC_USER WHERE LOGIN_NAME='{0}'", usern)))
            {
                if (db.IsExists(string.Format(@"SELECT * FROM SUC_LOGIN WHERE LOGIN_NAME='{0}' AND PASSWORD={1}", usern, userp)))
                {
                    SucCookie.Add("username", usern, 30);
                    return("ok");
                }
            }
            return("no");
        }
Ejemplo n.º 9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string UserN = SucCookie.Read("username");
         if (!string.IsNullOrEmpty(UserN))
         {
             lk_loginstate.Text   = UserN;
             lk_quitlogin.Visible = true;
             lk_modifypwd.Visible = false;
         }
         id = Request.QueryString["id"];
         if (SucCookie.Exists("fileid"))
         {
             SucCookie.Delete("fileid");
         }
         SucCookie.Add("fileid", id, 10);
         GetInfo(id);
         LoadMedia();
         LoadInfo(id);
         AddBrowNum(id);
     }
 }
Ejemplo n.º 10
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string c*k = SucCookie.Read("dt");

            Response.Write("<script language='javascript'>alert('" + c*k + "')</script>");
        }
Ejemplo n.º 11
0
 private void GetFunction()
 {
     funcs = db.GetList(string.Format(@"SELECT CODE,NAME FROM SUC_FUNCTION WHERE ID IN(
                                     SELECT FUNCTION_ID FROM SUC_ROLE_FUNCTION WHERE ROLE_ID=(
                                     SELECT ROLE_ID FROM SUC_USER WHERE LOGIN_NAME='{0}'))", SucCookie.Read("username")));
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 加载多级菜单
        /// </summary>
        public void BindMenu()
        {
            string        userid = db.GetList(string.Format(@"SELECT ID FROM SUC_USER WHERE LOGIN_NAME='{0}'", SucCookie.Read("username")))[0];
            StringBuilder sb     = new StringBuilder("<li><dl>");
            DataTable     dt     = db.GetDataTable(string.Format(@"
                                            SELECT * FROM SUC_MODULE WHERE ID IN(
                                            SELECT MODULE_ID FROM SUC_ROLE_MODULE WHERE MODULE_ID IN(
                                            SELECT ID FROM SUC_MODULE WHERE PARENT_ID=0)AND ROLE_ID=
                                            (SELECT ROLE_ID FROM SUC_USER WHERE ID={0}))", 1));

            foreach (DataRow dr in dt.Rows)
            {
                sb.Append(string.Format(@"<dt>{0}</dt>", dr["NAME"].ToString()));
                DataTable dt1 = db.GetDataTable(string.Format(@"SELECT * FROM SUC_MODULE WHERE ID IN(
                                            SELECT MODULE_ID FROM SUC_ROLE_MODULE WHERE MODULE_ID IN(
                                            SELECT ID FROM SUC_MODULE WHERE PARENT_ID={0})AND ROLE_ID=
                                            (SELECT ROLE_ID FROM SUC_USER WHERE ID={1}))", dr[0], 1));
                foreach (DataRow dr1 in dt1.Rows)
                {
                    sb.Append(string.Format("<dd><a href=\"{0}\">{1}</a></dd>", dr1[3], dr1[2]));
                }
            }
            sb.Append("</dl></li>");
            menu = sb.ToString();
        }