//发布投票add by fy 2014-02-23 protected void Button_Pub_Click(object sender, EventArgs e) { //发布投票时发送邮件给参与投票人 HyoaClass.DAO db = new HyoaClass.DAO(); HyoaClass.Hyoa_mail Hyoa_mail = new HyoaClass.Hyoa_mail(); HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global(); HyoaClass.Hyoa_user Hyoa_user = new HyoaClass.Hyoa_user(); string ls_yqmlists = ""; if (this.hy_field43.Text == "") { //从人员库中读取人员 DataTable dt = Hyoa_user.GetusersOrderbydeptsortandusersort(); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { string ls_jsrid = dt.Rows[i]["hy_userid"].ToString(); string ls_jsrname = dt.Rows[i]["hy_username"].ToString(); string ls_yqm = ""; string ls_yqms = GetRandom3(); if (ls_jsrid == "admin") { ls_yqm = "000" + ls_yqms; } else { ls_yqm = ls_jsrid.Substring(ls_jsrid.Length - 3) + ls_yqms; //获得6位数字的随机数 } //string ls_dburl = "/wstp.aspx?yqm=" + ls_yqm + "&rnd=" + Hyoa_global.GetRandom(); string ls_dburl = "/wstp.aspx?rnd=" + Hyoa_global.GetRandom(); string ls_body = this.Session["hyuname"].ToString() + "发起投票,您的投票邀请码为:" + ls_yqm + "。<a href=" + ls_dburl + " target=\"_blank\">请点击进入</a>"; String ls_sql = "insert into hyt_mail(ID,DOCID,hy_type,hy_foldername,hy_fsrid,hy_fsrname,hy_jsrid,hy_wbjsrid,hy_jsrname,hy_title,hy_body,hy_datetime,hy_ifsavetofjx,hy_yxj,hy_yjbg,hy_zycd,hy_hz,hy_wbjszh) values "; ls_sql += "('" + Hyoa_global.GetRandom() + "','" + Hyoa_global.GetRandom() + "','收件','收件箱','" + this.hy_djrid.Text + "','" + this.hy_djrname.Text + "','" + ls_jsrid + "','','" + ls_jsrname + "','" + this.hy_field23.Text + "','" + ls_body + "','" + System.DateTime.Now.ToString() + "','','','','','','') "; db.Execute(ls_sql); //将邀请码 if (ls_yqmlists == "") { ls_yqmlists = ls_yqm; } else { ls_yqmlists = ls_yqmlists + "+" + ls_yqm; } } } } else { string ls_jsrid = this.hy_field43.Text; string ls_jsrname = this.hy_field41.Text; string[] lv_jsrid = ls_jsrid.Split('+'); string[] lv_jsrname = ls_jsrname.Split('+'); for (var i = 0; i < lv_jsrid.Length; i++) { if (lv_jsrid[i] != "") { string ls_yqm = ""; string ls_yqms = GetRandom3(); if (lv_jsrid[i] == "admin") { ls_yqm = "000" + ls_yqms; } else { ls_yqm = lv_jsrid[i].Substring(lv_jsrid[i].Length - 3) + ls_yqms; //获得6位数字的随机数 } ////发送待办 //string ls_dburl = "wstp.aspx?rnd=" + Hyoa_global.GetRandom(); //string ls_body = this.Session["hyuname"].ToString() + "发起投票,请您参与"; //Hyoa_global.Senddbsy_global(this.txtdocid.Value, lv_jsrid[i].ToString(), lv_jsrname[i].ToString(), // this.Session["hyuid"].ToString(), this.Session["hyuname"].ToString(), ls_dburl, "待办", this.hy_mudelid.Text, "待办箱", "一般", ls_body, "请参与", 0, "", ""); //给参与的人发送邮件 //string ls_dburl = "/wstp.aspx?yqm=" + ls_yqm + "&rnd=" + Hyoa_global.GetRandom(); string ls_dburl = "/wstp.aspx?rnd=" + Hyoa_global.GetRandom(); string ls_body = this.Session["hyuname"].ToString() + "发起投票,您的投票邀请码为:" + ls_yqm + "。<a href=" + ls_dburl + " target=\"_blank\">请点击进入</a>"; String ls_sql = "insert into hyt_mail(ID,DOCID,hy_type,hy_foldername,hy_fsrid,hy_fsrname,hy_jsrid,hy_wbjsrid,hy_jsrname,hy_title,hy_body,hy_datetime,hy_ifsavetofjx,hy_yxj,hy_yjbg,hy_zycd,hy_hz,hy_wbjszh) values "; ls_sql += "('" + Hyoa_global.GetRandom() + "','" + Hyoa_global.GetRandom() + "','收件','收件箱','" + this.hy_djrid.Text + "','" + this.hy_djrname.Text + "','" + lv_jsrid[i].ToString() + "','','" + lv_jsrname[i].ToString() + "','" + this.hy_field23.Text + "','" + ls_body + "','" + System.DateTime.Now.ToString() + "','','','','','','') "; db.Execute(ls_sql); //将邀请码 if (ls_yqmlists == "") { ls_yqmlists = ls_yqm; } else { ls_yqmlists = ls_yqmlists + "+" + ls_yqm; } } } } //更新表 string sql = "update hyp_flowmain set hy_field30='" + ls_yqmlists + "',hy_field100=1 where docid='" + this.txtdocid.Value + "'"; db.Execute(sql); db.Close(); db.Dispose(); Response.Write("<script>alert('发布投票成功!');window.location = '/list_tpgl.aspx?mid=moduletpgl&tableid=bb4c4ac0-53b4-4c7f-89a6-4bde425c24fd';</script>"); }
//发布 protected void btnpubinfo_Click(object sender, EventArgs e) { //判断选中的投票项目是否一致 HyoaClass.Hyoa_flowmain Hyoa_flowmain = new HyoaClass.Hyoa_flowmain(); HyoaClass.DAO db = new HyoaClass.DAO(); string ls_tplb = "", ls_cyr = ""; String[] v_uids = this.txtuids.Value.Split(','); //通过ID得到信息 DataTable dt = Hyoa_flowmain.Getflowmain(v_uids[0]); if (dt.Rows.Count > 0) { ls_tplb = dt.Rows[0]["hy_field20"].ToString(); ls_cyr = dt.Rows[0]["hy_field41"].ToString(); if (ls_cyr != "" && ls_cyr.IndexOf('+') < 0) { Response.Write("<script>alert('多个可投票人员需要用加号分割,发布投票失败!');window.location = '/list_tpgl.aspx?mid=moduletpgl&tableid=bb4c4ac0-53b4-4c7f-89a6-4bde425c24fd';</script>"); return; } } //判断该投票类别是否已经发布过 string ls_sql22 = "select * from hyp_flowmain where hy_field20='" + ls_tplb + "' and hy_field100=1 "; DataTable dtlb = db.GetDataTable(ls_sql22); if (dtlb.Rows.Count > 0) { Response.Write("<script>alert('该投票类别已发布,发布投票失败!');window.location = '/list_tpgl.aspx?mid=moduletpgl&tableid=bb4c4ac0-53b4-4c7f-89a6-4bde425c24fd';</script>"); return; } //for (var i = 0; i < v_uids.Length; i++) //{ // //通过ID得到信息 // DataTable dt1 = Hyoa_flowmain.Getflowmain(v_uids[i]); // if (dt1.Rows.Count > 0) // { // if (ls_tpxm != dt1.Rows[0]["hy_field10"].ToString()) // { // Response.Write("<script>alert('选择的投票项目不一致,发布投票失败!');window.location = '/list_tpgl.aspx?mid=moduletpgl&tableid=bb4c4ac0-53b4-4c7f-89a6-4bde425c24fd';</script>"); // return; // } // if (dt.Rows[0]["hy_field100"].ToString() == "1") // { // Response.Write("<script>alert('选择的投票项目已发布,发布投票失败!');window.location = '/list_tpgl.aspx?mid=moduletpgl&tableid=bb4c4ac0-53b4-4c7f-89a6-4bde425c24fd';</script>"); // return; // } // } //} //Response.Write("<script>alert('" + ls_tpxm + "');</script>"); //return; //发布投票时发送邮件给参与投票人 HyoaClass.Hyoa_mail Hyoa_mail = new HyoaClass.Hyoa_mail(); HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global(); HyoaClass.Hyoa_user Hyoa_user = new HyoaClass.Hyoa_user(); string ls_yqmlists = ""; if (ls_cyr == "") { //从人员库中读取人员 string sql2 = "select * from hyt_user order by hy_sort"; DataTable dt2 = db.GetDataTable(sql2); if (dt.Rows.Count > 0) { for (int i = 0; i < dt2.Rows.Count; i++) { string ls_jsrid = dt2.Rows[i]["hy_userid"].ToString(); string ls_jsrname = dt2.Rows[i]["hy_username"].ToString(); string ls_yqm = ""; string ls_yqms = GetRandom3(); if (ls_jsrid == "admin") { ls_yqm = "000" + ls_yqms; } else { ls_yqm = ls_jsrid.Substring(ls_jsrid.Length - 3) + ls_yqms; //获得6位数字的随机数 } //string ls_dburl = "/wstp.aspx?yqm=" + ls_yqm + "&rnd=" + Hyoa_global.GetRandom(); string ls_dburl = "/wstp.aspx?rnd=" + Hyoa_global.GetRandom(); string ls_title = "[投票管理]-请参与" + ls_tplb + "的投票"; string ls_body = "您投票的邀请码为:" + ls_yqm + "。<a href=" + ls_dburl + " target=\"_blank\">请点击进入投票页面!</a>"; String ls_sql = "insert into hyt_mail(ID,DOCID,hy_type,hy_foldername,hy_fsrid,hy_fsrname,hy_jsrid,hy_wbjsrid,hy_jsrname,hy_title,hy_body,hy_datetime,hy_ifsavetofjx,hy_yxj,hy_yjbg,hy_zycd,hy_hz,hy_wbjszh) values "; ls_sql += "('" + Hyoa_global.GetRandom() + "','" + Hyoa_global.GetRandom() + "','收件','收件箱','admin','管理员','" + ls_jsrid + "','','" + ls_jsrname + "','" + ls_title + "','" + ls_body + "','" + System.DateTime.Now.ToString() + "','','','','','','') "; db.Execute(ls_sql); //将邀请码 if (ls_yqmlists == "") { ls_yqmlists = ls_yqm; } else { ls_yqmlists = ls_yqmlists + "+" + ls_yqm; } } } } else { string ls_jsrname = ls_cyr; string[] lv_jsrname = ls_jsrname.Split('+'); for (var i = 0; i < lv_jsrname.Length; i++) { if (lv_jsrname[i] != "") { string ls_jsrid = ""; string sqluser = "******" + lv_jsrname[i] + "'"; DataTable dtuser = db.GetDataTable(sqluser); if (dtuser.Rows.Count > 0) { ls_jsrid = dtuser.Rows[0]["hy_userid"].ToString(); } string ls_yqm = ""; string ls_yqms = GetRandom3(); if (lv_jsrname[i] == "管理员") { ls_yqm = "000" + ls_yqms; } else { //Response.Write("<script>alert('" + ls_jsrid + "')</script>"); //return; if (ls_jsrid != "" && ls_jsrid.Length - 3 > 0) { ls_yqm = ls_jsrid.Substring(ls_jsrid.Length - 3) + ls_yqms; //获得6位数字的随机数 } } ////发送待办 //string ls_dburl = "wstp.aspx?rnd=" + Hyoa_global.GetRandom(); //string ls_body = this.Session["hyuname"].ToString() + "发起投票,请您参与"; //Hyoa_global.Senddbsy_global(this.txtdocid.Value, lv_jsrid[i].ToString(), lv_jsrname[i].ToString(), // this.Session["hyuid"].ToString(), this.Session["hyuname"].ToString(), ls_dburl, "待办", this.hy_mudelid.Text, "待办箱", "一般", ls_body, "请参与", 0, "", ""); //给参与的人发送邮件 //string ls_dburl = "/wstp.aspx?yqm=" + ls_yqm + "&rnd=" + Hyoa_global.GetRandom(); string ls_dburl = "/wstp.aspx?rnd=" + Hyoa_global.GetRandom(); string ls_title = "[投票管理]-请参与" + ls_tplb + "的投票"; string ls_body = "您投票的邀请码为:" + ls_yqm + "。<a href=" + ls_dburl + " target=\"_blank\">请点击进入投票页面!</a>"; String ls_sql = "insert into hyt_mail(ID,DOCID,hy_type,hy_foldername,hy_fsrid,hy_fsrname,hy_jsrid,hy_wbjsrid,hy_jsrname,hy_title,hy_body,hy_datetime,hy_ifsavetofjx,hy_yxj,hy_yjbg,hy_zycd,hy_hz,hy_wbjszh) values "; ls_sql += "('" + Hyoa_global.GetRandom() + "','" + Hyoa_global.GetRandom() + "','收件','收件箱','admin','管理员','" + ls_jsrid + "','','" + lv_jsrname[i].ToString() + "','" + ls_title + "','" + ls_body + "','" + System.DateTime.Now.ToString() + "','','','','','','') "; db.Execute(ls_sql); //将邀请码 if (ls_yqmlists == "") { ls_yqmlists = ls_yqm; } else { ls_yqmlists = ls_yqmlists + "+" + ls_yqm; } } } } //更新表 string sql = "update hyp_flowmain set hy_field30='" + ls_yqmlists + "',hy_field100=1 where hy_field20='" + ls_tplb + "'"; db.Execute(sql); db.Close(); db.Dispose(); this.txtuids.Value = ""; //DataPlay(System.Int32.Parse(this.curpage.Text)); Response.Write("<script>alert('发布投票成功!');window.location = '/list_tpgl.aspx?mid=moduletpgl&tableid=bb4c4ac0-53b4-4c7f-89a6-4bde425c24fd';</script>"); }