private bool ValidateData()
    {
        if(string.IsNullOrWhiteSpace(txtName.Text))
        {
            ShowAlert("الرجاء ادخال الاسم", MsgType.Error);
            return false;
        }
        AppFunctions f=new AppFunctions();
        if (!f.IsPhoneValid(txtPhoneNumber.Text))
        {
            ShowAlert("الرجاء التأكد من رقم الهاتف", MsgType.Error);
            return false;
        }
        if(fileImg.HasFile)
        {
            List<string> acceptedExe=new List<string>();
            acceptedExe.Add(".jpg");
            acceptedExe.Add(".gif");
            acceptedExe.Add(".png");
            string exe = System.IO.Path.GetExtension(fileImg.PostedFile.FileName).ToLower();
            if (!acceptedExe.Contains(exe))
            {
                ShowAlert("الرجاء اختيار ملف صورة", MsgType.Error);
                return false;
            }
        }

        return true;
    }
    private bool ValidateData()
    {
        if (string.IsNullOrWhiteSpace(txtName.Text))
        {
            ShowAlert("الرجاء ادخال الاسم", MsgType.Error);
            return(false);
        }
        AppFunctions f = new AppFunctions();

        if (!f.IsPhoneValid(txtPhoneNumber.Text))
        {
            ShowAlert("الرجاء التأكد من رقم الهاتف", MsgType.Error);
            return(false);
        }
        if (fileImg.HasFile)
        {
            List <string> acceptedExe = new List <string>();
            acceptedExe.Add(".jpg");
            acceptedExe.Add(".gif");
            acceptedExe.Add(".png");
            string exe = System.IO.Path.GetExtension(fileImg.PostedFile.FileName).ToLower();
            if (!acceptedExe.Contains(exe))
            {
                ShowAlert("الرجاء اختيار ملف صورة", MsgType.Error);
                return(false);
            }
        }

        return(true);
    }
Beispiel #3
0
    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);
    }
Beispiel #4
0
    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;
    }
Beispiel #5
0
    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);
        }
    }
Beispiel #6
0
    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);
        }
    }