//保存 protected void Button_Save_Click(object sender, EventArgs e) { if (this.Session["hyuid"].ToString() == "") this.Response.Redirect("../login.aspx"); string ls_tip = "上传成功!"; string ls_attsize = ""; string str_path = ""; string lspath = ""; string lsguid = ""; string lsurl = ""; string lsfilename = ""; string lshy_fatherfield = ""; lsfilename = FileUpload1.FileName; HyoaClass.Hyoa_boke_headpic Hyoa_boke_headpic = new HyoaClass.Hyoa_boke_headpic(); HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global(); if (lsfilename != "") //attsize { //先删除再插入 Hyoa_boke_headpic.Delete(this.Session["hyuid"].ToString()); //删除 //插入 lshy_fatherfield = ""; ls_attsize = System.Convert.ToString(System.Convert.ToDouble(System.Convert.ToInt32(System.Convert.ToDouble(FileUpload1.PostedFile.ContentLength.ToString()) / 1024 / 1024 * 1000)) / 1000);//附件的大小 lsguid = Hyoa_global.GetRandom(); System.Console.WriteLine(lsguid); //SaveCommon(ls_path, ls_attsize, lsguid); //将附件上传到服务器目录下 lspath = Server.MapPath("~/");//虚拟目录的位置 lsurl = "fileatt\\" + lsguid; //存放的文件夹 Directory.CreateDirectory(lspath + "\\" + lsurl); str_path = lspath + "\\" + lsurl + "\\" + lsfilename; FileUpload1.SaveAs(str_path); Hyoa_boke_headpic.DOCID = lsguid; Hyoa_boke_headpic.hy_picpath = lsurl + "\\" + lsfilename; Hyoa_boke_headpic.hy_userid = this.Session["hyuid"].ToString(); Hyoa_boke_headpic.Insert(); } else { this.Response.Write("<script>alert('请选择要上传的头像!');</script>"); } Response.Write("<script>alert('" + ls_tip + "');window.close(); </script>"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.lblusername.Text = this.Session["hyuname"].ToString(); this.lbldept.Text = this.Session["hydeptname"].ToString(); this.lbldate.Text = System.DateTime.Now.ToShortDateString(); HyoaClass.Hyoa_boke_lookinfo Hyoa_boke_lookinfo = new HyoaClass.Hyoa_boke_lookinfo(); DataTable dt = Hyoa_boke_lookinfo.Getboke_rebackbyfatheruserid(this.Session["hyuid"].ToString()); string lsfk = ""; if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { lsfk += dt.Rows[i]["hy_djrname"].ToString() + "[" + dt.Rows[i]["fwcs"].ToString() + "次]<br>"; } } else { lsfk = "暂无访客!"; } this.lblfk.Text = lsfk; string lsheadpicpath = "images/tx.jpg"; HyoaClass.Hyoa_boke_headpic Hyoa_boke_headpic = new HyoaClass.Hyoa_boke_headpic(); DataTable dtheadpic = Hyoa_boke_headpic.Getboke_headpicbyuserid(this.Session["hyuid"].ToString()); if (dtheadpic.Rows.Count > 0) { if (dtheadpic.Rows[0]["hy_picpath"].ToString() != "") { lsheadpicpath = "\\" + dtheadpic.Rows[0]["hy_picpath"].ToString(); } else { lsheadpicpath = "images/tx.jpg"; } } this.lblheadpic.Text = "<img src=\"" + lsheadpicpath + "\" width=\"180\" height=\"180\" class=\"bk\" />"; } }