Пример #1
0
 private void BtEliminar_Click(object sender, EventArgs e)
 {
     try
     {
         DataBaseControl DBControl = new DataBaseControl(DataBaseControl.cPath, "ProjectDataBase.mdf");
         string[]        para      = { "@user" };
         string[]        ele       = { TxtUserName.Text };
         if (DBControl.Buscar("Select * from [Registro] where [materia]= @user", para, ele))
         {
             MessageBox.Show("Esta materia actualmente figura en una seccion, imposible eliminar");
             TxtUserName.Clear();
             return;
         }
         else
         {
             if (DBControl.Eliminar("Delete from [Materias] where [Clave] = @user", para, ele))
             {
                 MessageBox.Show("Materia eliminado con exito");
                 LVUsuarios.Clear();
             }
             else
             {
                 MessageBox.Show("Error al eliminar Materia");
             }
         }
     }
     catch (Exception) { MessageBox.Show("Por favor, verificar los datos"); }
 }
        private void InisiarSesion()
        {
            DataBaseControl DBControl = new DataBaseControl(DataBaseControl.cPath, "ProjectDataBase.mdf");

            string[] parameters = { "@id", "@pass" };
            string[] elements   = { TxtUserName.Text, TxtPassword.Text };
            TxtUserName.Clear();
            TxtPassword.Clear();
            List <string> admins = new List <string> {
                "Admin", "Develop"
            };

            if (DBControl.Buscar("select * from Users where [UserName]=@id and [KeyWord]=@pass", parameters, elements))
            {
                string       cat      = DBControl.BuscarElemento("select [Category] from Users where [UserName]=@id and [KeyWord]=@pass", parameters, elements);
                MainPageForm mainPage = new MainPageForm(cat);
                this.Hide();
                mainPage.ShowDialog();
                this.Show();
                TxtUserName.Focus();
            }
            else
            {
                MessageBox.Show("Usuario o contraseña inválidos");
                TxtUserName.Focus();
            }
        }
Пример #3
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            int         PassResult  = 0;
            int         TotalUsers  = 0;
            clsEmployee clsEmployee = new clsEmployee();

            TotalUsers = clsEmployee.GetAllUserTotal(1);
            PassResult = clsEmployee.GetLoginUserID(TxtUserName.Text.TrimEnd(), TxtPassword.Text.TrimEnd());
            if ((PassResult != 0) && (TotalUsers != 0))
            {
                FrmMain frmMain = new FrmMain();
                frmMain.RefToLoginForm = this;
                frmMain.UserID         = PassResult;
                frmMain.Show();
                this.Hide();
            }
            else
            {
                DialogResult dialog = MessageBox.Show("Unknown User and do you wish to add new user?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (dialog == DialogResult.Yes)
                {
                    FrmEmployee frmEmployee = new FrmEmployee();
                    frmEmployee.ShowDialog();
                    Application.Exit();
                }
                else
                {
                    TxtUserName.Clear();
                    TxtPassword.Clear();
                    TxtUserName.Select();
                }
            }
        }
Пример #4
0
        private void IniciarSesion()
        {
            ControlDB DBControl = new ControlDB(ControlDB.cPath, "dbQA.mdf");

            string[] parameters = { "@id", "@pass" };
            string[] elements   = { TxtUserName.Text, TxtPsw.Text };
            TxtUserName.Clear();
            TxtPsw.Clear();
            List <string> admins = new List <string> {
                "Adm", "Dev"
            };

            if (DBControl.Buscar("select * from [User] where [Username]=@id and [Password]=@pass", parameters, elements))
            {
                string   cat      = DBControl.BuscarElemento("select [Tipo] from [User] where [UserName]=@id and [Password]=@pass", parameters, elements);
                MainPage mainPage = new MainPage(cat);
                this.Hide();
                mainPage.ShowDialog();
                this.Show();
                TxtUserName.Focus();
            }
            else
            {
                MessageBox.Show("Usuario o contraseña inválidos");
                TxtUserName.Focus();
                TxtPsw.Text = "";
            }
        }
Пример #5
0
        private void BtnLogin_Click(object sender, RoutedEventArgs e)
        {
            SqlConnection MysqlConnect = new SqlConnection(MydbConnect);

            // open connect to DB
            try
            {
                MysqlConnect.Open();
                string MyLoginQuery = "select * from Library_Login where UserName= '******' and UserPassWord= '******' ";

                // create the commande for the query with 2 arguments(the query var , sqlconnection var)
                SqlCommand MyCommande = new SqlCommand(MyLoginQuery, MysqlConnect);

                //execute the query
                MyCommande.ExecuteNonQuery();
                SqlDataReader MyReader = MyCommande.ExecuteReader();

                int count = 0;

                while (MyReader.Read())
                {
                    count++;
                }
                // if the the reader of the query which is username and pass word is correct once then:
                if (count == 1)
                {
                    //MessageBox.Show("Correct User name & password");
                    MainWindow window = new MainWindow();
                    window.Show();
                    this.Hide();
                }

                /* if (count>1)
                 * {
                 *   MessageBox.Show("Duplicate Username and Password, try again");
                 * }*/

                if (count < 1)
                {
                    MessageBox.Show("Incorrect Username and Password!! try again");
                    TxtPassWord.Clear();
                    TxtUserName.Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            if (UserType.Text == "")
            {
                MessageBox.Show("Please Select User Type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                UserType.Focus();
                return;
            }
            if (TxtUserName.Text == "")
            {
                MessageBox.Show("Please Enter User Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TxtUserName.Focus();
                return;
            }
            if (TxtPassword.Text == "")
            {
                MessageBox.Show("Please Enter Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TxtUserName.Focus();
                return;
            }
            cmd = new OleDbCommand("SELECT * FROM Login WHERE UserName LIKE @UserName And Password LIKE @Password And UserType LIKE @UserType", con);
            cmd.Parameters.AddWithValue("@UserName", TxtUserName.Text);
            cmd.Parameters.AddWithValue("@Password", TxtPassword.Text);
            cmd.Parameters.AddWithValue("@UserType", UserType.Text);
            OleDbDataReader dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                FrmMDIMain f = new FrmMDIMain();
                f.UserName.Text    = this.TxtUserName.Text.ToUpper();
                f.Designation.Text = this.UserType.Text.ToUpper();
                if (UserType.Text == "Administrator")
                {
                    f.BtnNewUserCreation.Visible = true;
                }
                this.Hide();
                f.Visible = true;
            }
            else
            {
                MessageBox.Show("Login Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TxtUserName.Clear();
                TxtPassword.Clear();
                TxtUserName.Focus();
            }
        }
Пример #7
0
        private void bunifuButton1_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection myConnection = default(SqlConnection);
                myConnection = new SqlConnection(@"Data Source=DESKTOP-NP1RDM2\BAZALUIMARIAN;Initial Catalog=task;Persist Security Info=True;User ID=sa; Password = 0299");



                {
                    String query = "INSERT INTO dbo.Users (NameUser,PasswordUser,UserA) VALUES (@UserName,@Password,@UserA)";

                    using (SqlCommand command = new SqlCommand(query, con))
                    {
                        command.Parameters.AddWithValue("@UserName", TxtUserName.Text);

                        command.Parameters.AddWithValue("@Password", TxtPassword.Text);
                        command.Parameters.AddWithValue("@UserA", TxtUserA.Text);
                        MessageBox.Show("Save with successfully !", "Save with successfully", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        con.Open();
                        int result = command.ExecuteNonQuery();

                        // Check Error
                        if (result < 0)
                        {
                            MessageBox.Show("Save with successfully", "Save with successfully", MessageBoxButtons.OK, MessageBoxIcon.Error);

                            TxtUserName.Clear();
                            TxtUserA.Clear();
                            TxtPassword.Clear();
                            TxtUserName.Focus();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #8
0
        private void BtRegistrar_Click(object sender, EventArgs e)
        {
            try
            {
                if (TxtPass.Text == TxtUserName.Text)
                {
                    MessageBox.Show("El usuario y al contraseña no pueden ser iguales");
                    TxtUserName.Clear();
                    TxtPass.Clear();
                    return;
                }
                DataBaseControl DBControl  = new DataBaseControl(DataBaseControl.cPath, "ProjectDataBase.mdf");
                string[]        parameters = { "@userName", "@pass", "cat" };
                string[]        elements   = { TxtUserName.Text, TxtPass.Text, CBCat.SelectedItem.ToString() };
                if (DBControl.Insertar("insert into Users values(@userName,@pass,@cat)", parameters, elements))
                {
                    string[] para    = { "@id" };
                    string[] val     = { System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString() };
                    int      activos = int.Parse(DBControl.BuscarElemento("select [registros] from Activos where [ID] = @id", para, val));
                    para = new string[] { "@id", "@nums" };
                    string[] nums = { System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString(), (++activos).ToString(), };
                    DBControl.Insertar("update [Activos] set [registros]=@nums where [id]=@id", para, nums);

                    MessageBox.Show("Usuario agregado");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("El usuario no pudo ser agregado");
                }
                DBControl.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Por favor, verifique los datos");
            }
        }
Пример #9
0
 private void devAdd()
 {
     try
     {
         if (TxtPsw.Text == TxtUserName.Text)
         {
             MessageBox.Show("El usuario y al contraseña no pueden ser iguales");
             TxtUserName.Clear();
             TxtPsw.Clear();
             return;
         }
         ControlDB DBControl  = new ControlDB(ControlDB.cPath, "dbQA.mdf");
         string[]  parameters = { "@name", "@Username", "@pass", "cat" };
         string[]  elements   = { "No One", TxtUserName.Text, TxtPsw.Text, "Dev" };
         if (DBControl.Buscar("Select * from [User] where Username=@userName", parameters, elements))
         {
             MessageBox.Show("El usuario ya existe");
             TxtUserName.Clear();
             TxtPsw.Clear();
             return;
         }
         if (DBControl.Insertar("insert into [User] values(@Name,@userName,@pass,@cat)", parameters, elements))
         {
             MessageBox.Show("Usuario agregado");
         }
         else
         {
             MessageBox.Show("El usuario no pudo ser agregado");
         }
         DBControl.Close();
     }
     catch (Exception)
     {
         MessageBox.Show("Por favor, verifique los datos");
     }
 }
 private void TxtUserName_Enter(object sender, EventArgs e)
 {
     TxtUserName.Clear();
     TxtUserName.ForeColor = Color.Black;
 }
Пример #11
0
 private void BtnClear_Click(object sender, EventArgs e)
 {
     TxtUserName.Clear();
     TxtPassword.Clear();
 }