コード例 #1
0
        private void dataGridView1_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
        {
            DialogResult result4 = MessageBox.Show("Segur que vols eliminar l'admin?", "Eliminar", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (result4 == DialogResult.Yes)
            {
                ORMAdmins.DeleteAdmin((ADMINS)dataGridView1.SelectedRows[0].DataBoundItem);
            }
            else
            {
                e.Cancel = true;
            }
        }
コード例 #2
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            //TODO:validacion here.....

            //Validaciones de las textbox

            if (textBoxContraseña.Text.Length == 0 && textBoxNombre.Text.Length == 0)
            {
                MessageBox.Show("Omplir els camps.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            else if (textBoxNombre.Text.Length == 0)
            {
                MessageBox.Show("Omplir el camp Nom d'usuari.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                textBoxNombre.Focus();
            }

            else if (textBoxContraseña.Text.Length == 0)
            {
                MessageBox.Show("Omplir el camp Clau d'accés.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                textBoxContraseña.Focus();
            }

            else
            {
                // En este else irian las comprobaciones con el servidor
                List <ADMINS> _admins = ORMAdmins.SelectAllAdmins();

                foreach (ADMINS admin in _admins)
                {
                    if (admin.nombre == textBoxNombre.Text)
                    {
                        if (admin.password == textBoxContraseña.Text)
                        {
                            correcto = true;
                        }
                    }
                }

                if (!correcto)
                {
                    MessageBox.Show("Nom o contrasenya incorrectes.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    textBoxNombre.Focus();
                }
            }

            if (correcto)
            {
                this.Close();
            }
        }
コード例 #3
0
 private void buttonAcceptar_Click(object sender, EventArgs e)
 {
     if (textBoxNom.Text.Length == 0 || textBoxPAss.Text.Length < 4 || textBoxCorreu.Text.Length == 0)
     {
         MessageBox.Show("Les dades son incorrectes.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         ORMAdmins.InsertAdmin(textBoxNom.Text, textBoxPAss.Text, textBoxCorreu.Text);
         //Refrescamos la grid
         bindingSourceAdmins.DataSource = ORMAdmins.SelectAllAdmins();
         //Dejamos las textbox limpias
         textBoxNom.Text    = "";
         textBoxPAss.Text   = "";
         textBoxCorreu.Text = "";
     }
 }
コード例 #4
0
        private void FormInicio_Load(object sender, EventArgs e)
        {
            tabPeticio();

            //cargamos grids
            bindingSourceEntitats.DataSource     = ORMEntitats.SelectAllEntitats();
            bindingSourcePeticions.DataSource    = ORMActivitatsDemandades.SelectAllActvitats();
            bindingSourceInstalacions.DataSource = ORMInstalacions.SelectAllInstalacions();
            bindingSourceActivitats.DataSource   = ORMActivitats.SelectAllActvitats();
            bindingSourceAdmins.DataSource       = ORMAdmins.SelectAllAdmins();

            //Grid de peticiones

            foreach (DataGridViewRow item in dataGridViewPeticio.Rows)
            {
                //if (item.Cells[1].Value.ToString().Equals("Acceptada"))
                if (item.Cells[1].Value == null)
                {
                    item.DefaultCellStyle.SelectionBackColor = Color.Green;
                }
            }
        }