Esempio n. 1
0
 private void dgvReader_SelectionChanged(object sender, EventArgs e)//选择行操作
 {
     if (dgvReader.CurrentCell == null)
     {
         return;
     }
     reader = ReaderAdmin.GetReader((int)dgvReader["rdID", dgvReader.CurrentCell.RowIndex].Value);
     SetReaderToText();
 }
Esempio n. 2
0
        private void ChargementCollectionAdmin()
        {
            try
            {
                CollAdmin.Clear();
                //Ouverture connexion
                GestConn.Open();
                //Requete SQL
                String       ReqSql     = "SELECT * FROM membre ORDER BY ID_MEMBRE";
                MySqlCommand MaCommande = new MySqlCommand(ReqSql, GestConn);
                //Déclaration de Data Reader
                MySqlDataReader ReaderAdmin;
                //Exécution de la requête
                ReaderAdmin = MaCommande.ExecuteReader();
                //Nouveau contact
                Admin NouveauAdmin;

                while (ReaderAdmin.Read())
                {
                    NouveauAdmin.id        = int.Parse(ReaderAdmin["ID_MEMBRE"].ToString());
                    NouveauAdmin.nom       = (ReaderAdmin["NOM_MEMBRE"].ToString());
                    NouveauAdmin.prenom    = (ReaderAdmin["PRENOM_MEMBRE"].ToString());
                    NouveauAdmin.mail      = (ReaderAdmin["EMAIL_MEMBRE"].ToString());
                    NouveauAdmin.ville     = (ReaderAdmin["VILLE_MEMBRE"].ToString());
                    NouveauAdmin.adresse   = (ReaderAdmin["ADRESSE_MEMBRE"].ToString());
                    NouveauAdmin.cp        = (ReaderAdmin["CP_MEMBRE"].ToString());
                    NouveauAdmin.telephone = (ReaderAdmin["TEL_MEMBRE"].ToString());
                    NouveauAdmin.mdp       = (ReaderAdmin["MDP_MEMBRE"].ToString());
                    NouveauAdmin.login     = (ReaderAdmin["LOGIN_MEMBRE"].ToString());
                    NouveauAdmin.type      = (ReaderAdmin["TYPE_MEMBRE"].ToString());
                    NouveauAdmin.photo     = (ReaderAdmin["PHOTO_MEMBRE"].ToString());
                    NouveauAdmin.desc      = (ReaderAdmin["DESC_MEMBRE"].ToString());
                    NouveauAdmin.valide    = int.Parse(ReaderAdmin["VALIDE_MEMBRE"].ToString());
                    NouveauAdmin.argent    = Convert.ToDouble(ReaderAdmin["ARGENT_MEMBRE"].ToString());

                    CollAdmin.Add(NouveauAdmin);
                }

                ReaderAdmin.Close();
                GestConn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erreur : " + ex.Message);
            }
        }
Esempio n. 3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            loginTimes++;
            int rdID;

            rdID   = Convert.ToInt32(txtUserID.Text.Trim());
            reader = ReaderAdmin.GetReader(rdID);

            if (reader == null)
            {
                txtUserID.Focus();
                lblReaderInfo.Text = "登录信息:查无此人..{" + loginTimes.ToString() + "}";
            }
            else
            {
                if (reader.rdPwd == txtUserPwd.Text)
                {
                    this.DialogResult = DialogResult.OK;//登录成功
                }
                else
                {
                    txtUserPwd.Text = "";
                    txtUserPwd.Focus();
                    lblReaderInfo.Text = "登录信息:..密码错误!{" + loginTimes.ToString() + "}";
                }
            }

            //使用下面方法会导致数据库注入登录,不安全
            //SqlConnection conn = new SqlConnection("server=.; database=bookLibrary; integrated security=true");
            //conn.Open();
            //SqlCommand cmd = conn.CreateCommand();
            //cmd.CommandText = string.Format("select count(*) from reader where rdid={0} and rdPwd='{1}'", txtUserID.Text, txtUserPwd.Text);
            //int count = Convert.ToInt32(cmd.ExecuteScalar());
            //if (count == 0)
            //{
            //    MessageBox.Show("用户登录失败!");
            //}
            //else
            //{
            //    MessageBox.Show("嘿嘿,登录成功!");
            //}
        }
Esempio n. 4
0
        public void rechercheInformation(String requeteSQL)
        {
            try
            {
                //Ouverture connexion
                GestConn.Open();
                MySqlCommand MaCommande = new MySqlCommand(requeteSQL, GestConn);
                //Déclaration de Data Reader
                MySqlDataReader ReaderAdmin;
                //Exécution de la requête
                ReaderAdmin = MaCommande.ExecuteReader();

                while (ReaderAdmin.Read())
                {
                    this.nom       = (ReaderAdmin["NOM_MEMBRE"].ToString());
                    this.prenom    = (ReaderAdmin["PRENOM_MEMBRE"].ToString());
                    this.mail      = (ReaderAdmin["EMAIL_MEMBRE"].ToString());
                    this.ville     = (ReaderAdmin["VILLE_MEMBRE"].ToString());
                    this.adresse   = (ReaderAdmin["ADRESSE_MEMBRE"].ToString());
                    this.cp        = (ReaderAdmin["CP_MEMBRE"].ToString());
                    this.telephone = (ReaderAdmin["TEL_MEMBRE"].ToString());
                    this.mdp       = (ReaderAdmin["MDP_MEMBRE"].ToString());
                    this.login     = (ReaderAdmin["LOGIN_MEMBRE"].ToString());
                    this.type      = (ReaderAdmin["TYPE_MEMBRE"].ToString());
                    this.photo     = (ReaderAdmin["PHOTO_MEMBRE"].ToString());
                    this.desc      = (ReaderAdmin["DESC_MEMBRE"].ToString());
                    this.valide    = int.Parse(ReaderAdmin["VALIDE_MEMBRE"].ToString());
                    this.argent    = Convert.ToDouble(ReaderAdmin["ARGENT_MEMBRE"].ToString());
                }
                ReaderAdmin.Close();
                GestConn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erreur : " + ex.Message);
            }
        }