protected void btnForgetPass_Click(object sender, EventArgs e) { AppFunctions v = new AppFunctions(); if (!v.IsEmailValid(txtEmail.Text)) { ErrorDiv.Visible = true; sp1.Visible = true; lblError.Text = "<i class=\"fa fa-exclamation-triangle fcRed\"></i> الرجاء التأكد من البريد الالكتروني."; return; } Database db = new Database(); db.AddParameter("@email", txtEmail.Text); System.Data.DataTable dt = db.ExecuteDataTable("Select * from AdminUsers where email=@email"); if (dt.Rows.Count == 0) { ErrorDiv.Visible = true; sp1.Visible = true; lblError.Text = "<i class=\"fa fa-exclamation-triangle fcRed\"></i> هذا البريد الالكتروني غير مسجل في النظام"; return; } string body = "<h2>"; body += "هذة معلومات الدخول الى لوحة التحكم الخاصة بموقع الدليل الاإلكتروني لإرشفة القرارات و التعاميم الحكومية<br/>"; body += "اسم المستخدم : " + dt.Rows[0]["username"].ToString() + "<br/>"; body += "البريد الالكتروني : " + dt.Rows[0]["email"].ToString() + "<br/>"; body += "كلمة السر : " + dt.Rows[0]["password"].ToString() + "<br/>"; body += "</h2>"; SendMail mail = new SendMail(); mail.SendMsg(txtEmail.Text, "الدليل الاإلكتروني لإرشفة القرارات و التعاميم الحكومية", body); ScriptManager.RegisterClientScriptBlock(this,GetType(), "writeMsg", "alert('تم ارسال كلمة السر الي البريد الالكتروني " + txtEmail.Text + " ');", true); }
protected void btnForgetPass_Click(object sender, EventArgs e) { AppFunctions v = new AppFunctions(); if (!v.IsEmailValid(txtEmail.Text)) { ErrorDiv.Visible = true; sp1.Visible = true; lblError.Text = "<i class=\"fa fa-exclamation-triangle fcRed\"></i> invalid email address format"; return; } Database db = new Database(); db.AddParameter("@email", txtEmail.Text); System.Data.DataTable dt = db.ExecuteDataTable("Select * from AdminUsers where email=@email"); if (dt.Rows.Count == 0) { ErrorDiv.Visible = true; sp1.Visible = true; lblError.Text = "<i class=\"fa fa-exclamation-triangle fcRed\"></i> invalid email address"; return; } string body = "<h2>"; body += "هذة معلومات الدخول الى لوحة التحكم الخاصة المركز الوطني للدراسات والبحوث الإجتماعية<br/>"; body += "اسم المستخدم : " + dt.Rows[0]["username"].ToString() + "<br/>"; body += "البريد الالكتروني : " + dt.Rows[0]["email"].ToString() + "<br/>"; body += "كلمة السر : " + dt.Rows[0]["password"].ToString() + "<br/>"; body += "</h2>"; SendMail mail = new SendMail(); mail.SendMsg(txtEmail.Text, "المركز الوطني للدراسات والبحوث الإجتماعية", body); }
protected void btnForgetPass_Click(object sender, EventArgs e) { AppFunctions v = new AppFunctions(); if (!v.IsEmailValid(txtEmail.Text)) { ErrorDiv.Visible = true; sp1.Visible = true; lblError.Text = "<i class=\"fa fa-exclamation-triangle fcRed\"></i> الرجاء التأكد من البريد الالكتروني."; return; } Database db = new Database(); db.AddParameter("@email", txtEmail.Text); System.Data.DataTable dt = db.ExecuteDataTable("Select * from AdminUsers where email=@email"); if (dt.Rows.Count == 0) { ErrorDiv.Visible = true; sp1.Visible = true; lblError.Text = "<i class=\"fa fa-exclamation-triangle fcRed\"></i> هذا البريد الالكتروني غير مسجل في النظام"; return; } string body = "<h2>"; body += "هذة معلومات الدخول الى لوحة التحكم الخاصة بموقع الدليل الاإلكتروني لإرشفة القرارات و التعاميم الحكومية<br/>"; body += "اسم المستخدم : " + dt.Rows[0]["username"].ToString() + "<br/>"; body += "البريد الالكتروني : " + dt.Rows[0]["email"].ToString() + "<br/>"; body += "كلمة السر : " + dt.Rows[0]["password"].ToString() + "<br/>"; body += "</h2>"; SendMail mail = new SendMail(); mail.SendMsg(txtEmail.Text, "الدليل الاإلكتروني لإرشفة القرارات و التعاميم الحكومية", body); ScriptManager.RegisterClientScriptBlock(this, GetType(), "writeMsg", "alert('تم ارسال كلمة السر الي البريد الالكتروني " + txtEmail.Text + " ');", true); }
protected void btnSave_Click(object sender, EventArgs e) { AppFunctions v = new AppFunctions(); if (Request.QueryString["Op"].ToLower() == "add") { if (string.IsNullOrEmpty(txtFirstName.Text)) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال الاسم.\")</SCRIPT>", false); return; } if (string.IsNullOrEmpty(txtUsername.Text)) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال اسم المستخدم.\")</SCRIPT>", false); return; } if (string.IsNullOrEmpty(txtEmail.Text)) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال البريد الالكتروني.\")</SCRIPT>", false); return; } if (string.IsNullOrEmpty(txtPassword.Text)) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال كلمة السر.\")</SCRIPT>", false); return; } } if (!v.IsEmailValid(txtEmail.Text)) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء التحقق من البريد الالكتوني.\")</SCRIPT>", false); return; } if (txtPassword.Text.Length < 6) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"كلمة السر يجب ان تكون بطول 6 احرف على الاقل\")</SCRIPT>", false); return; } System.Data.DataTable dt = new System.Data.DataTable(); db.AddParameter("@username", txtUsername.Text); db.AddParameter("@Email", txtEmail.Text); if (Request.QueryString["Op"].ToLower().Equals("add")) { dt = db.ExecuteDataTable("Select * from AdminUsers Where UserName=@username Or Email=@Email"); } else if (Request.QueryString["Op"].ToLower().Equals("edit")) { db.AddParameter("@id", Request.QueryString["id"]); dt = db.ExecuteDataTable("Select * from AdminUsers Where (UserName=@username Or Email=@Email) and not id=@id"); } if (dt.Rows.Count != 0) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"خطأ : هذة البريد الالكتروني موجود مسبقا\")</SCRIPT>", false); return; } db.AddParameter("@Name", txtFirstName.Text); db.AddParameter("@UName", txtUsername.Text); db.AddParameter("@Password", txtPassword.Text); db.AddParameter("@Email", txtEmail.Text); db.AddParameter("@permition", ddlPermition.SelectedValue); if (Request.QueryString["Op"] == "Edit") { db.AddParameter("@id", Request.QueryString["id"]); db.ExecuteNonQuery("update " + tablename + " set email=@Email,Name=@Name,UserName=@UName,Password=@Password,permition=@permition where id=@id"); //ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"Contact Added successfully.\")</SCRIPT>", false); Response.Redirect("AdminList.aspx"); //ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"Contact Added successfully.\")</SCRIPT>", false); } else if (Request.QueryString["Op"] == "Add") { try { if (txtPassword.Text.Length <= 5) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"Password Must Be 6 Char lenght at least\")</SCRIPT>", false); return; } db.ExecuteNonQuery("insert into " + tablename + "(Name,UserName,Password,email,permition) Values(@Name,@UName,@Password,@Email,@permition)"); Response.Redirect("AdminList.aspx"); // ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"Contact Added successfully.\")</SCRIPT>", false); } catch { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"Please try again.\")</SCRIPT>", false); } } }
protected void btnSave_Click(object sender, EventArgs e) { AppFunctions v = new AppFunctions(); if (Request.QueryString["Op"].ToLower() == "add") { if (string.IsNullOrEmpty(txtFirstName.Text)) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال الاسم.\")</SCRIPT>", false); return; } if (string.IsNullOrEmpty(txtUsername.Text)) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال اسم المستخدم.\")</SCRIPT>", false); return; } if (string.IsNullOrEmpty(txtEmail.Text)) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال البريد الالكتروني.\")</SCRIPT>", false); return; } if (string.IsNullOrEmpty(txtPassword.Text)) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال كلمة السر.\")</SCRIPT>", false); return; } } if (!v.IsEmailValid(txtEmail.Text)) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء التحقق من البريد الالكتوني.\")</SCRIPT>", false); return; } if (txtPassword.Text.Length < 6) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"كلمة السر يجب ان تكون بطول 6 احرف على الاقل\")</SCRIPT>", false); return; } System.Data.DataTable dt = new System.Data.DataTable(); db.AddParameter("@username", txtUsername.Text); db.AddParameter("@Email", txtEmail.Text); if (Request.QueryString["Op"].ToLower().Equals("add")) { dt = db.ExecuteDataTable("Select * from AdminUsers Where UserName=@username Or Email=@Email"); } else if (Request.QueryString["Op"].ToLower().Equals("edit")) { db.AddParameter("@id", Request.QueryString["id"]); dt = db.ExecuteDataTable("Select * from AdminUsers Where (UserName=@username Or Email=@Email) and not id=@id"); } if (dt.Rows.Count != 0) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"خطأ : هذة البريد الالكتروني موجود مسبقا\")</SCRIPT>", false); return; } db.AddParameter("@Name", txtFirstName.Text); db.AddParameter("@UName", txtUsername.Text); db.AddParameter("@Password", txtPassword.Text); db.AddParameter("@Email", txtEmail.Text); db.AddParameter("@permition", ddlPermition.SelectedValue); if (Request.QueryString["Op"] == "Edit") { db.AddParameter("@id", Request.QueryString["id"]); db.ExecuteNonQuery("update " + tablename + " set email=@Email,Name=@Name,UserName=@UName,Password=@Password,permition=@permition where id=@id"); //ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"Contact Added successfully.\")</SCRIPT>", false); Response.Redirect("AdminList.aspx"); //ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"Contact Added successfully.\")</SCRIPT>", false); } else if (Request.QueryString["Op"] == "Add") { try { if (txtPassword.Text.Length <= 5) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"Password Must Be 6 Char lenght at least\")</SCRIPT>", false); return; } db.ExecuteNonQuery("insert into " + tablename + "(Name,UserName,Password,email,permition) Values(@Name,@UName,@Password,@Email,@permition)"); Response.Redirect("AdminList.aspx"); // ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"Contact Added successfully.\")</SCRIPT>", false); } catch { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"Please try again.\")</SCRIPT>", false); } } }
private bool ValidateData() { Lang lang = new Lang(); if (string.IsNullOrWhiteSpace(txtName.Text)) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("NameError") + "');", true); return(false); } if (ddlCountry.SelectedValue.Equals("-1")) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("CountryError") + "');", true); return(false); } if (string.IsNullOrWhiteSpace(txtMajor.Text)) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("MajorError") + "');", true); return(false); } if (ddlDegree.SelectedValue.Equals("-1")) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("DegreeError") + "');", true); return(false); } if (string.IsNullOrWhiteSpace(txtWorkPlace.Text)) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("WorkPlaceError") + "');", true); return(false); } AppFunctions v = new AppFunctions(); if (!v.IsEmailValid(txtEmail.Text)) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("EmailError") + "');", true); return(false); } if (!v.IsPhoneValid(txtPhone.Text)) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("PhoneError") + "');", true); return(false); } Regex reg = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(2000)); if (!reg.IsMatch(txtEmail.Text)) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("EmailError2") + "');", true); return(false); } Regex reg2 = new Regex(@"^http(s)?://([\w-]+.)+[\w-]+(/[\w- ./?%&=])?$", RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(2000)); if (!reg2.IsMatch(txtFacebook.Text) || !txtFacebook.Text.ToLower().Contains("facebook.com")) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("FacebookError") + "');", true); return(false); } if (!reg2.IsMatch(txtTwitter.Text) || !txtTwitter.Text.ToLower().Contains("twitter.com")) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("TwitterError") + "');", true); return(false); } if (!txtLinkedin.Text.ToLower().Contains("linkedin.com")) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("LinkedinrError") + "');", true); return(false); } if (string.IsNullOrWhiteSpace(txtPrev.Text)) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("PrevError") + "');", true); return(false); } if (!fileImage.HasFile) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("ImageError") + "');", true); return(false); } return(true); }
private bool ValidateData() { Lang lang=new Lang(); if (string.IsNullOrWhiteSpace(txtName.Text)) { ClientScript.RegisterClientScriptBlock(this.GetType(),"Alert1", "alertify.alert('"+lang.getByKey("")+"','"+lang.getByKey("NameError") +"');", true); return false; } if (ddlCountry.SelectedValue.Equals("-1")) { ClientScript.RegisterClientScriptBlock( this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("CountryError") + "');", true); return false; } if (string.IsNullOrWhiteSpace(txtMajor.Text)) { ClientScript.RegisterClientScriptBlock( this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("MajorError") + "');", true); return false; } if (ddlDegree.SelectedValue.Equals("-1")) { ClientScript.RegisterClientScriptBlock( this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("DegreeError") + "');", true); return false; } if (string.IsNullOrWhiteSpace(txtWorkPlace.Text)) { ClientScript.RegisterClientScriptBlock( this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("WorkPlaceError") + "');", true); return false; } AppFunctions v=new AppFunctions(); if (!v.IsEmailValid(txtEmail.Text)) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("EmailError") + "');", true); return false; } if (!v.IsPhoneValid(txtPhone.Text)) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("PhoneError") + "');", true); return false; } Regex reg=new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*",RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(2000)); if (!reg.IsMatch(txtEmail.Text)) { ClientScript.RegisterClientScriptBlock( this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("EmailError2") + "');", true); return false; } Regex reg2=new Regex(@"^http(s)?://([\w-]+.)+[\w-]+(/[\w- ./?%&=])?$", RegexOptions.IgnoreCase,TimeSpan.FromMilliseconds(2000)); if (!reg2.IsMatch(txtFacebook.Text) || !txtFacebook.Text.ToLower().Contains("facebook.com")) { ClientScript.RegisterClientScriptBlock( this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("FacebookError") + "');", true); return false; } if (!reg2.IsMatch(txtTwitter.Text) || !txtTwitter.Text.ToLower().Contains("twitter.com")) { ClientScript.RegisterClientScriptBlock( this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("TwitterError") + "');", true); return false; } if ( !txtLinkedin.Text.ToLower().Contains("linkedin.com")) { ClientScript.RegisterClientScriptBlock( this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("LinkedinrError") + "');", true); return false; } if (string.IsNullOrWhiteSpace(txtPrev.Text)) { ClientScript.RegisterClientScriptBlock( this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("PrevError") + "');", true); return false; } if (!fileImage.HasFile) { ClientScript.RegisterClientScriptBlock( this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("ImageError") + "');", true); return false; } return true; }
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_Click(object sender, EventArgs e) { AppFunctions v = new AppFunctions(); if (Request.QueryString["Op"].Equals("Add") && !fileFile.HasFile) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء اختيار الصورة.\")</SCRIPT>", false); return; } if (string.IsNullOrEmpty(txtName.Text)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال الاسم.\")</SCRIPT>", false); return; } if (string.IsNullOrEmpty(txtOrganization.Text)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال جهة العمل.\")</SCRIPT>", false); return; } if (string.IsNullOrEmpty(txtUserName.Text)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال البريد الالكتروني.\")</SCRIPT>", false); return; } if (!v.IsEmailValid(txtUserName.Text)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء التأكد من البريد الالكتروني.\")</SCRIPT>", false); return; } /*DateTime tmp,tmp2; * * if (!DateTime.TryParseExact(datets.HijriToGreg(txtAddedDate.Text, "d/M/yyyy"), "d/M/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out tmp)) * { * ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء التأكد من التاريخ الاضافة\")</SCRIPT>", false); * return; * } * * if (!DateTime.TryParseExact(datets.HijriToGreg(txtFileDate.Text, "d/M/yyyy"), "d/M/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out tmp2)) * { * ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء التأكد من تاريخ الملف\")</SCRIPT>", false); * return; * }*/ if (fileFile.HasFile) { if (!Tools.IsImage(fileFile.PostedFile.FileName)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء التأكد من ملف الصورة\")</SCRIPT>", false); return; } try { if (ViewState["file"] != null) { System.IO.File.Delete(Server.MapPath("~/SystemFiles/Users/" + ViewState["file"].ToString())); } ViewState["file"] = DateTime.Now.Ticks + System.IO.Path.GetFileName(fileFile.PostedFile.FileName); fileFile.PostedFile.SaveAs(Server.MapPath("~/SystemFiles/Users/" + ViewState["file"].ToString())); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"Error : " + ex.Message + "\")</SCRIPT>", false); return; } } db.AddParameter("@name", txtName.Text); db.AddParameter("@username", txtUserName.Text); db.AddParameter("@password", txtPassword.Text); db.AddParameter("@Organization", txtOrganization.Text); db.AddParameter("@RequerChange", RadioButtonList1.SelectedValue); DateTime tmp2; if (DateTime.TryParseExact(datets.HijriToGreg(txtLockedTo.Text, "d/M/yyyy"), "d/M/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out tmp2)) { db.AddParameter("@LockedTo", tmp2); } else { db.AddParameter("@LockedTo", DBNull.Value); } db.AddParameter("@IsActive", ddlStatus.SelectedValue); db.AddParameter("@JobTitle", txtJobTitle.Text); db.AddParameter("@phone", txtPhone.Text); db.AddParameter("@Mobile", txtMobile.Text); db.AddParameter("@img", ViewState["file"].ToString()); if (Request.QueryString["Op"].Equals("Edit")) { try { db.AddParameter("@id", Request.QueryString["id"]); db.ExecuteNonQuery("Update " + tablename + " Set name=@name,[username]=@username,[img]=@img,password=@password,[RequerChange]=@RequerChange,[LockedTo]=@LockedTo,[IsActive]=@IsActive,[JobTitle]=@JobTitle,[Phone]=@Phone,[Mobile]=@Mobile,Organization=@Organization where Id=@id"); ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "alertify.alert('تم التعديل ','تم التعديل بنجاح').set('onok', function(closeEvent){ location.href='" + listpage + "'; } );", true); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"Error : " + ex.Message + "\")</SCRIPT>", false); } } else if (Request.QueryString["Op"] == "Add") { db.ExecuteNonQuery("Insert into " + tablename + "(name,username,password,RequerChange,LockedTo,IsActive,JobTitle,Phone,Img,Organization,Mobile) Values(@name,@username,@password,@RequerChange,@LockedTo,@IsActive,@JobTitle,@Phone,@Img,@Organization,@Mobile)"); ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "alertify.alert('تم الاضافة ','تم الاضافة بنجاح').set('onok', function(closeEvent){ location.href='" + listpage + "'; } );", true); } }
protected void btnSave_Click(object sender, EventArgs e) { AppFunctions v=new AppFunctions(); if (Request.QueryString["Op"].Equals("Add") && !fileFile.HasFile) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء اختيار الصورة.\")</SCRIPT>", false); return; } if (string.IsNullOrEmpty(txtName.Text)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال الاسم.\")</SCRIPT>", false); return; } if (string.IsNullOrEmpty(txtOrganization.Text)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال جهة العمل.\")</SCRIPT>", false); return; } if (string.IsNullOrEmpty(txtUserName.Text)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال البريد الالكتروني.\")</SCRIPT>", false); return; } if (!v.IsEmailValid(txtUserName.Text)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء التأكد من البريد الالكتروني.\")</SCRIPT>", false); return; } /*DateTime tmp,tmp2; if (!DateTime.TryParseExact(datets.HijriToGreg(txtAddedDate.Text, "d/M/yyyy"), "d/M/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out tmp)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء التأكد من التاريخ الاضافة\")</SCRIPT>", false); return; } if (!DateTime.TryParseExact(datets.HijriToGreg(txtFileDate.Text, "d/M/yyyy"), "d/M/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out tmp2)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء التأكد من تاريخ الملف\")</SCRIPT>", false); return; }*/ if (fileFile.HasFile) { if (!Tools.IsImage(fileFile.PostedFile.FileName)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء التأكد من ملف الصورة\")</SCRIPT>", false); return; } try { if (ViewState["file"] != null) { System.IO.File.Delete(Server.MapPath("~/SystemFiles/Users/" + ViewState["file"].ToString())); } ViewState["file"] = DateTime.Now.Ticks + System.IO.Path.GetFileName(fileFile.PostedFile.FileName); fileFile.PostedFile.SaveAs(Server.MapPath("~/SystemFiles/Users/" + ViewState["file"].ToString())); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"Error : " + ex.Message + "\")</SCRIPT>", false); return; } } db.AddParameter("@name", txtName.Text); db.AddParameter("@username", txtUserName.Text); db.AddParameter("@password", txtPassword.Text); db.AddParameter("@Organization", txtOrganization.Text); db.AddParameter("@RequerChange", RadioButtonList1.SelectedValue); DateTime tmp2; if (DateTime.TryParseExact(datets.HijriToGreg(txtLockedTo.Text, "d/M/yyyy"), "d/M/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out tmp2)) { db.AddParameter("@LockedTo", tmp2); } else { db.AddParameter("@LockedTo", DBNull.Value); } db.AddParameter("@IsActive", ddlStatus.SelectedValue); db.AddParameter("@JobTitle",txtJobTitle.Text); db.AddParameter("@phone", txtPhone.Text); db.AddParameter("@Mobile", txtMobile.Text); db.AddParameter("@img", ViewState["file"].ToString()); if (Request.QueryString["Op"].Equals("Edit")) { try { db.AddParameter("@id", Request.QueryString["id"]); db.ExecuteNonQuery("Update " + tablename + " Set name=@name,[username]=@username,[img]=@img,password=@password,[RequerChange]=@RequerChange,[LockedTo]=@LockedTo,[IsActive]=@IsActive,[JobTitle]=@JobTitle,[Phone]=@Phone,[Mobile]=@Mobile,Organization=@Organization where Id=@id"); ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "alertify.alert('تم التعديل ','تم التعديل بنجاح').set('onok', function(closeEvent){ location.href='" + listpage+"'; } );", true); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"Error : " + ex.Message + "\")</SCRIPT>", false); } } else if (Request.QueryString["Op"] == "Add") { db.ExecuteNonQuery("Insert into " + tablename + "(name,username,password,RequerChange,LockedTo,IsActive,JobTitle,Phone,Img,Organization,Mobile) Values(@name,@username,@password,@RequerChange,@LockedTo,@IsActive,@JobTitle,@Phone,@Img,@Organization,@Mobile)"); ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "alertify.alert('تم الاضافة ','تم الاضافة بنجاح').set('onok', function(closeEvent){ location.href='" + listpage + "'; } );", true); } }
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); } }