Esempio n. 1
0
    //发送
    protected void Button_SendInfo_Click(object sender, EventArgs e)
    {
        if (this.Session["hyuid"].ToString() == "")
            this.Response.Redirect("../login.aspx");

        string ls_tip = "发送成功!";
        string ls_content = this.hy_content.Text;
        HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global();
        HyoaClass.Hyoa_jstx_info Hyoa_jstx_info = new HyoaClass.Hyoa_jstx_info();
        Hyoa_jstx_info.ID = Hyoa_global.GetRandom();
        Hyoa_jstx_info.hy_sendinfo_userid = this.Session["hyuid"].ToString();
        Hyoa_jstx_info.hy_sendinfo_username = this.Session["hyuname"].ToString();
        Hyoa_jstx_info.hy_receive_userid = recuserid;
        Hyoa_jstx_info.hy_receive_username = recusername;
        ls_content = ls_content.Replace("|#", "<img src='images_main/qq/");
        ls_content = ls_content.Replace("gif#", "gif' />");
        Hyoa_jstx_info.hy_content = ls_content;
        Hyoa_jstx_info.hy_sendinfo_date = System.DateTime.Now.ToString();
        Hyoa_jstx_info.hy_fileattpath = "";
        Hyoa_jstx_info.hy_readlists = "";
        Hyoa_jstx_info.hy_delrylist = "";
        Hyoa_jstx_info.Insert();
        this.hy_content.Text = "";

        ///////////////////////////////////////////////////////////////////////////////////////
        //DataTable dt_getinfo = Hyoa_jstx_info.GetDocBySenduserid_Receiveuserid_top6(this.Session["hyuid"].ToString());
        //string lsinfo = "";
        //string lscontent = "";
        //if (dt_getinfo.Rows.Count > 0)
        //{
        //    for (int i = dt_getinfo.Rows.Count - 1; i >= 0; i--)
        //    {
        //        //if (dt_getinfo.Rows[i]["hy_sendinfo_userid"].ToString() == this.Session["hyuid"].ToString())
        //        //{//如果发送人是当前用户则显示为发送人,否则显示为接收人
        //        lsinfo += "<br>" + dt_getinfo.Rows[i]["hy_sendinfo_username"].ToString() + "&nbsp;&nbsp;" + dt_getinfo.Rows[i]["hy_sendinfo_date"].ToString();
        //        lscontent = dt_getinfo.Rows[i]["hy_content"].ToString();
        //        lscontent = lscontent.Replace("|#", "<img src='images_main/qq/");
        //        lscontent = lscontent.Replace("gif#", "gif' />");
        //        if (dt_getinfo.Rows[i]["hy_fileattpath"].ToString() != "")
        //            lscontent = "<a href='/" + dt_getinfo.Rows[i]["hy_fileattpath"].ToString() + "' target='_blank'><font color=red>" + lscontent + "</font></a>";
        //        lsinfo += "<br>" + lscontent;
        //        //}
        //        //else
        //        //{
        //        //    lsinfo += "<br>" + dt_getinfo.Rows[i]["hy_sendinfo_username"].ToString() + "&nbsp;&nbsp;" + dt_getinfo.Rows[i]["hy_sendinfo_date"].ToString();
        //        //    lsinfo += "<br>" + dt_getinfo.Rows[i]["hy_content"].ToString();
        //        //}

        //    }

        //}
        //this.hy_content_display.Text = lsinfo;
        //////////////////////////////////////////////////////////////////////////////////

        Response.Write("<script>window.location='hy_main_jstx.aspx?recuserid=" + this.txtrecuserid.Text + "&rnd='+Math.random();</script>");

        ////处理完成后的提示及跳转
        //if (this.txtifpop.Value == "")
        //{
        //    Response.Write("<script>alert('" + ls_tip + "');window.location='" + this.txturl.Value + "'</script>");
        //}
        //else
        //{
        //    Response.Write("<script>alert('" + ls_tip + "');self.close();</script>");
        //}
    }
    //保存
    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_fileatt Hyoa_fileatt = new HyoaClass.Hyoa_fileatt();
        HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global();
        if (lsfilename != "")  //attsize
        {
            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\\" + this.Session["hyuid"].ToString() + "\\" + lsguid; //存放的文件夹

            //Directory.CreateDirectory(lspath + "\\" + this.Session["hyuid"].ToString() );
            Directory.CreateDirectory(lspath  + "\\" + lsurl);
            str_path = lspath + "\\" + lsurl + "\\" + lsfilename;
            FileUpload1.SaveAs(str_path);

            HyoaClass.Hyoa_jstx_info Hyoa_jstx_info = new HyoaClass.Hyoa_jstx_info();
            Hyoa_jstx_info.ID = lsguid;
            Hyoa_jstx_info.hy_sendinfo_userid = this.Session["hyuid"].ToString();
            Hyoa_jstx_info.hy_sendinfo_username = this.Session["hyuname"].ToString();
            Hyoa_jstx_info.hy_receive_userid = recuserid;
            Hyoa_jstx_info.hy_receive_username = recusername;
            Hyoa_jstx_info.hy_content = lsfilename;
            Hyoa_jstx_info.hy_sendinfo_date = System.DateTime.Now.ToString();
            Hyoa_jstx_info.hy_fileattpath = lsurl + "\\" + lsfilename;
            Hyoa_jstx_info.hy_readlists = "";
            Hyoa_jstx_info.hy_delrylist = "";
            Hyoa_jstx_info.Insert();

            //Hyoa_fileatt.ID = lsguid;
            //Hyoa_fileatt.hy_fatherid = this.txtfatherid.Value;
            //if (this.txtfilename.Text == "")
            //{
            //    Hyoa_fileatt.hy_filename = lsfilename;
            //}
            //else
            //{
            //    Hyoa_fileatt.hy_filename = this.txtfilename.Text;
            //}
            //Hyoa_fileatt.hy_filepath = lsurl + "\\" + lsfilename;
            //Hyoa_fileatt.hy_filesize = ls_attsize;
            //Hyoa_fileatt.hy_userid = this.Session["hyuid"].ToString();
            //Hyoa_fileatt.hy_djsj = System.DateTime.Now.ToString();
            //if (this.Request.QueryString["fatherfield"] != null)
            //{
            //    lshy_fatherfield = this.Request.QueryString["fatherfield"].ToString();   ////父文档配置的域名
            //}
            //Hyoa_fileatt.hy_fatherfield = lshy_fatherfield;
            //Hyoa_fileatt.Insert();

        }
        else
        {
            this.Response.Write("<script>alert('请选择要上传的文件!');</script>");
        }

        Response.Write("<script>alert('发送成功!');window.opener.location.reload();</script>");
    }