Esempio n. 1
0
        private void DetectInputLogin()
        {
            string Name    = Account.Text.Trim();
            string Passwd  = Password.Password;
            string PasswdV = PasswordV.Password;
            string Email   = EmailInput.Text.Trim();

            if (string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(Passwd) || string.IsNullOrEmpty(PasswdV) || string.IsNullOrEmpty(Email))
            {
                if (string.IsNullOrEmpty(Name))
                {
                    Account.Focus(FocusState.Keyboard);
                }
                else if (string.IsNullOrEmpty(Passwd))
                {
                    Password.Focus(FocusState.Keyboard);
                }
                else if (string.IsNullOrEmpty(PasswdV))
                {
                    PasswordV.Focus(FocusState.Keyboard);
                }
                else if (string.IsNullOrEmpty(Email))
                {
                    EmailInput.Focus(FocusState.Keyboard);
                }
            }
            else if (Passwd != PasswdV)
            {
                StringResources stx = StringResources.Load("Error");
                ServerMessage.Text = stx.Str("PasswordMismatch");
                Password.Focus(FocusState.Keyboard);
            }
            else
            {
                ServerMessage.Text = "";

                IsPrimaryButtonEnabled
                              = IsSecondaryButtonEnabled
                              = Account.IsEnabled
                              = Password.IsEnabled
                              = PasswordV.IsEnabled
                              = EmailInput.IsEnabled
                              = false
                    ;

                this.Focus(FocusState.Pointer);

                IndicateLoad();

                RuntimeCache RCache = new RuntimeCache()
                {
                    EN_UI_Thead = true
                };
                RCache.POST(
                    Shared.ShRequest.Server
                    , Shared.ShRequest.Register(Name, Passwd, Email)
                    , RequestComplete, RequestFailed, false);
            }
        }
 private void Submit_Click(object sender, RoutedEventArgs e) //submit button function.
 {
     //listing contraints for email and password using if and Regex.
     if (EmailInput.Text.Length == 0)
     {
         errormessage.Text = "Enter an email.";                                                                                              //show error message.
         EmailInput.Focus();                                                                                                                 //will focus the email after the popup of error message.
     }
     else if (!Regex.IsMatch(EmailInput.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")) //regex constraints for email validation.
     {
         errormessage.Text = "Enter a valid email.";
         EmailInput.Select(0, EmailInput.Text.Length);
         EmailInput.Focus();
     }
     else
     {
         //assigning varibales for xaml input tags
         string firstname = FirstNameInput.Text;
         string lastname  = LastNameInput.Text;
         string email     = EmailInput.Text;
         string password  = passwordInput.Password;
         //constraints for password using if
         if (passwordInput.Password.Length == 0)
         {
             errormessage.Text = "Enter password.";
             passwordInput.Focus();
         }
         else if (passwordConfirmInput.Password.Length == 0)
         {
             errormessage.Text = "Enter Confirm password.";
             passwordConfirmInput.Focus();
         }
         else if (passwordInput.Password != passwordConfirmInput.Password)
         {
             errormessage.Text = "Confirm password must be same as password.";
             passwordConfirmInput.Focus();
         }
         else
         {
             errormessage.Text = "";
             string address = AddressInput.Text;
             //sql connection --- SSMS --> Server type = Database engine ; Auth --> Windows Auth ;
             SqlConnection con = new SqlConnection(@"Data Source=PRAVEENRAMESH;Initial Catalog=Login_DB;Integrated Security=True;");
             con.Open(); //create connection
             //insert values
             SqlCommand cmd = new SqlCommand("Insert into [Users] (FirstName,LastName,Email,Password,Address) values('" + firstname + "','" + lastname + "','" + email + "','" + password + "','" + address + "')", con);
             cmd.CommandType = CommandType.Text;
             cmd.ExecuteNonQuery(); //executenonquery to insert values
             con.Close();           //close connection after data inseration
             errormessage.Text = "You have Registered successfully.";
             Reset();               //reset the registration form
         }
     }
 }
Esempio n. 3
0
 private void ToggleEmailGrouping(bool state)
 {
     if (state == true)
     {
         gridEmailGroup.Visibility = Visibility.Visible;
         this.PreviewKeyDown      -= KeyTakePhotoAction;
         EmailInput.Focus();
         Keyboard.Focus(EmailInput);
     }
     else
     {
         SaveEmail.Focus();
         gridEmailGroup.Visibility = Visibility.Collapsed;
         EmailInput.Text           = emailInputDefaultText;
         this.PreviewKeyDown      += KeyTakePhotoAction;
     }
 }
        Welcome welcome         = new Welcome();                   //object for welcome class

        private void Login_Click(object sender, RoutedEventArgs e) //login button function
        {
            //constraints for login using if and regex
            if (EmailInput.Text.Length == 0)
            {
                errormessage.Text = "Enter an email.";
                EmailInput.Focus();
            }
            else if (!Regex.IsMatch(EmailInput.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"))
            {
                errormessage.Text = "Enter a valid email.";
                EmailInput.Select(0, EmailInput.Text.Length);
                EmailInput.Focus();
            }
            else
            {
                string email    = EmailInput.Text;
                string password = passwordInput.Password;
                //sql connection --> to know env see MainWindow.xaml.cs sql comment line 94.
                SqlConnection con = new SqlConnection("Data Source=PRAVEENRAMESH;Initial Catalog=Login_DB;Integrated Security=True;");
                con.Open(); //create connection
                //select login values from db.
                SqlCommand cmd = new SqlCommand("Select * from dbo.Users where Email='" + email + "'  and password='******'", con);
                cmd.CommandType = CommandType.Text;
                SqlDataAdapter adapter = new SqlDataAdapter();
                adapter.SelectCommand = cmd;
                DataSet dataSet = new DataSet();
                adapter.Fill(dataSet);
                //check in db for data.
                if (dataSet.Tables[0].Rows.Count > 0)
                {
                    string username = dataSet.Tables[0].Rows[0]["FirstName"].ToString() + " " + dataSet.Tables[0].Rows[0]["LastName"].ToString();
                    welcome.TextBlockName.Text = username; //Sending value from one form to another form.
                    welcome.Show();                        //shows welcome window
                    Close();                               //close login window
                }
                else
                {
                    errormessage.Text = "Sorry! Please enter existing emailid/password.";
                }
                con.Close(); //close the connection.
            }
        }
        private void EditEmployeeOKButton_Click(jQueryEvent evt)
        {
            string firstName = FirstNameInput.Value.Trim(),
                   lastName  = LastNameInput.Value.Trim(),
                   title     = TitleInput.Value.Trim(),
                   email     = EmailInput.Value.Trim();

            if (firstName == "")
            {
                Window.Alert("You must enter a first name.");
                FirstNameInput.Focus();
                return;
            }
            if (lastName == "")
            {
                Window.Alert("You must enter a last name.");
                LastNameInput.Focus();
                return;
            }
            if (title == "")
            {
                title = null;
            }
            if (email == "")
            {
                Window.Alert("You must enter an email address.");
                EmailInput.Focus();
                return;
            }

            bool     add = (EmployeesGrid.GetData(EmployeesGrid.SelectedRowIndex) == null);
            Employee emp = new Employee(firstName, lastName, title, email);

            EmployeesGrid.UpdateItem(EmployeesGrid.SelectedRowIndex, GetGridTexts(emp), emp);
            if (add)
            {
                EmployeesGrid.AddItem(GetGridTexts(null), null);
            }

            Tree.SetTreeNodeData(DepartmentsTree.SelectedNode, GetCurrentEmployees());

            EditEmployeeDialog.Close();
        }