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;
    }
Example #2
0
        private void InitData()
        {
            Model = new AboutWindowModel();

            Model.Username = UserFunctions.GetFQDN();
            Model.AppBuild = AppFunctions.GetAppBuild();
        }
Example #3
0
    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);
    }
    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);
    }
Example #5
0
        // GET: Health/News/5
        public ActionResult News(string id)
        {
            string category = "Health";

            ViewBag.Category = category;

            ViewBag.HasMedia                = AppFunctions.ArticleHasMediaFile(AppFunctions.GetArticleIdFromIdentifier(id));
            ViewBag.ArticleMediaFileName    = AppFunctions.GetArticleMediaData(AppFunctions.GetArticleIdFromIdentifier(id), "FileName");
            ViewBag.ArticleMediaFileCaption = AppFunctions.GetArticleMediaData(AppFunctions.GetArticleIdFromIdentifier(id), "FileCaption");

            ViewBag.ArticleMediaFileType = AppFunctions.GetArticleMediaData(AppFunctions.GetArticleIdFromIdentifier(id), "FileType");
            string text_id = id;

            if (String.IsNullOrEmpty(text_id))
            {
                return(PartialView("~/Views/Home/_404.cshtml"));
            }
            int article_id = AppFunctions.GetNewsArticleIDFromTextID(text_id);
            NewsArticlesModel newsArticlesModel = db.NewsArticles.Find(article_id);

            if (newsArticlesModel == null)
            {
                return(PartialView("~/Views/Home/_404.cshtml"));
            }

            //Count page visit
            AppFunctions.AddArticlePageVisit(article_id);

            return(View(newsArticlesModel));
        }
Example #6
0
        public ActionResult Index()
        {
            AppFunctions apf = new AppFunctions();

            ViewBag.HeadLine1   = AppFunctions.GetNewsArticleData("ArticleHeadline", AppFunctions.GetLatestArticleIds(0));
            ViewBag.HeadLine1ID = AppFunctions.GetLatestArticleIds(0).ToString();
            //
            ViewBag.HeadLine2   = AppFunctions.GetNewsArticleData("ArticleHeadline", AppFunctions.GetLatestArticleIds(1));
            ViewBag.HeadLine2ID = AppFunctions.GetLatestArticleIds(1).ToString();
            //
            ViewBag.HeadLine3   = AppFunctions.GetNewsArticleData("ArticleHeadline", AppFunctions.GetLatestArticleIds(2));
            ViewBag.HeadLine3ID = AppFunctions.GetLatestArticleIds(2).ToString();
            //
            ViewBag.HeadLine4   = AppFunctions.GetNewsArticleData("ArticleHeadline", AppFunctions.GetLatestArticleIds(3));
            ViewBag.HeadLine4ID = AppFunctions.GetLatestArticleIds(3).ToString();
            //
            ViewBag.HeadLine5   = AppFunctions.GetNewsArticleData("ArticleHeadline", AppFunctions.GetLatestArticleIds(4));
            ViewBag.HeadLine5ID = AppFunctions.GetLatestArticleIds(4).ToString();
            //
            ViewBag.HeadLine6   = AppFunctions.GetNewsArticleData("ArticleHeadline", AppFunctions.GetLatestArticleIds(5));
            ViewBag.HeadLine6ID = AppFunctions.GetLatestArticleIds(5).ToString();

            ViewBag.ShowData = true;
            if (db.NewsArticles.Count(s => s.ReviewStatus == 1 && s.DeleteStatus != true) < 6)
            {
                ViewBag.ShowData = false;
            }

            var data = db.NewsArticles.Where(s => s.ReviewStatus == 1 && s.DeleteStatus != true);

            return(View(data));
            //var data = db.Posts.Where(s => s.ReviewStatus == 1 && s.DeleteStatus != true);
            //return View(db.Posts.ToList());
        }
Example #7
0
        //Function to send email using  sendgrid
        public static bool SendEmail(string from_email, string to_email, string email_subject, string message_body, string smtp_email, string smtp_pass, string display_name, string smtp_host, int smtp_port)
        {
            AppFunctions functions = new AppFunctions();

            try
            {
                var apiKey           = "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";
                var client           = new SendGridClient(apiKey);
                var from             = new EmailAddress(from_email, display_name);
                var subject          = email_subject;
                var to               = new EmailAddress(to_email, to_email.Split("@")[0]);
                var plainTextContent = functions.StripHTML(message_body);
                var htmlContent      = message_body;
                var msg              = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
                var response         = client.SendEmailAsync(msg);

                return(true);
            }
            catch (Exception ex)
            {
                //TODO log error
                Console.WriteLine(ex);
                return(false);
            }
        }
Example #8
0
        protected async override void OnAppearing()
        {
            base.OnAppearing();
            // URLContent.Text = await AppFunctions.devGetPage();

            List <string> testfiles = new List <string>();

            try
            {
                testfiles = await AppFunctions.devGetFiles();

                if (testfiles != null)
                {
                    TestList.ItemsSource = testfiles;
                }
                else
                {
                    await this.DisplayAlert("Test Mate", "No files found!", "OK");
                }
            }
            catch (Exception ex)
            {
                await this.DisplayAlert("Test Mate", "Something went wrong, but we've logged it in: " + ex.ToString(), "OK");
            }
        }
Example #9
0
    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);
    }
Example #10
0
        /**
         * This method handles receiving name data from the client and printing that name, only called once upon a client connecting.
         */
        private void RecieveNameCallback(IAsyncResult ar)
        {
            var current  = (Socket)ar.AsyncState;
            var received = 0;

            try
            {
                received = current.EndReceive(ar);

                if (received == 0)
                {
                    return;
                }

                // Creating a new client from the data received from the client, the client class has an overloaded constructor that takes a byte array and converts that data.
                client = new Client(mReceivedData);
                mClients.Add(client);

                var line = "";
                line = client.Name + " has entered the room";
                AppFunctions.AppendTextBox(line, receivedTxt);

                foreach (Socket client in mClientSockets)
                {
                    AppFunctions.SendText(line, client, mSendData);
                }

                // Ensure received data array is cleared for the next piece of data.
                Array.Clear(mReceivedData, 0, mReceivedData.Length);
            }
            catch (SocketException) { }
        }
Example #11
0
        /// <summary>
        /// Gets the industries.
        /// </summary>
        private void BindIndustries()
        {
            ContactServiceClient contactService = null;

            try
            {
                contactService = new ContactServiceClient();
                CollectionRequest         collectionRequest = new CollectionRequest();
                IndustrySearchCriteria    searchCriteria    = new IndustrySearchCriteria();
                IndustrySearchReturnValue returnValue       = contactService.IndustrySearch(_logonSettings.LogonId,
                                                                                            collectionRequest, searchCriteria);
                if (returnValue.Success)
                {
                    //Add a blank item
                    AppFunctions.AddDefaultToDropDownList(_ddlIndustry);

                    //Generate the items to be displayed in the Industry drop down list
                    //Get the main items
                    string industryText = string.Empty;
                    foreach (IndustrySearchItem industry in returnValue.Industries.Rows)
                    {
                        if (industry.ParentId == 0)
                        {
                            industryText = industry.Name;
                            _ddlIndustry.Items.Add(new ListItem(industryText, industry.Id.ToString()));

                            // Call method to get the sub items
                            GetIndustrySubItems(returnValue.Industries.Rows, industryText, industry.Id);
                        }
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblError.Text     = DataConstants.WSEndPointErrorMessage;
                _lblError.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblError.Text     = ex.Message;
                _lblError.CssClass = "errorMessage";
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        contactService.Close();
                    }
                }
            }
        }
Example #12
0
        /**
         * Method for handling all text sent from a client.
         * */
        private void RecieveCallback(IAsyncResult ar)
        {
            var current      = (Socket)ar.AsyncState;
            var received     = 0;
            var currentIndex = 0;

            currentIndex = UpdateIndex(current);

            try
            {
                received = current.EndReceive(ar);

                if (received == 0)
                {
                    return;
                }

                // Parsing the data sent, need to trim the end of any null characters.
                var text = "";
                text = Encoding.ASCII.GetString(mReceivedData, mReceivedData[received], mReceivedData.Length).TrimEnd('\0');

                // Handles closing the socket when the client clicks the exit button.
                if (text == "/exit")
                {
                    var line = "";
                    line = mClients[currentIndex].Name + " has left the room";
                    AppFunctions.AppendTextBox(line, receivedTxt);

                    foreach (Socket client in mClientSockets)
                    {
                        AppFunctions.SendText(line, client, mSendData);
                    }

                    // Remove client from the client list and the curent socket from the socket list, clear the received data array so that other people can still send data.
                    mClientSockets.Remove(current);
                    mClients.Remove(mClients[currentIndex]);
                    Array.Clear(mReceivedData, 0, mReceivedData.Length);
                }
                else
                {
                    var line = "";
                    line = mClients[currentIndex].Name + " says: " + text;
                    AppFunctions.AppendTextBox(line, receivedTxt);

                    // Send the received data to all clients.
                    foreach (Socket client in mClientSockets)
                    {
                        AppFunctions.SendText(line, client, mSendData);
                    }

                    // Clear the data array for the next piece of incoming data.
                    Array.Clear(mReceivedData, 0, mReceivedData.Length);
                    current.BeginReceive(mReceivedData, 0, mReceivedData.Length, SocketFlags.None, new AsyncCallback(RecieveCallback), current);
                }
            }
            catch (SocketException) { }
        }
Example #13
0
        /// <summary>
        /// Get and save settings to file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SaveSettingsButton_Clicked(object sender, EventArgs e)
        {
            App.questionOrder   = (Constants.QuestionOrder)QuestionOrderPicker.SelectedIndex;
            App.termDisplay     = (Constants.TermDisplay)TermDisplayPicker.SelectedIndex;
            App.provideFeedback = (Constants.ProvideFeedback)ProvideFeedbackPicker.SelectedIndex;
            // Returns success or error message
            await this.DisplayAlert("Test Mate", AppFunctions.SaveSettingsToFile(App.questionOrder, App.termDisplay, App.provideFeedback), "OK");

            await Application.Current.MainPage.Navigation.PopAsync();
        }
Example #14
0
        private void DisplayIndividualDetails(Person person)
        {
            _pnlContactDetails.Style.Add("width", "800px");
            _pnlContactDetails.Style.Add("height", "500px");
            _pnlOrganisation.Visible = false;
            _pnlIndividual.Visible   = true;

            //Get the data for the dropdown lists only if we havent fetched it earlier
            if (!(bool)ViewState["IndividualsDropdownsPopulated"])
            {
                BindIndividualsDropdownLists();
                ViewState["IndividualsDropdownsPopulated"] = true;
            }
            if (person.Title != string.Empty)
            {
                _ddlTitle.SelectedValue = person.Title;
            }

            _txtForenames.Text = person.ForeName;
            _txtSurname.Text   = person.Surname;
            _ddlMaritalStatus.SelectedValue = person.MaritalStatusId.ToString();
            _txtPreviousName.Text           = person.PreviousName;
            _txtOccupation.Text             = person.Occupation;
            _ddlSex.SelectedValue           = person.Sex.ToString();
            if (person.DOB != DataConstants.BlankDate)
            {
                _ccDOBDate.DateText = person.DOB.ToString("dd/MM/yyyy");
                //Contact blank date in the database was being stored as 01/01/1900 which is not the system blankdate
                //Therefore added a test to make sure that the date of death is later than the date of birth.
                //If it isn't, restore date of death to system blankdate as it is invalid.
                if ((person.DOD != DataConstants.BlankDate) && (person.DOD < person.DOB))
                {
                    _ccDODDate.DateText = DataConstants.BlankDate.ToString("dd/MM/yyyy");
                }
            }

            _txtAge.Text = AppFunctions.CalculateAge(person.DOB, person.DOD);
            if (person.DOD != DataConstants.BlankDate)
            {
                _ccDODDate.DateText = person.DOD.ToString("dd/MM/yyyy");
            }
            _txtPlaceOfBirth.Text        = person.PlaceOfBirth;
            _txtBirthName.Text           = person.BirthName;
            _txtFormalSalutation.Text    = person.SalutationLettterFormal;
            _txtInformalSalutation.Text  = person.SalutationLettterInformal;
            _txtFriendlySalutation.Text  = person.SalutationLettterFriendly;
            _txtEnvelopeSalutation.Text  = person.SalutationEnvelope;
            _ddlEthnicity.SelectedValue  = person.EthnicityId.ToString();
            _ddlDisability.SelectedValue = person.DisabilityId.ToString();
            _chkArmedForces.Checked      = person.IsInArmedForces;
            _txtArmedForcesNo.Text       = person.ArmedForcesNo;
            _txtNINo.Text = person.NINo;
        }
Example #15
0
        public ActionResult IndexX()
        {
            string category = "Gambia";

            ViewBag.Category = category;

            int category_id = AppFunctions.GetCategoryIDFromText(category);
            var data        = db.NewsArticles.Where(s => s.ArticleCategory == category_id && s.ReviewStatus == 1 && s.DeleteStatus == false).OrderByDescending(s => s.ID);

            ViewBag.total_records = db.NewsArticles.Count(s => s.ArticleCategory == category_id && s.DeleteStatus == false);
            return(View(data));
        }
Example #16
0
        protected async override void OnAppearing()
        {
            base.OnAppearing();
            List <string>        testfiles = new List <string>();
            IEnumerable <string> tests     = await AppFunctions.GetTestList();

            foreach (string test in tests)
            {
                testfiles.Add(test);
            }
            TestList.ItemsSource = testfiles;
        }
Example #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _lblMessage.Text = string.Empty;
            // If Session expires, redirect the user to the login screen
            if (Session[SessionName.LogonId] == null)
            {
                Response.Redirect("~/LoginMobile.aspx?SessionExpired=1", true);
            }
            else
            {
                _logonId = (Guid)Session[SessionName.LogonId];
            }

            if (!IsPostBack)
            {
                //Select the fee earner associated with the logged-in user
                if (Session[SessionName.DefaultFeeEarner] != null)
                {
                    _msAddTimeEntry.DefaultFeeEarnerId = (Guid)Session[SessionName.DefaultFeeEarner];
                }

                if (!string.IsNullOrEmpty(Request.QueryString["Success"]))
                {
                    if (Request.QueryString["Success"] == "1")
                    {
                        _lblMessage.CssClass = "successMessage";
                        _lblMessage.Text     = "Time entry saved successfully";
                    }

                    if (Session[SessionName.ProjectId] != null)
                    {
                        _msAddTimeEntry.ProjectId = (Guid)Session[SessionName.ProjectId];
                    }
                }
                else
                {
                    //if we are coming from the Additional Detail pg then display the entered values
                    if (Request.UrlReferrer != null)
                    {
                        string pageName = Request.UrlReferrer.AbsolutePath;
                        pageName = AppFunctions.GetPageNameByUrl(pageName);
                        if (pageName == "AdditionalTimeDetailsMobile.aspx")
                        {
                            // Load Last saved time entry
                            LoadLastSavedTimeEntry();
                            return;
                        }
                    }
                }
                Session[SessionName.TimeDetails] = null;
            }
        }
Example #18
0
        /// <summary>
        /// Attempt to read and set stored settings upon application load
        /// </summary>
        protected override void OnStart()
        {
            // Handle when your app starts
            // ReadSettingsFromFile() returns null if successful
            string errorMessage = AppFunctions.ReadSettingsFromFile();

            if (!String.IsNullOrEmpty(errorMessage))
            {
                // Display error
                Application.Current.MainPage.DisplayAlert("Test Mate", errorMessage, "OK");
                // Disable application only if the error is NOT a missing settings file (e.g., IOException, etc.)
                App.enableAppFlag = (errorMessage != AppResources.SettingsMissingErrorMessage) ? false : true;
            }
        }
Example #19
0
        public ActionResult Subscribe([Bind(Include = "SubscriberEmail")] SubscribersModel subscribersModel)
        {
            var ReturnUrl = Request.Form["ReturnUrl"];

            if (string.IsNullOrEmpty(ReturnUrl))
            {
                ReturnUrl = "Index";
            }

            TempData["SubsAlertDiv"] = "SubsAlertDiv";
            if (ModelState.IsValid)
            {
                subscribersModel.Status = 1;

                if (db.Subcribers.Any(s => s.SubscriberEmail == subscribersModel.SubscriberEmail && s.Status != 0))
                {
                    TempData["ErrorMessage"] = "Already subscribed.";
                    return(Redirect(ReturnUrl));
                }
                else if (db.Subcribers.Any(s => s.SubscriberEmail == subscribersModel.SubscriberEmail && s.Status == 0))
                {
                    //Update status
                    if (AppFunctions.UpdateSubcriberStatus(subscribersModel.SubscriberEmail, 1))
                    {
                        TempData["SuccessMessage"] = "Subscription successfull.";
                        return(Redirect(ReturnUrl));
                    }
                    TempData["ErrorMessage"] = "Failed to re-subscribe.";
                    return(Redirect(ReturnUrl));
                }

                db.Subcribers.Add(subscribersModel);
                db.SaveChanges();
                TempData["SuccessMessage"] = "Subscription successfull.";

                if (!string.IsNullOrEmpty(ReturnUrl))
                {
                    return(Redirect(ReturnUrl));
                }
                return(RedirectToAction("Index", "Home"));
            }

            TempData["ErrorMessage"] = "Opps!an  error occured.";
            if (!string.IsNullOrEmpty(ReturnUrl))
            {
                return(Redirect(ReturnUrl));
            }
            return(RedirectToAction("Index", "Home"));
        }
Example #20
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count > 0)
     {
         int             userID          = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["uID"].Value.ToString());
         UpdateUserAdmin updateUserAdmin = new UpdateUserAdmin(AppFunctions.getUser(
                                                                   AppFunctions.getUserTable(userID)),
                                                               this);
         updateUserAdmin.ShowDialog();
     }
     else
     {
         MessageBox.Show("A row should be selected.");
     }
 }
Example #21
0
        /// <summary>
        /// Binds fee earners
        /// </summary>
        private void BindFeeEarner()
        {
            EarnerServiceClient earnerService = null;

            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();

                EarnerSearchCriteria criteria = new EarnerSearchCriteria();
                criteria.IncludeArchived = false;
                criteria.MultiOnly       = false;

                earnerService = new EarnerServiceClient();
                EarnerSearchReturnValue returnValue = earnerService.EarnerSearch(_logonSettings.LogonId,
                                                                                 collectionRequest, criteria);

                if (returnValue.Success)
                {
                    _ddlFeeEarner.Items.Clear();
                    foreach (EarnerSearchItem feeEarner in returnValue.Earners.Rows)
                    {
                        ListItem item = new ListItem();
                        item.Text  = CommonFunctions.MakeFullName(feeEarner.Title, feeEarner.Name, feeEarner.SurName);
                        item.Value = feeEarner.Id.ToString();
                        _ddlFeeEarner.Items.Add(item);
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
                AppFunctions.AddDefaultToDropDownList(_ddlFeeEarner);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (earnerService != null)
                {
                    if (earnerService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        earnerService.Close();
                    }
                }
            }
        }
Example #22
0
 public TestPage(TestFile testFile)
 {
     InitializeComponent();
     // Create the actual test and store the questions in a list
     // Test test = new Test();
     // testQuestion = test.GetTest(Path.Combine(Constants.AppDataPath, testFile.FileName), App.questionOrder, App.termDisplay);
     testQuestion = AppFunctions.GetTest(Path.Combine(Constants.AppDataPath, testFile.FileName), App.questionOrder, App.termDisplay);
     // Initialize the results list instead of using Add. This makes changng the answers to questions easier
     foreach (TestQuestion tq in testQuestion)
     {
         resultList.Add(new Result(tq.Question, null, false));
     }
     // Display the test title and the first question
     testTitle = AppFunctions.TestTitle;
     PopulateControls();
 }
    protected override bool AuthorizeCore(HttpContextBase httpContext)
    {
        var variable_session   = httpContext.Session["sessionEmail"];
        var variable_unique_id = httpContext.Session["sessionID"];

        if (httpContext.Session["sessionID"] == null || httpContext.Session["sessionEmail"] == null || httpContext.Session["sessionFullName"] == null)
        {
            return(variable_session != null);
        }

        using (var db = new DBConnection())
        {
            string session_unique_id = variable_unique_id.ToString();
            string session_email     = variable_session.ToString();
            if (!db.Accounts.Any(s => s.Email == session_email))
            {
                variable_session = null;
            }

            if (!db.LoginInfo.Any(s => s.Email == session_email && s.LoginSessionID == session_unique_id))
            {
                variable_session = null;
            }

            //Validate for User having an Exting Role in group
            if (!db.Groups.Any(s => s.Email == session_email))
            {
                variable_session = null;
            }

            int sys_admin_role_id = AppFunctions.GetRoleID("SystemAdmin");
            int editor_role_id    = AppFunctions.GetRoleID("Editor");
            int censor_role_id    = AppFunctions.GetRoleID("Censor");
            //Validate for User having an Censor Role in group
            if (!db.Groups.Any(s => s.Email == session_email && (s.RoleID == sys_admin_role_id || s.RoleID == editor_role_id || s.RoleID == censor_role_id)))
            {
                variable_session = null;
            }
        }

        if (variable_session == null)
        {
            httpContext.Session["ErrorMessage"] = "You do not have access to that section";
        }

        return(variable_session != null);
    }
Example #24
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 users where isActive=1 and (id in (" + researchid + "))");
        }
        else
        {
            dt = db.ExecuteDataTable("select * from users where isActive=1");
        }
        List <string> to       = new List <string>();
        AppFunctions  validate = new AppFunctions();

        foreach (DataRow row in dt.Rows)
        {
            db.AddParameter("@from", "-1");
            db.AddParameter("@Title", txtSubject.Text);
            db.AddParameter("@msg", txtTxt.Text);
            db.AddParameter("@toId", row["id"].ToString());
            db.ExecuteNonQuery("insert into msg ([from],title,msg,toId) values(@from,@title,@msg,@toId)");
        }

        ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "alertify.alert('تم الارسال ','تم الارسال بنجاح').set('onok', function(closeEvent){ location.href='MsgList.aspx'; } );", true);
    }
Example #25
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 users where isActive=1 and (id in (" + researchid + "))");
        }
        else
        {
            dt = db.ExecuteDataTable("select * from users where isActive=1");
        }
        List<string> to=new List<string>();
        AppFunctions validate=new AppFunctions();
        foreach (DataRow row in dt.Rows)
        {
            db.AddParameter("@from", "-1");
            db.AddParameter("@Title", txtSubject.Text);
            db.AddParameter("@msg", txtTxt.Text);
            db.AddParameter("@toId", row["id"].ToString());
            db.ExecuteNonQuery("insert into msg ([from],title,msg,toId) values(@from,@title,@msg,@toId)");
        }

        ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "alertify.alert('تم الارسال ','تم الارسال بنجاح').set('onok', function(closeEvent){ location.href='MsgList.aspx'; } );", true);
    }
Example #26
0
        // GET: Health
        public ActionResult Index(int page = 0)
        {
            string category = "Health";

            ViewBag.Category = category;
            int category_id = AppFunctions.GetCategoryIDFromText(category);
            var dataSource  = db.NewsArticles.Where(s => s.ArticleCategory == category_id && s.ReviewStatus == 1 && s.DeleteStatus == false).OrderByDescending(s => s.ID);

            const int PageSize = 6; // you can always do something more elegant to set this

            var count = dataSource.Count();

            var data = dataSource.Skip(page * PageSize).Take(PageSize).ToList();

            ViewBag.MaxPage = (count / PageSize) - (count % PageSize == 0 ? 1 : 0);

            ViewBag.Page = page;

            return(View(data));
        }
Example #27
0
        private async void TestList_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            string testFile = e.SelectedItem as string;
            string testURL  = "https://raw.githubusercontent.com/garciart/TestMate/master/Tests/" + testFile;

            try
            {
                byte[] returnedBytes = await AppFunctions.DownloadFileAsync(testURL);

                File.WriteAllBytes(String.Format("{0}/{1}", Constants.AppDataPath, testFile), returnedBytes);
                await this.DisplayAlert("Test Mate", AppResources.DownloadSuccessMessage, "OK");

                OnAppearing();
                // await Application.Current.MainPage.Navigation.PopAsync();
            }
            catch (Exception ex)
            {
                await this.DisplayAlert("Test Mate", String.Format(AppResources.DownloadErrorMessage, ex.Message), "OK");
            }
        }
Example #28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void UpdateDatabaseButton_Clicked(object sender, EventArgs e)
        {
            bool answer = await DisplayAlert("Quick Meds", AppResources.UpdateConfirm, AppResources.ButtonYes, AppResources.ButtonNo);

            if (answer)
            {
                string databaseFile = "QuickMeds.db";
                string databaseURL  = "https://raw.githubusercontent.com/garciart/QuickMeds/master/Database/" + databaseFile;
                try {
                    byte[] returnedBytes = await AppFunctions.DownloadFileAsync(databaseURL);

                    File.WriteAllBytes(string.Format("{0}/{1}", Constants.AppDataPath, databaseFile), returnedBytes);
                    await DisplayAlert("Quick Meds", AppResources.DownloadSuccessMessage, "OK");

                    await Application.Current.MainPage.Navigation.PopAsync();
                }
                catch (Exception ex) {
                    await DisplayAlert("Quick Meds", string.Format(AppResources.DownloadErrorMessage, ex.Message), "OK");
                }
            }
        }
Example #29
0
        private async void TestList_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            // CHECK https://stackoverflow.com/questions/45711428/download-file-with-webclient-or-httpclient
            string testFile = e.SelectedItem as string;

            Console.WriteLine(">>> SELECTED FILE: " + testFile);
            // string testFileURL = "http://testmate.rgprogramming.com/" + testFile;

            try
            {
                AppFunctions.devDownloadFileAsync(testFile);
                await this.DisplayAlert("Test Mate", AppResources.DownloadSuccessMessage, "OK");

                OnAppearing();
                // await Application.Current.MainPage.Navigation.PopAsync();
            }
            catch (Exception ex)
            {
                await this.DisplayAlert("Test Mate", String.Format(AppResources.DownloadErrorMessage, ex.Message), "OK");
            }
        }
Example #30
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        AppFunctions v = new AppFunctions();

        if (string.IsNullOrEmpty(txtTitle.Text))
        {
            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال عنوان الصفحة.\")</SCRIPT>", false);
            return;
        }
        if (string.IsNullOrEmpty(txtPrv.Text))
        {
            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال ملخص.\")</SCRIPT>", false);
            return;
        }
        if (string.IsNullOrEmpty(txtText.Text))
        {
            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال التفاصيل.\")</SCRIPT>", false);
            return;
        }
        System.Data.DataTable dt = new System.Data.DataTable();
        db.AddParameter("@title", txtTitle.Text);
        db.AddParameter("@Text", txtText.Text);
        db.AddParameter("@Prv", txtPrv.Text);
        db.AddParameter("@lang", ddlLang.SelectedValue);

        if (Request.QueryString["Op"].ToLower().Equals("edit"))
        {
            try
            {
                db.AddParameter("@id", Request.QueryString["id"]);
                dt = db.ExecuteDataTable("Update Pages Set title=@title,txt=@Text,prev=@Prv,lang=@lang where Id=@id");
                Response.Redirect("PagesList.aspx");
            }

            catch
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"Please try again.\")</SCRIPT>", false);
            }
        }
    }
Example #31
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        AppFunctions v = new AppFunctions();

        if (string.IsNullOrEmpty(txtTitle.Text))
        {
            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال عنوان الصفحة.\")</SCRIPT>", false);
            return;
        }
        if (string.IsNullOrEmpty(txtPrv.Text))
        {
            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال ملخص.\")</SCRIPT>", false);
            return;
        }
        if (string.IsNullOrEmpty(txtText.Text))
        {
            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال التفاصيل.\")</SCRIPT>", false);
            return;
        }
        System.Data.DataTable dt = new System.Data.DataTable();
        db.AddParameter("@title", txtTitle.Text);
        db.AddParameter("@Text", txtText.Text);
        db.AddParameter("@Prv", txtPrv.Text);
        db.AddParameter("@lang", ddlLang.SelectedValue);

        if (Request.QueryString["Op"].ToLower().Equals("edit"))
        {
            try
            {
                db.AddParameter("@id", Request.QueryString["id"]);
                dt = db.ExecuteDataTable("Update Pages Set title=@title,txt=@Text,prev=@Prv,lang=@lang where Id=@id");
                Response.Redirect("PagesList.aspx");
            }

            catch
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"Please try again.\")</SCRIPT>", false);
            }
        }
    }
Example #32
0
        public ActionResult Search(NewsArticlesModel subscribersModel)
        {
            var ReturnUrl = Request.Form["ReturnUrl"];
            var search    = Request.Form["search"];

            if (search == null)
            {
                if (!string.IsNullOrEmpty(ReturnUrl))
                {
                    return(Redirect(ReturnUrl));
                }
                return(RedirectToAction("Index", "Home"));
            }

            search = AppFunctions.CleanString(search);
            Regex rgx = new Regex("[^a-zA-Z0-9 -]");

            search = rgx.Replace(search, "");

            Response.Redirect("~/Home/Search/?q=" + search);
            return(RedirectToAction("Search/?q=" + search, "Home"));
        }
Example #33
0
        //Search
        public ActionResult Search()
        {
            var ReturnUrl = Request.Form["ReturnUrl"];
            var query     = Request.QueryString["q"];

            if (query == null)
            {
                if (!string.IsNullOrEmpty(ReturnUrl))
                {
                    return(Redirect(ReturnUrl));
                }
                return(RedirectToAction("Index", "Home"));
            }
            query = AppFunctions.CleanString(query);

            ViewBag.Search = query;

            ViewBag.CountTotal = db.NewsArticles.Count(s => (s.ArticleTextIdentifier.Contains(query) || s.ArticleHeadline.Contains(query) || s.ArticleBody.Contains(query) || s.Tags.Contains(query)) && (s.DeleteStatus == false && s.ReviewStatus == 1));
            var data = db.NewsArticles.Where(s => (s.ArticleTextIdentifier.Contains(query) || s.ArticleHeadline.Contains(query) || s.ArticleBody.Contains(query) || s.Tags.Contains(query)) && (s.DeleteStatus == false && s.ReviewStatus == 1)).OrderByDescending(s => s.ArticleDate);

            return(View(data));
        }
Example #34
0
        //Tags
        public ActionResult Tags()
        {
            var ReturnUrl = Request.Form["ReturnUrl"];
            var tag       = Request.QueryString["tag"];

            if (tag == null)
            {
                if (!string.IsNullOrEmpty(ReturnUrl))
                {
                    return(Redirect(ReturnUrl));
                }
                return(RedirectToAction("Index", "Home"));
            }
            tag = AppFunctions.CleanString(tag);

            ViewBag.Tag = tag;

            ViewBag.CountTotal = db.NewsArticles.Count(s => (s.Tags.Contains(tag)) && (s.DeleteStatus == false && s.ReviewStatus == 1));
            var data = db.NewsArticles.Where(s => (s.Tags.Contains(tag)) && (s.DeleteStatus == false && s.ReviewStatus == 1)).OrderByDescending(s => s.ArticleDate);

            return(View(data));
        }
Example #35
0
    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);
        }
    }
Example #36
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);
        }
    }
Example #37
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;
    }
Example #38
0
    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);
            }
        }
    }