protected void btnSave_OnClick(object sender, EventArgs e) { string researchid = txtResearchList.Text; if(string.IsNullOrWhiteSpace(researchid) && !CheckBox1.Checked) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء اختيار باحث على الاقل\")</SCRIPT>", false); return; } if (string.IsNullOrWhiteSpace(txtSubject.Text)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال عنوان الرسالة\")</SCRIPT>", false); return; } if (string.IsNullOrWhiteSpace(txtTxt.Text)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال الرسالة\")</SCRIPT>", false); return; } Database db=new Database(); DataTable dt; if(!CheckBox1.Checked) { dt = db.ExecuteDataTable("select * from Researcher where isAproved=1 and (id in (" + researchid + "))"); } else { dt = db.ExecuteDataTable("select * from Researcher where isAproved=1"); } List<string> to=new List<string>(); AppFunctions validate=new AppFunctions(); foreach (DataRow row in dt.Rows) { if(RadioButtonList1.SelectedValue.Equals("1")) { if (validate.IsEmailValid(row["email"].ToString())) { to.Add(row["email"].ToString()); } } else { if (validate.IsPhoneValid(row["phone"].ToString())) { to.Add(row["phone"].ToString()); } } } if (RadioButtonList1.SelectedValue.Equals("1")) { SendMail mail = new SendMail(); mail.SendMsg(to, txtSubject.Text, txtTxt.Text); ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"تم ارسال رسالة بريد الالكتروني الى الباحثين و عددهم " + dt.Rows.Count+"\")</SCRIPT>", false); } else { Tools t = new Tools(); SMSSender sms = new SMSSender(); sms.Message = txtTxt.Text; sms.SendSms(to); ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"تم ارسال رسالة نصية الى الباحثين و عددهم " + dt.Rows.Count + "\")</SCRIPT>", false); } }
protected void btnSave_OnClick(object sender, EventArgs e) { string researchid = txtResearchList.Text; if (string.IsNullOrWhiteSpace(researchid) && !CheckBox1.Checked) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء اختيار باحث على الاقل\")</SCRIPT>", false); return; } if (string.IsNullOrWhiteSpace(txtSubject.Text)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال عنوان الرسالة\")</SCRIPT>", false); return; } if (string.IsNullOrWhiteSpace(txtTxt.Text)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال الرسالة\")</SCRIPT>", false); return; } Database db = new Database(); DataTable dt; if (!CheckBox1.Checked) { dt = db.ExecuteDataTable("select * from Researcher where isAproved=1 and (id in (" + researchid + "))"); } else { dt = db.ExecuteDataTable("select * from Researcher where isAproved=1"); } List <string> to = new List <string>(); AppFunctions validate = new AppFunctions(); foreach (DataRow row in dt.Rows) { if (RadioButtonList1.SelectedValue.Equals("1")) { if (validate.IsEmailValid(row["email"].ToString())) { to.Add(row["email"].ToString()); } } else { if (validate.IsPhoneValid(row["phone"].ToString())) { to.Add(row["phone"].ToString()); } } } if (RadioButtonList1.SelectedValue.Equals("1")) { SendMail mail = new SendMail(); mail.SendMsg(to, txtSubject.Text, txtTxt.Text); ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"تم ارسال رسالة بريد الالكتروني الى الباحثين و عددهم " + dt.Rows.Count + "\")</SCRIPT>", false); } else { Tools t = new Tools(); SMSSender sms = new SMSSender(); sms.Message = txtTxt.Text; sms.SendSms(to); ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"تم ارسال رسالة نصية الى الباحثين و عددهم " + dt.Rows.Count + "\")</SCRIPT>", false); } }