viewsmsinfo.aspx.cs

来自「该服务平台解决了计算机网络与移动网络之间信息交换问题」· CS 代码 · 共 459 行 · 第 1/2 页

CS
459
字号
    protected void btnrest_Click(object sender, EventArgs e)
    {
        string GetUrl = "";
        string smsFalg = Request.QueryString[2].ToString();
        string  SMSType =  Request.QueryString[3].ToString();
        if (smsFalg == "1")
        {
             GetUrl = string.Format("SubmisionMsg.aspx?SMSType={0}", Request.QueryString[3].ToString());  
         }

        else
        {                        
               GetUrl = string.Format("AreadySendSMS.aspx?SMSType={0} ", Request.QueryString[3].ToString());
        }
        Response.Redirect(GetUrl);

    }

    #region 发送
    protected void btnSub_Click(object sender, EventArgs e)
    {
        DataAccess.TableAccessor.SMSInfo smsInfo = new DataAccess.TableAccessor.SMSInfo();
        DataAccess.SendSMS sendSMS = new DataAccess.SendSMS();
        DataAccess.CookieAccessor cookieAccessor = new DataAccess.CookieAccessor();
        DataAccess.TableAccessor.UserInfo userInfo = new DataAccess.TableAccessor.UserInfo();
        //DataAccess.TableAccessor.UserInfo userInfo = new DataAccess.TableAccessor.UserInfo();

        string SMSType = Request.QueryString[2].ToString();

        int sendUserID = cookieAccessor.GetLoginUserOperationID();
        int userID = cookieAccessor.GetLoginUserOperationID();
        int smsID = int.Parse(Request.QueryString[0].ToString());
        String smsContent = smsInfo.GetMsgContentBySMSID(smsID);       
        string pretime = smsInfo.GetTimeBySMSID(smsID);

        #region  选择发送方式
        string sendType = this.RBList1.SelectedValue.ToString();
        string nowTime = "";
        string sendTime = "";

        string y = DateTime.Now.Year.ToString().Trim();
        string m = DateTime.Now.Month.ToString().Trim();
        string d = DateTime.Now.Day.ToString().Trim();
        string h = DateTime.Now.Hour.ToString().Trim();
        string s = DateTime.Now.Second.ToString().Trim();
        nowTime = y + "-".Trim() + m + "-".Trim() + d + " " + h + ":".Trim() + s;
        if (sendType == "0")
        {
            this.dttext.Visible = false;
            this.hour.Visible = false;
            this.second.Visible = false;
        }
        else
        {
            dttext.Visible = true;
            hour.Visible = true;
            second.Visible = true;
            string dataTime = Request.Form["dttext"];
            string Second1 = this.second.SelectedItem.ToString();
            string Hour1 = this.hour.SelectedItem.ToString();
            sendTime = dataTime + " " + Second1 + ":" + Hour1;




        }
        if (sendTime != "")
        {
            if (DateTime.Parse(sendTime) < DateTime.Parse(nowTime))
            {
                this.lbBZ.Text = "<script language='javascript'>alert('定时发送时间必须大于当前时间!');</script>";
            }
            else
            {
                smsInfo.ChangeSMSFlag(smsID, 1, sendUserID, sendTime, sendType);                 
               
            }
        }
        else
        {
            smsInfo.ChangeSMSFlag(smsID, 1, sendUserID, sendTime, sendType);               
          
        }
        #endregion

        int countSendUser = 0;
        
        int trade = 0;
        int count = 0;
        int totalSMS = smsInfo.GetCount();//允许发送的最大条数
        int countSMS = smsInfo.GetCountSMS();//统计已发条数
        DataTable dt = smsSendUserList.GetSemdUserList(smsID);

        #region 删除重复用户
        for (int t = 0; t < dt.Rows.Count; t++)
        {
            int count1 = smsSendUserList.DeleteRepeat(smsID);
        }
        #endregion
        try
        {
            DataTable dtb = smsSendUserList.GetSemdUserList(smsID);
            count = countSMS + dtb.Rows.Count;
            //count = countSMS;
            if (count <= totalSMS) //已发短信统计
            {
                for (int i = 0; i < dtb.Rows.Count; i++)
                {
                    string mobile = dtb.Rows[i]["Mobile"].ToString();
                    trade = userInfo.GetTradeByMobile(mobile);
                    string companyID = "001";
                    smsInfo.Send(mobile, smsContent, trade);
                    sendSMS.SendingSMS(mobile, smsContent, trade, companyID, pretime);
                    countSendUser++;
                }
                if (sendType == "0")
                {
                    try
                    {
                        smsInfo.UpdateCountSMSInfo(countSendUser, 0, int.Parse(Request.QueryString[0].ToString()));
                        smsInfo.ChangeSMSFlagAndSetSendManID(smsID, userID);//AreadySendSMS.aspx?SMSType=1
                        Response.Write("<script language='javascript'>alert('发送短信成功!');</script>");//SubmisionMsg.aspx?SMSType=1
                        string url = string.Format("<script>window.location.href ='SubmisionMsg.aspx?SMSType={0}'</script>", Request.QueryString[2].ToString());
                        Response.Write("<script>top.Title.window.location='../TreeViewPage.aspx'</script>");
                        Response.Write(url);
                    }
                    catch
                    {
                        this.lbBZ.Text = "<script language='javascript'>alert('请选择要发送的用户!');</script>";
                        string url = string.Format("<script>window.location.href ='SubmisionMsg.aspx?SMSType={0}'</script>", Request.QueryString[2].ToString());
                        Response.Write(url);
                    }
                }
                else if (sendType == "1")
                {
                    try
                    {
                        smsInfo.UpdateCountSMSInfo(countSendUser, 0, int.Parse(Request.QueryString[0].ToString()));
                        smsInfo.ChangeSMSFlagAndSetSendManID(smsID, userID);//AreadySendSMS.aspx?SMSType=1
                        Response.Write("<script language='javascript'>alert('发送短信成功!');</script>");//SubmisionMsg.aspx?SMSType=1
                        string url = string.Format("<script>window.location.href ='TimeSend.aspx'</script>");
                        Response.Write("<script>top.Title.window.location='../TreeViewPage.aspx'</script>");
                        Response.Write(url);
                    }
                    catch
                    {
                        this.lbBZ.Text = "<script language='javascript'>alert('请选择要发送的用户!');</script>";
                        string url = string.Format("<script>window.location.href ='SubmisionMsg.aspx?SMSType={0}'</script>", Request.QueryString[2].ToString());
                        Response.Write(url);
                    }
                }
            }
            else
            {
                int remnantCount1 = totalSMS - countSMS;
                this.tbWordCount.Text = remnantCount1.ToString();
                //int remnantCount = 15 - count;//当前可以发的条数:'+remnantCount(15-count)'你所发短信已超出充许的最大条数!当前可以发的条数:'
                this.lbBZ.Text = "<script language='javascript'>alert('你所发短信已超出充许的最大条数!');</script>";
            }
        }

        catch
        {
            Response.Write("<script language='javascript'>alert('发送短信失败!');</script>");
            string url = string.Format("<script>window.location.href ='SubmisionMsg.aspx?SMSType={0}'</script>", Request.QueryString[2].ToString());
            Response.Write(url);
        }
    }
    #endregion

    #region 更新短信内容
    protected void btSave_Click(object sender, EventArgs e)
    {
        if (tbSMS.Text != "" && tbSMS.Text.Length < 70)
        {
            smsInfo = new DataAccess.TableAccessor.SMSInfo();
            try
            {
                smsInfo.UpdateSMSInfo(tbSMS.Text, int.Parse(Request.QueryString[0].ToString()));
                this.lbBZ.Text ="<script language='javascript'>alert('更新成功!');</script>";

            }
            catch
            {
                this.lbBZ.Text ="<script language='javascript'>alert('更新失败!');</script>";
                return;
            }
        }
        else
        {
            this.lbBZ.Text = "<script language='javascript'>alert('短信内容不能超过70个字');</script>";
            return;
        }
    }
    #endregion

    #region 选择要发送的对象
    protected void btChoice_Click(object sender, EventArgs e)
    {
        int smsID = int.Parse(Request.QueryString[0].ToString());
        int operationID = int.Parse(Request.QueryString[1].ToString());
        int smstype = int.Parse(Request.QueryString[0].ToString());


        if (tbSMS.Text != "")
        {
            string url = string.Format("<script>window.location.href = 'SMSSend.aspx?smsID={0}&operationid=1&smsType={1}'</script>",
            smsID, int.Parse(Request.QueryString[0].ToString()));
            Response.Write(url);
        }
        else
        {
            this.lbBZ.Text = "<script language='javascript'>alert('短信内容不能为空!');</script>";
            return;
        }
       
    }
    #endregion

    protected void RBList1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?