Exemplo n.º 1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string ids = "";
        XYECOM.Business.SendEmail se = new XYECOM.Business.SendEmail();
        foreach (GridViewRow GR in this.gvlist.Rows)
        {
            if (((CheckBox)(GR.FindControl("chkExport"))).Checked == true)
            {
                ids += "," + this.gvlist.DataKeys[GR.DataItemIndex].Value.ToString();
            }
        }
        if (ids.IndexOf(",") == 0)
        {
            ids = ids.Substring(1);
            int i = 0;
            i = se.Deletes(ids);
            string url = "SendEmail.aspx";
            if (i >= 0)
            {
                XYECOM.Business.Admin ad = new XYECOM.Business.Admin();
                XYECOM.Model.AdminInfo ea = new XYECOM.Model.AdminInfo();

                Alert("删除成功!", url);
                dvDataBind();
            }
            else
            {
                Alert("删除失败!", url);
            }
        }
    }
Exemplo n.º 2
0
    protected void Button2_Click2(object sender, EventArgs e)
    {
        string UG_IDS = "";
        for (int i = 0; i < CBL.Items.Count; i++)
        {
            if (CBL.Items[i].Selected)
            {
                UG_IDS += "," + CBL.Items[i].Value;
            }
        }
        //给用户组发
        if (UG_IDS.Length > 0)
        {
            DataTable dt = Function.GetDataTable(" where UG_ID  in (" + UG_IDS.Substring(1) + ")", "", " XYV_UserInfo");
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    str = this.lbcontent.Value.Replace("{loginname}", dt.Rows[i]["U_Name"].ToString()).Replace("{username}", dt.Rows[i]["UI_Name"].ToString()).Replace("{userid}", dt.Rows[i]["U_ID"].ToString());
                    XYECOM.Business.Utils.SendMail(dt.Rows[i]["U_Email"].ToString(), this.lbtitle.Text, str);
                }
            }
        }
        string h = "";
        String c = "";
        String isAll = this.personall.Value;
        DataTable dt2 = new DataTable();
        if (!isAll.Equals("1"))
        {
            foreach (GridViewRow gv in gvlist.Rows)
            {
                if (((CheckBox)(gv.FindControl("chkExport"))).Checked == true)
                {
                    h += "," + gvlist.DataKeys[gv.DataItemIndex].Value.ToString();
                }
            }
        }

        if (isAll.Equals("1"))
        {
            dt2 = Function.GetDataTable(" where 1=1 ", "", " XYV_individual");
        }
        else {
            if(h.Length > 0)
                dt2 = Function.GetDataTable(" where U_ID  in (" + h.Substring(1) + ")", "", " XYV_individual");
        }

        if (dt2.Rows.Count > 0)
        {
            for (int t = 0; t < dt2.Rows.Count; t++)
            {
                str = this.lbcontent.Value.Replace("{loginname}", dt2.Rows[t]["U_Name"].ToString()).Replace("{username}", dt2.Rows[t]["UI_Name"].ToString()).Replace("{userid}", dt2.Rows[t]["U_ID"].ToString());
                XYECOM.Business.Utils.SendMail(dt2.Rows[t]["U_Email"].ToString(),this.lbtitle.Text, str);
            }
        }

        foreach (GridViewRow gv in GridView1.Rows)
        {
            if (((CheckBox)(gv.FindControl("chkExport1"))).Checked == true)
            {
                c += "," + GridView1.DataKeys[gv.DataItemIndex].Value.ToString();
            }
        }
        if (c.Length > 0)
        {
            DataTable dt3 = Function.GetDataTable(" where U_ID  in (" + c.Substring(1) + ")", "", " XYV_UserInfo");
            if (dt3.Rows.Count > 0)
            {

                for (int t = 0; t < dt3.Rows.Count; t++)
                {
                    str = this.lbcontent.Value.Replace("{loginname}", dt3.Rows[t]["U_Name"].ToString()).Replace("{username}", dt3.Rows[t]["UI_Name"].ToString()).Replace("{userid}", dt3.Rows[t]["U_ID"].ToString());
                    XYECOM.Business.Utils.SendMail(dt3.Rows[t]["U_Email"].ToString(), this.lbtitle.Text,str) ;
                }
            }
        }

        XYECOM.Business.SendEmail ee = new XYECOM.Business.SendEmail();
        XYECOM.Model.SendEmailInfo se = new XYECOM.Model.SendEmailInfo();
        se.E_title = this.lbtitle.Text;
        se.E_content = str;

        se.U_IDS = UG_IDS;
        int y = 0;
        string url = "SendEmail.aspx";
        y = ee.Insert(se);

        if (y >= 0)
        {
            Alert("发送成功!", url);
        }
        else
        {
            Alert("发送失败!", url);
        }
    }