コード例 #1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            Test temp = (Test)obj;

            return(Name.Equals(temp.Name) && Pass.Equals(temp.Pass));
        }
コード例 #2
0
        public async void Register()
        {
            var realmDB   = Realm.GetInstance();
            var elUsuario = realmDB.All <UserModel>().ToList();
            var elIdDelUltimoUsuarioInsertado = 0;

            if (elUsuario.Count != 0)
            {
                elIdDelUltimoUsuarioInsertado = elUsuario.Max(s => s.Id);
            }
            if (User.Equals("") || FullName.Equals("") || Pass.Equals("") || Age == 0)
            {
                message.Title   = "Error";
                message.Message = "Complete correctamente los campos";
                message.Cancel  = "Aceptar";
                message.MostrarMensaje(message);
            }
            else
            {
                UserModel elNuevoUsuario = new UserModel()
                {
                    Id       = elIdDelUltimoUsuarioInsertado + 1,
                    Name     = User,
                    Pass     = Pass,
                    FullName = FullName,
                    Age      = Age
                };
                UserModel elUsuarioAlmacenado = realmDB.All <UserModel>().FirstOrDefault(b => b.Name == User);
                if (elUsuarioAlmacenado == null)
                {
                    realmDB.Write(() =>
                    {
                        realmDB.Add(elNuevoUsuario);
                    });

                    User     = string.Empty;
                    Pass     = string.Empty;
                    FullName = string.Empty;
                    Age      = 0;

                    await App.Current.MainPage.Navigation.PushModalAsync(new LoginView());
                }
                else
                {
                    message.Title   = "Error";
                    message.Message = "El usuario con el nombre " + User + ", ya existe.";
                    message.Cancel  = "Aceptar";
                    message.MostrarMensaje(message);
                }
            }
        }
コード例 #3
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            Form2  f2 = new Form2();
            String User, Pass;

            //Citire USER+PASSWORD
            User = Convert.ToString(textBox1.Text);
            Pass = Convert.ToString(textBox2.Text);

            //Deschidere conexiune DB
            SqlConnection con = new SqlConnection(init);

            con.Open();

            //Selectare User+Parola din DB
            string        q    = "select Pwd from LogIn where Us ='" + User + "'";
            SqlCommand    cmd  = new SqlCommand(q, con);
            SqlDataReader read = cmd.ExecuteReader();

            //Verificare credentiale
            if (read.Read())
            {
                if (Pass.Equals(read["Pwd"].ToString()))
                {
                    this.Hide();
                    f2.ShowDialog();
                    textBox1.Text = null;
                    textBox2.Text = null;
                    this.Show();
                }
                else
                {
                    MessageBox.Show("Wrong password");
                    textBox2.Text = null;
                }
            }

            else
            {
                MessageBox.Show("Wrong username");
                textBox1.Text = null;
                textBox2.Text = null;
            }
            con.Close();
        }
コード例 #4
0
        private void button2_MouseDown(object sender, MouseEventArgs e)
        {
            Form3 f3 = new Form3();
            Form2 f2 = new Form2();

            if (MouseButtons == MouseButtons.Right)
            {
                String User, Pass;

                //Citire USER+PASSWORD
                User = Convert.ToString(textBox1.Text);
                Pass = Convert.ToString(textBox2.Text);

                //Deschidere conexiune DB
                SqlConnection con = new SqlConnection(init);
                con.Open();

                //Selectare User+Parola din DB
                string        q    = "select Pwd, Super from LogIn where Us ='" + User + "'";
                SqlCommand    cmd  = new SqlCommand(q, con);
                SqlDataReader read = cmd.ExecuteReader();

                //Verificare credentiale
                if (read.Read())
                {
                    if (Pass.Equals(read["Pwd"].ToString()))
                    {
                        if ("1".Equals(read["Super"].ToString()))
                        {
                            this.Hide();
                            f3.ShowDialog();
                            textBox1.Text = null;
                            textBox2.Text = null;
                            this.Show();
                        }
                    }
                }
                con.Close();
            }
        }
コード例 #5
0
ファイル: Form6.cs プロジェクト: akar995/cashier-Csharp
        private void button1_Click(object sender, EventArgs e)
        {
            String Fname, Uname, Pass, Rpass, Email;
            String Per = "";

            Fname = textBox1.Text;
            Uname = textBox2.Text;
            Email = textBox3.Text;
            Pass  = textBox4.Text;
            Rpass = textBox5.Text;
            if (Pass.Equals(Rpass) && (!Pass.Equals("") || !Pass.Equals("")))
            {
                if (checkBox1.Checked == true)
                {
                    Per = checkBox1.Text;
                }
                if (checkBox2.Checked == true)
                {
                    Per = checkBox2.Text;
                }
                if (checkBox3.Checked == true)
                {
                    Per = checkBox3.Text;
                }
                else
                {
                    label7.Visible = true;
                    label7.Text    = "Please Select User Permition";
                }
                if (!Per.ToString().Equals(""))
                {
                    try
                    {
                        SqlConnection conn = new SqlConnection(sqlcon);
                        conn.Open();
                        SqlCommand cmd = new SqlCommand("INSERT INTO User_Table (Full_Name,UserName,Email,Password,Permission) VALUES ('" + Fname + "','" + Uname + "','" + Email + "','" + Pass + "','" + Per + "');", conn);
                        cmd.ExecuteNonQuery();
                        Console.WriteLine("Inserting Data Successfully");
                        conn.Close();
                        label7.Visible = true;
                        label7.Text    = "User Added Successfully";
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Exception Occre while creating table:");;
                    }
                }
            }
            else
            {
                if (Pass.Equals("") && Pass.Equals(""))
                {
                    label7.Visible = true;
                    label7.Text    = "Password Please";
                }
                else
                {
                    label7.Visible = true;
                    label7.Text    = "Password Do not Match";
                }
            }
        }
コード例 #6
0
        public RegistrationViewModel()
        {
            this.ImageSource = "pic.png";
            dataService      = new DataService();
            IsEnabled        = true;
            IsRunning        = false;

            ClicLoginPageCommand = new Command(async() =>
            {
                await Application.Current.MainPage.Navigation.PopAsync();
            });

            ClicAddImageCommand = new Command(async() =>
            {
                file = await CrossMedia.Current.PickPhotoAsync(
                    new PickMediaOptions
                {
                    PhotoSize = PhotoSize.Small,
                });
                if (file != null)
                {
                    ImageSource = ImageSource.FromStream(() =>
                    {
                        var stream = file.GetStream();
                        return(stream);
                    });
                }
            });

            ClicSafeUserCommand = new Command(async() =>
            {
                IsRunning        = true;
                IsEnabled        = false;
                byte[] ArrayFoto = null;
                if (file != null)
                {
                    ArrayFoto = ReadFully(this.file.GetStream());
                }

                if (string.IsNullOrEmpty(Name))
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "Debe tener Nombre", "OK");
                    IsEnabled = true;
                    IsRunning = false;
                    return;
                }

                if (string.IsNullOrEmpty(Email))
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "Usuario debe tener Email", "OK");
                    IsEnabled = true;
                    IsRunning = false;
                    return;
                }

                if (!EmailHelper.IsValidEmail(Email))
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "Formato de Email No Valido", "OK");
                    IsEnabled = true;
                    IsRunning = false;
                    return;
                }

                if (string.IsNullOrEmpty(Pass))
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "Usuario Debe tener password", "OK");
                    IsEnabled = true;
                    IsRunning = false;
                    return;
                }

                if (string.IsNullOrEmpty(ConfPass))
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "Usuario Debe confirmar password", "OK");
                    IsEnabled = true;
                    IsRunning = false;
                    return;
                }

                if (!Pass.Equals(ConfPass))
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "El password debe ser igual", "OK");
                    IsEnabled = true;
                    IsRunning = false;
                    return;
                }

                if (Pass.Length < 6)
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "Password debe tener mas de 6 caracteres", "OK");
                    IsEnabled = true;
                    IsRunning = false;
                    return;
                }

                if (string.IsNullOrEmpty(Phone))
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "Debe tener No. Telefono", "OK");
                    IsEnabled = true;
                    IsRunning = false;
                    return;
                }

                await dataService.Insert(new Users
                {
                    Name     = Name,
                    Password = Pass,
                    Email    = Email,
                    //Date = Date.Date,
                    _Image     = ArrayFoto,
                    Remembered = false,
                    Telephone  = Phone
                });
                //IsRunning = false;
                // IsEnabled = true;

                await dataService.GetAllUsers();
            });

            //ClicCancelUserCommand = new Command(async () =>
            //{

            //});
        }
コード例 #7
0
ファイル: Frm_Login.cs プロジェクト: dpolanco1/SGF
        private void btnAceptar_Click_1(object sender, EventArgs e)
        {
            var list = bllCompania.Search(enlCompania);


            //if (string.IsNullOrEmpty(cmbCompania.Text) || string.IsNullOrEmpty(txtContrasena.Text) || string.IsNullOrEmpty(txtUsuario.Text))
            //{
            //    MessageBox.Show("Todos los Campos Son Obligatorios ", "SGF", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}
            //else
            //{

            string User, Pass;

            User = txtUsuario.Text;
            Pass = txtContrasena.Text;
            if (User.Equals("admin") == true && Pass.Equals("123") == true)
            {
                if (list.Count != 0)
                {
                    Enl_DatosDeSession.NombreCompania = list[0].NombreCompania;
                    Enl_DatosDeSession.Telefono       = list[0].Telefono;
                    Enl_DatosDeSession.Fax            = list[0].Fax;
                    Enl_DatosDeSession.Email          = list[0].Email;
                    Enl_DatosDeSession.PaginaWeb      = list[0].PaginaWeb;
                    Enl_DatosDeSession.Direccion      = list[0].Direccion;
                    Enl_DatosDeSession.RNC            = list[0].RNC;
                    Enl_DatosDeSession.Ciudad         = list[0].Ciudad;
                    Enl_DatosDeSession.Pais           = list[0].Pais;


                    Enl_DatosDeSession.NombreUsuario = "Admin";
                }
                Close();
            }
            else
            {
                if (User.Equals("Ventas") == true && Pass.Equals("1234567") == true)
                {
                    Enl_DatosDeSession.NombreCompania = list[0].NombreCompania;
                    Enl_DatosDeSession.Telefono       = list[0].Telefono;
                    Enl_DatosDeSession.Fax            = list[0].Fax;
                    Enl_DatosDeSession.Email          = list[0].Email;
                    Enl_DatosDeSession.PaginaWeb      = list[0].PaginaWeb;
                    Enl_DatosDeSession.Direccion      = list[0].Direccion;
                    Enl_DatosDeSession.RNC            = list[0].RNC;
                    Enl_DatosDeSession.Ciudad         = list[0].Ciudad;
                    Enl_DatosDeSession.Pais           = list[0].Pais;

                    Enl_DatosDeSession.NombreUsuario = "Ventas";

                    Close();
                }
                else
                {
                    enlUsuarios.NombreUsuario = txtUsuario.Text;
                    enlUsuarios.Nombre        = string.Empty;
                    enlUsuarios.Apellido      = string.Empty;

                    if (bllUsuarios.IsExiste(enlUsuarios) == "True")
                    {
                        var list2 = bllUsuarios.Search(enlUsuarios);

                        if (User.Equals(list2[0].NombreUsuario) == true && Pass.Equals(list2[0].Contrasena) == true)
                        {
                            Enl_DatosDeSession.NombreCompania = list[0].NombreCompania;
                            Enl_DatosDeSession.Telefono       = list[0].Telefono;
                            Enl_DatosDeSession.Fax            = list[0].Fax;
                            Enl_DatosDeSession.Email          = list[0].Email;
                            Enl_DatosDeSession.PaginaWeb      = list[0].PaginaWeb;
                            Enl_DatosDeSession.Direccion      = list[0].Direccion;
                            Enl_DatosDeSession.RNC            = list[0].RNC;
                            Enl_DatosDeSession.Ciudad         = list[0].Ciudad;
                            Enl_DatosDeSession.Pais           = list[0].Pais;

                            Enl_DatosDeSession.NombreUsuario = txtUsuario.Text;

                            Close();
                        }
                        else
                        {
                            MessageBox.Show("Usuario o Contrasena Incorrecto ", "SGF", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Usuario o Contrasena Incorrecto ", "SGF", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
コード例 #8
0
        public void Login()
        {
            var realmDB        = Realm.GetInstance();
            var elNuevoUsuario = realmDB.All <UserModel>().FirstOrDefault(b => b.Name == User);

            Settings.UserActive = User;
            if (User != null && elNuevoUsuario != null)
            {
                if (User == elNuevoUsuario.Name && Pass == elNuevoUsuario.Pass)
                {
                    NavigationPage navigation = new NavigationPage(new HomeView());

                    App.Current.MainPage = new MasterDetailPage
                    {
                        Master = new MenuView(),
                        Detail = navigation
                    };

                    if (cboRecuerdame)
                    {
                        if (elNuevoUsuario != null)
                        {
                            Settings.UserName   = elNuevoUsuario.Name.ToString();
                            Settings.RememberMe = cboRecuerdame.ToString();
                        }
                    }
                    else
                    {
                        Settings.UserName   = string.Empty;
                        Settings.RememberMe = "false";
                    }

                    //Agregamos el inicio de sesión.
                    var realmDBLogins = Realm.GetInstance();
                    var logins        = realmDBLogins.All <LoginsModel>().ToList();
                    int idLogin       = 0;
                    if (logins.Count != 0)
                    {
                        idLogin = logins.Max(s => s.Id) + 1;
                    }
                    LoginsModel login = new LoginsModel();
                    login.Id              = idLogin;
                    login.IdUser          = elNuevoUsuario.Id;
                    login.User            = elNuevoUsuario.Name;
                    login.TelefonoIngreso = DeviceInfo.Name;
                    login.FechaIngreso    = DateTime.Now;

                    realmDBLogins.Write(() =>
                    {
                        realmDBLogins.Add(login);
                    });
                }
                else
                {
                    message.Title   = "Error";
                    message.Message = "Credenciales incorrectas";
                    message.Cancel  = "Aceptar";
                    message.MostrarMensaje(message);
                }
            }
            else
            {
                message.Title   = "Error";
                message.Cancel  = "Aceptar";
                message.Message = "Nombre de usuario inválido";
                if (Pass == null || Pass.Equals(""))
                {
                    message.Message = "Clave inválida";
                }
                message.MostrarMensaje(message);
            }
        }