Esempio n. 1
0
        protected void btn_send_Click(object sender, EventArgs e)
        {
            string msg = this.CheckControlValue();

            if (!string.IsNullOrEmpty(msg))
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", "showWarn('" + msg + "');", true);
                return;
            }
            if (string.IsNullOrEmpty(this.txtReceiverIds.Text.Trim(',')) && string.IsNullOrEmpty(this.db_newSxr.Text.Trim().Trim(',')))
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", "showWarn('请选择或输入收信人!');", true);
                return;
            }

            List <IDataItem> list   = this.GetControlValue();
            string           sxrIds = "";
            DataTable        dt     = BLL.RetrieveDxjb_AllSxr_List().Result;

            foreach (string s in this.txtReceiverIds.Text.Trim().Trim(',').Split(','))
            {
                if (!string.IsNullOrEmpty(s))
                {
                    DataRow[] rows = dt.Select("SjmlID=" + s);
                    if (rows != null && rows.Length > 0)
                    {
                        if (!string.IsNullOrEmpty(rows[0]["sjmlMobile"].ToString2().Trim()))
                        {
                            sxrIds += rows[0]["sjmlMobile"].ToString2().Trim() + ",";
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "showWarn('\"" + rows[0]["SjmlName"] + "\"收信人号码为空,无法发送短信!');", true);
                            return;
                        }
                    }
                }
            }
            string sxr = this.db_fsdx.Text.Trim().Trim(',');

            string[] mobiles;
            if (!string.IsNullOrEmpty(this.db_newSxr.Text.Trim().Trim(new char[','])))
            {
                mobiles = this.db_newSxr.Text.Trim().Trim(',').Split(',');

                if (mobiles != null && mobiles.Length > 0)
                {
                    foreach (var item in mobiles)
                    {
                        if (!string.IsNullOrEmpty(item))
                        {
                            sxrIds += item + ",";
                        }
                        if (string.IsNullOrEmpty(sxr))
                        {
                            sxr += "【" + item + "】";
                        }
                        else
                        {
                            sxr += ",【" + item + "】";
                        }
                    }
                }
            }
            if (string.IsNullOrEmpty(sxrIds.Trim(',')))
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", "showWarn('收信人号码为空!');", true);
                return;
            }
            WebCommon.AddDataItem(list, "SxrNumbers", sxrIds.Trim(','));

            WebCommon.AddDataItem(list, "Jbmc", this.db_Jbmc.Text);
            WebCommon.AddDataItem(list, "Jbnr", this.db_Jbnr.Text);
            WebCommon.AddDataItem(list, "EveryWeekOne", "0");
            WebCommon.AddDataItem(list, "IsDsfs", "False");
            WebCommon.AddDataItem(list, "EveryWeekOne", "0");
            WebCommon.AddDataItem(list, "EveryMonthOne", "0");
            WebCommon.AddDataItem(list, "EveryQuarterOne", "0");
            WebCommon.AddDataItem(list, "Sxr", sxr);

            //WebCommon.AddDataItem(list, "UserID", this.WorkUser.UserID);
            //WebCommon.AddDataItem(list, "Fxr", this.WorkUser.UserName);
            //WebCommon.AddDataItem(list, "SendTime", DateTime.Now.ToString());
            string errorPhone          = "";
            FunctionResult <string> fr = BLL.SendDxjb(this.ddl_yzjb.SelectedValue, list, out errorPhone);

            if (fr.Status != FunctionResultStatus.Error)
            {
                if (string.IsNullOrEmpty(errorPhone))
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "SaveResult('" + fr.Result + "');", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "ShowWarnResult('" + fr.Result + "');", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", "showWarn('" + fr.Result + "');", true);
            }
        }