Exemplo n.º 1
0
        private void btnSign_Click(object sender, RoutedEventArgs e)
        {
            User u = new User();
            var result=model.Users.Where(i=>i.UserName==txtUserName.Text).Where(p=>p.Password==txtPassword.Password);

            if (result.Count() == 0)
            {
                MessageBox.Show("Invalid Username or password", "Error in logging");

            }

            else
            {
                result.First().LastLoginDate = DateTime.Now;
                model.SaveChanges();
                new MainWindow().Show();
                this.Close();

            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            //Validate username
            IEnumerable<User> users = model.Users.Where(u => u.UserName == txtUserName.Text);
            if (users.Count() == 0)
            {
                //Validate requiered fields
                if(valid.ValidateTextField(txtNIC.Text) && valid.ValidateTextField(txtEPFNo.Text) && valid.ValidateTextField(txtUserName.Text) && valid.ValidateTextField(txtPassword.Password) )
                {
                    //Validate Email
                    if ((valid.ValidateTextField(txtEmail.Text)) ? valid.ValidateEmail(txtEmail.Text) : true)
                    {
                        //Validate NIC
                        if (valid.ValidateNIC(txtNIC.Text))
                        {
                            //Validate password
                            if (txtPassword.Password.Equals(txtRePassword.Password, StringComparison.Ordinal))
                            {
                                //Add new user
                                User user = new User();
                                user.EpfNo = txtEPFNo.Text;
                                user.FirstName = txtFirstName.Text;
                                user.LastName = txtLastName.Text;
                                user.NIC = txtNIC.Text;
                                user.Gender = txtGender.Text;
                                user.Designation = txtDesignation.Text;
                                user.Address = txtAddress.Text;
                                user.MobileNo = txtMobileNo.Text;
                                user.LandPhone = txtLandPhone.Text;
                                user.Email = txtEmail.Text;
                                user.DateOfBirth = dtPickerDateOfBirth.SelectedDate.Value;
                                user.UserName = txtUserName.Text;
                                user.Password = txtPassword.Password;
                                user.AddedDate = DateTime.Now;

                                model.AddToUsers(user);
                                model.SaveChanges();

                                ClearTextBox();

                                LoadGrid();
                            }
                            else
                            {
                                MessageBox.Show("Passowrds not match");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Invalid NIC");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Invalid Email");
                    }
                }
                else
                {
                     MessageBox.Show(" * Fields Required");
                }
            }
            else
            {
                MessageBox.Show("Username exist");
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUsers(User user)
 {
     base.AddObject("Users", user);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Create a new User object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="epfNo">Initial value of the EpfNo property.</param>
 /// <param name="nIC">Initial value of the NIC property.</param>
 /// <param name="firstName">Initial value of the FirstName property.</param>
 /// <param name="lastName">Initial value of the LastName property.</param>
 /// <param name="gender">Initial value of the Gender property.</param>
 /// <param name="designation">Initial value of the Designation property.</param>
 /// <param name="address">Initial value of the Address property.</param>
 /// <param name="mobileNo">Initial value of the MobileNo property.</param>
 /// <param name="landPhone">Initial value of the LandPhone property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 /// <param name="userName">Initial value of the UserName property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 public static User CreateUser(global::System.Int32 id, global::System.String epfNo, global::System.String nIC, global::System.String firstName, global::System.String lastName, global::System.String gender, global::System.String designation, global::System.String address, global::System.String mobileNo, global::System.String landPhone, global::System.String email, global::System.String userName, global::System.String password)
 {
     User user = new User();
     user.Id = id;
     user.EpfNo = epfNo;
     user.NIC = nIC;
     user.FirstName = firstName;
     user.LastName = lastName;
     user.Gender = gender;
     user.Designation = designation;
     user.Address = address;
     user.MobileNo = mobileNo;
     user.LandPhone = landPhone;
     user.Email = email;
     user.UserName = userName;
     user.Password = password;
     return user;
 }