Close() public method

Closes the MySqlDataReader object.
public Close ( ) : void
return void
Ejemplo n.º 1
2
        public static void Login(string username, string passhash)
        {
            if (Validate(username, passhash))
            {
                time = string.Format("{0:yyyy.MM.dd 0:HH:mm:ss tt}", DateTime.Now);

                rdr = new MySqlCommand("SELECT lastin FROM login WHERE username='******';", conn).ExecuteReader();
                while (rdr.Read()) {
                    Console.WriteLine("User's last sign in was: " + rdr["lastin"]);
                }
                rdr.Close();

                new MySqlCommand("UPDATE login SET lastin='" + time + "' WHERE username='******';", conn).ExecuteNonQuery();

            }
            Console.WriteLine("HHHHhhhh");

            //TODO:
            //
            //If the username exists, check that the password hash matches.
            //
            //If the username does not exist, be like "No user found".
            //
            //Else, If the password hash matches, Sign in.
            //Set the current player to active
            //forward/bind socket to control an Object?
            //Note the timestamp and IP of the login in the database
            //Send all of the necessary information back to the client:
        }
Ejemplo n.º 2
0
        // overload 2/9/2011 fix load history in new month
        public bool CheckMonthlyDocIsApprove(POSMySQL.POSControl.CDBUtil dbUtil, MySql.Data.MySqlClient.MySqlConnection conn,
                                             DateTime dateFrom, DateTime dateTo)
        {
            this.DocumentTypeId = 7;
            string sql = " SELECT DocumentDate, DocumentID FROM document WHERE documenttypeid=" + this.DocumentTypeId + " AND shopid=" + this.ShopId +
                         " AND DocumentStatus=1 AND DocumentDate BETWEEN '" + dateFrom.ToString("yyyy-MM-dd", dateProvider) + "' AND '" + dateTo.ToString("yyyy-MM-dd", dateProvider) + "'";

            MySql.Data.MySqlClient.MySqlDataReader reader = dbUtil.sqlRetrive(sql, conn);
            if (reader.Read())
            {
                this.DocumentDate = reader.GetDateTime("DocumentDate");
                this.DocumentId   = reader.GetInt32("DocumentID");
                reader.Close();
                return(false); // Approved
            }
            else
            {
                sql = " SELECT DocumentDate, DocumentID FROM document WHERE documenttypeid=" + this.DocumentTypeId + " AND shopid=" + this.ShopId +
                      " AND DocumentStatus=2 AND DocumentDate BETWEEN '" + dateFrom.ToString("yyyy-MM-dd", dateProvider) + "' AND '" + dateTo.ToString("yyyy-MM-dd", dateProvider) + "'";
                reader.Close();
                reader = dbUtil.sqlRetrive(sql, conn);
                if (reader.Read())
                {
                    this.DocumentDate = reader.GetDateTime("DocumentDate");
                    this.DocumentId   = reader.GetInt32("DocumentID");
                    reader.Close();
                    return(true); // Not Approve
                }
                else
                {
                    reader.Close();
                }
            }
            return(false);
        }
 // Initialise la fenêtre
 private void initialisation()
 {
     try
     {
         if (Global.Connection.State != ConnectionState.Open)
         {
             // Ouverture de la connexion
             Global.Connection.Open();
         }
         MySqlCommand cmd = new MySqlCommand("SELECT * FROM utilisateur WHERE idUtilisateur = '" + Global.userId + "'", Global.Connection);
         rd = cmd.ExecuteReader();
         rd.Read();
         labelPrenom.Text = (string)rd["prenom"];
         labelNom.Text = (string)rd["nom"];
         labelMail.Text = (string)rd["mail"];
         labelNaissance.Text = String.Format("{0:dd/MM/yyyy}", rd["dateNaissance"]);
         labelSexe.Text = (string)rd["sexe"];
         textBoxLogin.Text = (string)rd["login"];
         pictureBoxAvatar.Load(System.Windows.Forms.Application.StartupPath + @"\Avatar\" + (string)rd["avatar"]);
         avatarPath = System.Windows.Forms.Application.StartupPath + @"\Avatar\" + (string)rd["avatar"];
         rd.Close();
         // Fermeture de la connexion
         //Global.Connection.Close();
     }
     catch (MySqlException)
     {
         MessageBox.Show("Une erreur est survenue. Impossible de contiuer.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
         rd.Close();
         Global.Connection.Close();
     }
 }
 // Changement du mot de passe
 private void btnValider_Click(object sender, EventArgs e) {
     // Si tout les champs renseignés
     if (txtAncMdp.Text != "" && txtCnfNouvMdp.Text != "" && txtNouvMdp.Text != "") {
         // ---------- Vérification des informations rentrées ---------------           
         // Vérification que nouveau mot de passe + confirmation soient identiques
         if (txtNouvMdp.Text == txtCnfNouvMdp.Text) {
             // Vérification de la longueur du nouveau mot de passe
             if (txtNouvMdp.TextLength >= Global._MIN_CARAC_PWD) {
                 // Vérification du mot de passe actuel
                 try {
                     cmd = new MySqlCommand("SELECT count(*) FROM utilisateur WHERE idUtilisateur = '" + Global.userId + "' and password = PASSWORD(@pwd)", Global.Connection);
                     MySqlParameter pMdp = new MySqlParameter("@pwd", MySqlDbType.Text);
                     pMdp.Value = txtAncMdp.Text;
                     cmd.Parameters.Add(pMdp);
                     cmd.Prepare();
                     rd = cmd.ExecuteReader();
                     rd.Read();
                     // Si ancien mot de passe OK
                     if (rd.GetInt16(0) == 1) {
                         rd.Close();
                         // MAJ du mot de passe
                         cmd = new MySqlCommand("UPDATE utilisateur SET password = PASSWORD(@pwd) WHERE idUtilisateur = '" + Global.userId + "'", Global.Connection);
                         MySqlParameter pNouvMdp = new MySqlParameter("@pwd", MySqlDbType.Text);
                         pNouvMdp.Value = txtNouvMdp.Text;
                         cmd.Parameters.Add(pNouvMdp);
                         cmd.Prepare();
                         cmd.ExecuteNonQuery();
                         MessageBox.Show("Votre mot de passe a bien été modifié ! ", "Succès", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         rd.Close();
                         // Retour à l'écran principal
                         this.Close();
                     } else {
                         MessageBox.Show("Votre mot de passe actuel est incorrect. Veuillez recommencer.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         txtAncMdp.Text = "";
                         rd.Close();
                     }
                 } catch (MySqlException) {
                     MessageBox.Show("Une erreur est survenue. Le mot de passe n'a pas été changé.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     rd.Close();
                 }
             } else {
                 MessageBox.Show("Le nouveau mot de passe est trop petit : minimum " + Global._MIN_CARAC_PWD + " caractères.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txtNouvMdp.Text = "";
                 txtCnfNouvMdp.Text = "";
             }
         } else {
             MessageBox.Show("Le nouveau mot de passe et sa confirmation ne correspondent pas.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
             txtNouvMdp.Text = "";
             txtCnfNouvMdp.Text = "";
         }
     } else {
         MessageBox.Show("Veuillez renseigner tous les champs.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        /// <summary>
        /// Initialisation de la fenêtre
        /// </summary>
        private void init() {
            // Résa en cours 
            try {
                requete = "SELECT idEmprunt, categorie, marque, modele, matricule, vehicule.idVehicule FROM emprunt INNER JOIN vehicule ON emprunt.idVehicule = vehicule.idVehicule "
                    + " INNER JOIN categorievehicule ON vehicule.idCategorieVehicule = categorievehicule.idCategorieVehicule WHERE idUtilisateur = " + Global.userId + " AND valide = 1 AND rendu = 0";
                MySqlCommand cmd = new MySqlCommand(requete, Global.Connection);
                rd = cmd.ExecuteReader();
                // On ajoute chaque ligne à la dgv
                dgvEnCours.AllowUserToAddRows = true;
                while (rd.Read() != false) {
                    row = (DataGridViewRow)dgvEnCours.Rows[0].Clone();
                    row.Cells[0].Value = rd["idEmprunt"];
                    row.Cells[1].Value = rd["idVehicule"];
                    row.Cells[2].Value = rd["categorie"];
                    row.Cells[3].Value = rd["marque"];
                    row.Cells[4].Value = rd["modele"];
                    row.Cells[5].Value = rd["matricule"];
                    dgvEnCours.Rows.Add(row);
                }
                dgvEnCours.AllowUserToAddRows = false;
                rd.Close();
            } catch (MySqlException) {
                MessageBox.Show("Une erreur est survenue. Impossible de contiuer.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                rd.Close();
            }

            // Résa en attente
            try {
                requete = "SELECT idEmprunt, categorie, marque, modele, matricule, vehicule.idVehicule FROM emprunt INNER JOIN vehicule ON emprunt.idVehicule = vehicule.idVehicule "
                    + " INNER JOIN categorievehicule ON vehicule.idCategorieVehicule = categorievehicule.idCategorieVehicule WHERE idUtilisateur = " + Global.userId + " AND valide = 0 AND rendu = 0";
                MySqlCommand cmd = new MySqlCommand(requete, Global.Connection);
                rd = cmd.ExecuteReader();
                // On ajoute chaque ligne à la dgv
                dgvEnAtt.AllowUserToAddRows = true;
                while (rd.Read() != false) {
                    row = (DataGridViewRow)dgvEnAtt.Rows[0].Clone();
                    row.Cells[0].Value = rd["idEmprunt"];
                    row.Cells[1].Value = rd["idVehicule"];
                    row.Cells[2].Value = rd["categorie"];
                    row.Cells[3].Value = rd["marque"];
                    row.Cells[4].Value = rd["modele"];
                    row.Cells[5].Value = rd["matricule"];
                    dgvEnAtt.Rows.Add(row);
                }
                dgvEnAtt.AllowUserToAddRows = false;
                rd.Close();
            } catch (MySqlException) {
                MessageBox.Show("Une erreur est survenue. Impossible de contiuer.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                rd.Close();
            }
        }
Ejemplo n.º 6
0
 public string getMACPass(string email)
 {
     string query = string.Format("SELECT u.macpass from users u WHERE u.email='{0}';", email);
     cmd = new MySqlCommand(query, conn);
     read = cmd.ExecuteReader();
     if (read.Read())
     {
         string result = read.GetString(0);
         read.Close();
         return result;
     }
     read.Close();
     return "No records exist";
 }
Ejemplo n.º 7
0
 public string getAnswers(string email)
 {
     string query = "SELECT u.semisecret1 from users u WHERE u.email='" + email + "';";
     cmd = new MySqlCommand(query, conn);
     read = cmd.ExecuteReader();
     if (read.Read())
     {
         string result = read.GetString(0);
         read.Close();
         return result;
     }
     read.Close();
     return email + ": No records exist";
 }
 // Initialise la fenêtre
 private void initialisation() {
     try {
         MySqlCommand cmd = new MySqlCommand("SELECT * FROM utilisateur WHERE idUtilisateur = '" + Global.userId + "'", Global.Connection);
         rd = cmd.ExecuteReader();
         rd.Read();
         rd.Close();
         // MAJ des infos de connexion
         cmd = new MySqlCommand("UPDATE utilisateur SET dateDerniereConnexion = now() WHERE idUtilisateur = '" + Global.userId + "'", Global.Connection);
         cmd.ExecuteNonQuery();
         rd.Close();
     } catch (MySqlException) {
         MessageBox.Show("Une erreur est survenue. Impossible de contiuer.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
         rd.Close();
     }
 }
Ejemplo n.º 9
0
        private Object getAllItems()
        {
            try
            {
                connection.Open();

                string sql = "SELECT title FROM products";
                //string sql = "INSERT INTO `products`(`title`, `short_desc`, `long_desc`, `is_frontpage`, `availability_date`, `expiration_date`, `view_count`, `id_brand`) VALUES('Test', 'Test', 'Test', '0', '2015-04-29', '2015 - 05 - 29', '12', '1')";
                command = new MySqlCommand(sql, connection);
                executer = command.ExecuteReader();

                /*while (executer.Read())
                {
                    Console.WriteLine(executer[0]);
                }*/
                executer.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            connection.Close();

            return executer;
        }
Ejemplo n.º 10
0
 private void button1_Click(object sender, EventArgs e)
 {
     string query = "select * from testing";
     MySqlCommand command = new MySqlCommand(query, connection);
     try
     {
         connection.Open();
         read = command.ExecuteReader();
         if (read.HasRows == true)
         {
             MessageBox.Show("ADA DATANYA dan koneksi berhasil", "INFO", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show("GA ADAAAAAAA", "INFO", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         read.Close();
     }
     catch (MySqlException ex)
     {
         MessageBox.Show(ex.Message.ToString());
     }
     finally
     {
         connection.Close();
     }
 }
Ejemplo n.º 11
0
 public List<Sector> LoadSector()
 {
     try
     {
         using (MySqlConnection cn = new MySqlConnection((clsCon = new Connection(this.user)).Parameters()))
         {
             listSec = new List<Sector>();
             cn.Open();
             sql = "select * from asada.view_sectores";
             cmd = new MySqlCommand(sql, cn);
             reader = cmd.ExecuteReader();
             while (reader.Read())
             {
                 sec = new Sector();
                 sec.Code = reader.GetString(0);
                 sec.Consecutive = reader.GetInt32(1);
                 sec.Description = reader.GetString(2);
                 listSec.Add(sec);
             }
             reader.Close();
             return listSec;
         }
     }
     catch (Exception e)
     {
         Logs lg = new Logs();
         lg.Log(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + ", " + e.Message.ToString());
         throw;
     }
 }
Ejemplo n.º 12
0
        public List<Tarifa> LoadTarifa()
        {
            try
            {
                using (MySqlConnection cn = new MySqlConnection((clsCon = new Connection(this.user)).Parameters()))
                {
                    lisTrf = new List<Tarifa>();
                    cn.Open();
                    sql = "select * from asada.view_tarifas";
                    cmd = new MySqlCommand(sql, cn);
                    reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        trf = new Tarifa();
                        trf.Code = reader.GetString(0);
                        trf.FixAmount = float.Parse(reader.GetString(1));
                        trf.MetAmount = float.Parse(reader.GetString(2));
                        trf.RateHidrant = float.Parse(reader.GetString(3));
                        trf.TypeAppString = reader.GetString(4);
                        lisTrf.Add(trf);
                    }
                    reader.Close();
                    return lisTrf;
                }
            }
            catch (Exception)
            {
                throw;
            }

        }        
Ejemplo n.º 13
0
        public Boolean CarregaDadosComplementares(String userName)
        {
            using (Banco banco = new Banco())
            {
                banco.AddParameter("userName", userName);

                using (MySql.Data.MySqlClient.MySqlDataReader reader = banco.ExecuteReader("SELECT * FROM users_detail WHERE userName = @userName"))
                {
                    if (reader.Read())
                    {
                        try { UserUF = reader["uf"].ToString(); }
                        catch { UserUF = ""; }

                        try { UserCidade = reader["cidade"].ToString(); }
                        catch { UserCidade = ""; }

                        try { MostraEmail = Convert.ToBoolean(reader["mostra_email"]); }
                        catch { MostraEmail = false; }
                    }

                    reader.Close();
                }
            }

            return(true);
        }
Ejemplo n.º 14
0
        public List<string> getNextInfoHashes(int nofInfohashes)
        {
            List<String> lResult = new List<String>();
            lock (Program.dbLock)
            {
                // Get oldest torrent
                command.CommandText = "SELECT  `infohash`,`id` FROM  `torrents45` ORDER BY updated ASC LIMIT "
                    + nofInfohashes.ToString() + ";";
                command.CommandTimeout = 60000;
                connection.Open();

                reader = command.ExecuteReader();
                if (!reader.HasRows) return null;
                while (reader.Read())
                {
                    lResult.Add(reader.GetString("infohash"));
                }

                reader.Close();
                connection.Close();
                connection.Open();

                command.CommandText = "UPDATE `torrents45` SET updated = CURRENT_TIMESTAMP WHERE infohash = '" + lResult[0] + "' OR ";
                for (int i = 1; i < lResult.Count-1; i++)
                {
                    command.CommandText += "infohash = '" + lResult[i] + "' OR ";
                }
                command.CommandText += "infohash = '" + lResult[lResult.Count-1] + "';";
                command.CommandTimeout = 60000;
                command.ExecuteNonQuery();
                connection.Close();
            }
            return lResult;
        }
Ejemplo n.º 15
0
        private void RulesForm_Load(object sender, EventArgs e)
        {
            string time="";
            this.ControlBox = false;

            con.Open();
            cmd = new MySqlCommand("select sum(mark) from test where ecode='" + SelectExam.exam_code + "'", con);
            dr = cmd.ExecuteReader();
            dr.Read();
            cnt = dr.GetInt32(0);
            dr.Close();

               cmd = new MySqlCommand("select duration,tot_quest from exam where eid='" + SelectExam.exam_code + "'", con);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                noquest = dr.GetInt32("tot_quest");
                temp = dr.GetInt32("duration");
                time = (temp.ToString().Length > 1) ? "mins" : "hrs";
                label3.Text = "Duraton of Exam is : " + temp.ToString() + " " + time + "\n\nTotal Number Of Questions : " + noquest+"\n\nMax. Marks : "+cnt;
            }
            else
            {
                MessageBox.Show("Exam Code not selected", "Code Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                this.Hide();
                new SelectExam().Show();
            }
            dr.Close();
            con.Close();
        }
        private bool DoSQLQueryTest()
        {
            try
            {
                String connString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();
                conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
                conn.Open();
                String queryStr = "";
                queryStr   = "SELECT COUNT(id) as countindex FROM database.metadata WHERE metadata.codeuser='******' ";
                cmd        = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
                reader     = cmd.ExecuteReader();
                countindex = 0;

                while (reader.HasRows && reader.Read())
                {
                    countindex = reader.GetInt32(reader.GetOrdinal("countindex"));
                }


                if (countindex != 0)
                {
                    return(true);
                }

                reader.Close();
                conn.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            return(false);
        }
        private void DoSQLCountComment()
        {
            try
            {
                String connString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();
                conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
                conn.Open();
                String queryStr = "";
                queryStr = "SELECT COUNT(id) as countcom FROM database.comment WHERE comment.codeuser='******' AND comment.idmetadata= (SELECT id from database.metadata WHERE metadata.codeuser='******') ";
                cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
                reader   = cmd.ExecuteReader();
                count    = "";

                while (reader.HasRows && reader.Read())
                {
                    count = reader.GetString(reader.GetOrdinal("countcom"));
                }
                if (reader.HasRows)
                {
                    LaCountComment.Text = count;
                }

                reader.Close();
                conn.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 18
0
    public WebLogin(string database, string username, string password, string tableName) {
        try {
            // initialize the List objects
            usernames = new List<string>();
            passwords = new List<string>();

            // setup connection string
            connectionString = "Database=" + database + ";Data Source=localhost;User Id=" + username +
                               ";Password="******"SELECT username,password FROM " + tableName;
            dbCommand = new MySqlCommand(sqlString, dbConnection);
            // get all the data!
            dbReader = dbCommand.ExecuteReader();

            // populate List objects with usernames/passwords (Parallel Lists!)
            while (dbReader.Read()) {
                usernames.Add(dbReader["username"].ToString());
                passwords.Add(dbReader["password"].ToString());
            }
            dbReader.Close();

            // other initialization
            _username = "";
            _password = "";
            _access = false;
        } finally {
            dbConnection.Close();
        }
    }
Ejemplo n.º 19
0
 public static void DisposeMysql(MySqlDataReader obj)
 {
     if (obj != null)
     {
         obj.Close();
     }
 }
Ejemplo n.º 20
0
        private void printForumPost()
        {
            String connString = System.Configuration.ConfigurationManager.ConnectionStrings["CredditConnString"].ToString();

            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = "";
            queryStr = "SELECT * FROM forum WHERE forumId='" + forumId + "'";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
            reader   = cmd.ExecuteReader();
            String post        = "";
            String name        = "";
            int    accountID   = 0;
            String dateTime    = "";
            String accountType = "";

            while (reader.HasRows && reader.Read())
            {
                post        = reader.GetString(reader.GetOrdinal("post"));
                name        = reader.GetString(reader.GetOrdinal("name"));
                dateTime    = reader.GetString(reader.GetOrdinal("dateTime"));
                accountID   = Int32.Parse(reader.GetString(reader.GetOrdinal("accountId")));
                accountType = reader.GetString(reader.GetOrdinal("accountType"));
            }
            PostLabel.Text     = post;
            NameLabel.Text     = name;
            datetimeLabel.Text = dateTime;
            TypeLabel.Text     = accountType;
            reader.Close();
            conn.Close();
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();
            conn             = new MySql.Data.MySqlClient.MySqlConnection(connectionString);
            conn.Open();
            userID = (String)Session["trainerID"];
            String query = "SELECT * FROM webapppersonalfit.trainer AS T WHERE T.userID=" + userID + ";";
            cmd    = new MySql.Data.MySqlClient.MySqlCommand(query, conn);
            reader = cmd.ExecuteReader();

            if (reader.HasRows && reader.Read())
            {
                Username.Text    = reader.GetString(reader.GetOrdinal("name"));
                short_intro.Text = reader.GetString(reader.GetOrdinal("short_intro"));
                long_intro.Text  = reader.GetString(reader.GetOrdinal("long_intro"));
                avatar.ImageUrl  = reader.GetString(reader.GetOrdinal("url_pic"));
            }
            addSpanOntoPlaceHolder();
            conn.Close();
            reader.Close();
        }
        catch (Exception ex)
        {
            //
        }
    }
        private void DoSQLQueryPie1()
        {
            try
            {
                String connString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();
                conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
                if ((String)(Session["urole"]) == "1")
                {
                    conn.Open();
                    queryStr = "";
                    queryStr = "SELECT * FROM database.detail WHERE detail.t1='" + Session["OfInterne"] + "' AND detail.titre='Suivi Prod'";
                    cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
                    reader   = cmd.ExecuteReader();

                    while (reader.HasRows && reader.Read())
                    {
                        Qteof    = reader.GetString(reader.GetOrdinal("t2"));
                        Coupe    = reader.GetString(reader.GetOrdinal("t3"));
                        Montage  = reader.GetString(reader.GetOrdinal("t4"));
                        Controle = reader.GetString(reader.GetOrdinal("t5"));
                        Finition = reader.GetString(reader.GetOrdinal("t6"));
                        Exped    = reader.GetString(reader.GetOrdinal("t7"));
                    }



                    reader.Close();
                    conn.Close();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 23
0
        public Dictionary<int, string> get_db_controlsamples_current(int id)
        {
            _connection.Open();
            var controlsamples = new Dictionary<int, string>();

            var myCommand = new MySqlCommand(@"
                SELECT
                controlsamples.Id_ControlSample,
                controlsamples.NameControlSample
                FROM
                controlsamples
                WHERE controlsamples.Id_SizeTube = @A
            ", _connection.MySqlConnection);
            myCommand.Parameters.AddWithValue("A", id);

            _mySqlDataReader = myCommand.ExecuteReader();

            while (_mySqlDataReader.Read())
            {
                controlsamples.Add(_mySqlDataReader.GetInt32(0), _mySqlDataReader.GetString(1));
            }
            _mySqlDataReader.Close();
            _connection.Close();
            return controlsamples;
        }
        public bool deleteCustomer(long contactNo)
        {
            Customer        p    = new Customer();
            MySqlConnection conn = mysqlDbConnect.GetConnection();

            MySql.Data.MySqlClient.MySqlDataReader mySqlReade = null;
            String sqlString = "SELECT * FROM customer WHERE contactNo = '" + contactNo.ToString() + "'";

            MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(sqlString, conn);
            mySqlReade = cmd.ExecuteReader();

            if (mySqlReade.Read())
            {
                mySqlReade.Close();
                sqlString = "DELETE FROM customer WHERE contactNo = '" + contactNo.ToString() + "'";
                cmd       = new MySql.Data.MySqlClient.MySqlCommand(sqlString, conn);
                cmd.ExecuteNonQuery();
                return(true);
            }

            else
            {
                return(false);
            }
        }
Ejemplo n.º 25
0
 //important to pass string address text because it is needed to identify which offers are made on which listings
 public oForm(string s)
 {
     //Same syntax to establish the connector for the database from form1
     InitializeComponent();
     con = new MySqlConnection("SERVER=localhost;DATABASE=properties;UID=ricefieldboy;PASSWORD=Superhi2;");
     con.Open();
     cmd = new MySqlCommand("SELECT * FROM listings where address='" + s + "'", con); //selects all rows from listings where address is 's', the string address
     read = cmd.ExecuteReader();
     if (read.HasRows)
     {//name and offers will be added
         test = s;
         read.Read();
         name1.Text = read[19].ToString();
         name2.Text = read[20].ToString();
         name3.Text = read[21].ToString();
         name4.Text = read[22].ToString();
         name5.Text = read[23].ToString();
         offer1.Text = read[24].ToString();
         offer2.Text = read[25].ToString();
         offer3.Text = read[26].ToString();
         offer4.Text = read[27].ToString();
         offer5.Text = read[28].ToString();
         name6.Text = read[38].ToString();
         offer6.Text = read[37].ToString();
         read.Close();
     }
 }
Ejemplo n.º 26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString.Count==0) { evtid = "2"; }
        else
        { evtid = Request.QueryString["eventid"]; }
        try
        {
            con.Open();

            cmddispevt = new MySqlCommand("select name,detail,img1path,img2path,img3path from events where rowid=" + evtid, con);
            drdispevt = cmddispevt.ExecuteReader();
            drdispevt.Read();
            EventHead = drdispevt.GetString("name");
            EventStory = drdispevt.GetString("detail");
            img1.Src = "../"+drdispevt.GetString("img1path") + "thumbs/img1.jpg";
            img2.Src = "../" + drdispevt.GetString("img2path") + "thumbs/img2.jpg";
            img3.Src = "../" + drdispevt.GetString("img3path") + "thumbs/img3.jpg";
            aimg1.HRef = "../" + drdispevt.GetString("img1path") + "slides/img1.jpg";
            aimg2.HRef = "../" + drdispevt.GetString("img2path") + "slides/img2.jpg";
            aimg3.HRef = "../" + drdispevt.GetString("img3path") + "slides/img3.jpg";

            drdispevt.Close();
            con.Close();
        }
        catch (Exception ex)
        {
            CreateLogFile errlog = new CreateLogFile();
            errlog.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Page Load of AboutSSNAA Page for " + Session["loginname"] + ":" + ex.Message);
        }
    }
Ejemplo n.º 27
0
    private void LoginWithPasswordHashFunction()
    {
        List <String> salthashList = null;
        List <String> namesList    = null;

        try
        {
            connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();

            conn = new MySql.Data.MySqlClient.MySqlConnection(connectionString);
            conn.Open();
            String query = "SELECT slowHashSalt, firstname, middlename, lastname FROM webAppPersonalFit.userregistration WHERE username=?uname";

            cmd = new MySql.Data.MySqlClient.MySqlCommand(query, conn);
            cmd.Parameters.AddWithValue("?uname", usernameTextBox.Text);

            reader = cmd.ExecuteReader();

            while (reader.HasRows && reader.Read())
            {
                if (salthashList == null)
                {
                    salthashList = new List <String>();
                    namesList    = new List <String>();
                }

                String saltHashes = reader.GetString(reader.GetOrdinal("slowHashSalt"));
                //Console.WriteLine(saltHashes);
                salthashList.Add(saltHashes);

                String fullname = reader.GetString(reader.GetOrdinal("firstname")) + " " + reader.GetString(reader.GetOrdinal("lastname"));
                namesList.Add(fullname);
            }

            if (salthashList != null)
            {
                for (int i = 0; i < salthashList.Count; i++)
                {
                    bool validUser = PasswordStorage.VerifyPassword(passwordTextBox.Text, salthashList[i]);

                    if (validUser == true)
                    {
                        Session["UserName"]   = namesList[i];
                        Response.BufferOutput = true;
                        Response.Redirect("LoggedIn.aspx", false);
                    }
                    else
                    {
                        passwordTextBox.Text = "User not authenticated";
                    }
                }
            }
            reader.Close();
            conn.Close();
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }
    }
Ejemplo n.º 28
0
        public string Maxsuivant(string sTable, string sChamp, string scond)
        {
            //int iCount = GetRecordCount(QC, sTable, "");
            DeltaSQLTmp.CommandText = "SELECT (max(" + sChamp + ") + 1) as tmp FROM " + sTable;
            if (scond != "")
            {
                DeltaSQLTmp.CommandText = DeltaSQLTmp.CommandText + " WHERE " + scond;
            }
            MySql.Data.MySqlClient.MySqlDataReader Q = DeltaSQLTmp.ExecuteReader();
            //Q.Read();
            string Ret = "";

            //if (Q.RecordCount != 0)
            //if (iCount != 0)
            if (Q.Read() && Q.GetValue(Q.GetOrdinal("tmp")).ToString() != "")
            {
                Ret = Q.GetValue(Q.GetOrdinal("tmp")).ToString();
            }
            else
            {
                Ret = "1";
            }
            Q.Close();
            return(Ret);
        }
Ejemplo n.º 29
0
    public bool Login(string email, string password)
    {
        int count = DbConnecter.instance.Count("age", "member", "email = '" + email + "' AND password = '******';");

        if (count == 0)
        {
            return(false);
        }
        else
        {
            string sql = "SELECT * FROM member WHERE email = '" + email + "' AND password = '******';";
            MySql.Data.MySqlClient.MySqlDataReader reader = DbConnecter.instance.Reader(sql);
            reader.Read();
            member.email            = email;
            member.password         = password;
            member.gender           = reader.GetInt32(2);
            member.age              = reader.GetInt32(3);
            member.child            = reader.GetInt32(4);
            member.productBookmarks = "";
            if (reader.IsDBNull(5) == false)
            {
                member.productBookmarks = reader.GetString(5);
            }
            member.ingredientBookmarks = "";
            if (reader.IsDBNull(6) == false)
            {
                member.ingredientBookmarks = reader.GetString(6);
            }
            reader.Close();
            DbConnecter.instance.CloseConnection();

            return(true);
        }
    }
Ejemplo n.º 30
0
 public List<Sector> LoadSector()
 {
     try
     {
         using (MySqlConnection cn = new MySqlConnection((clsCon=new Connection(this.user)).Parameters()))
         {
             listSec = new List<Sector>();
             cn.Open();
             sql = "select * from asada.view_sectores";
             cmd = new MySqlCommand(sql, cn);
             reader = cmd.ExecuteReader();
             while (reader.Read())
             {
                 sec = new Sector();
                 sec.Code = reader.GetString(0);
                 sec.Consecutive = reader.GetInt32(1);
                 sec.Description = reader.GetString(2);
                 listSec.Add(sec);
             }
             reader.Close();
             return listSec;                    
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        private void DoSQLQueryPieFournisseur()
        {
            try
            {
                String connString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();
                conn = new MySql.Data.MySqlClient.MySqlConnection(connString);



                conn.Open();
                queryStr = "";
                queryStr = "SELECT * FROM database.detail WHERE detail.t1='" + Session["AnnPieFournisseur"] + "' AND detail.titre='Solde fournisseurs'";
                cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
                reader   = cmd.ExecuteReader();

                while (reader.HasRows && reader.Read())
                {
                    fournisseur = reader.GetString(reader.GetOrdinal("t1"));
                    DebitF1     = reader.GetInt32(reader.GetOrdinal("t2"));
                    CreditF1    = reader.GetInt32(reader.GetOrdinal("t3"));
                    SoldeF1     = reader.GetInt32(reader.GetOrdinal("t4"));
                }



                reader.Close();
                conn.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 32
0
    protected void Page_Load(object sender, EventArgs e)
    {
        nid = Request.QueryString["news_id"];
        try
        {
            con.Open();
            cmd = new MySqlCommand("select * from news where newsid='" + nid + "'", con);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                article.Text = "<h1 style='font-size:25px'>" + dr.GetString("headline").Substring(0, 1).ToUpper() + dr.GetString("headline").Substring(1).ToLower() + "</h1><br/><br/><img alt='' src='../images/tag.png' />&nbsp;Alumni News<br/><br/>";
                article.Text += " <p style='text-align: justify;'>" + dr.GetString("story") + "</p>";
                article.Text += "<p style='text-align: justify;'><a href='http://alumni.ssn.edu.in/alumni-stories.php'>http://alumni.ssn.edu.in/alumni-stories.php</a></p>";
                dr.Close();
                con.Close();
            }
            else
            {
                rerr.Visible = true;
            }

        }
        catch (Exception ex)
        {
            CreateLogFile log = new CreateLogFile();
            log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Page load method of NewsRead page for " + Session["loginname"] + ":" + ex.Message);
        }
    }
    protected void loadDataToExerciseTable()
    {
        thColorStyle.BackColor = System.Drawing.ColorTranslator.FromHtml("#d9534f");
        trColorSytle.BackColor = System.Drawing.ColorTranslator.FromHtml("#343a40");
        try
        {
            connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();
            conn             = new MySql.Data.MySqlClient.MySqlConnection(connectionString);
            conn.Open();

            String query = "SELECT * FROM webapppersonalfit.trainer";
            cmd    = new MySql.Data.MySqlClient.MySqlCommand(query, conn);
            reader = cmd.ExecuteReader();

            while (reader.HasRows && reader.Read())
            {
                String trainerID   = reader.GetString(reader.GetOrdinal("userID"));
                String trainerName = reader.GetString(reader.GetOrdinal("name"));
                String cardTitle   = reader.GetString(reader.GetOrdinal("name"));
                String cardContent = reader.GetString(reader.GetOrdinal("short_intro"));
                String picUrl      = reader.GetString(reader.GetOrdinal("url_pic"));
                addCardOntoPlaceHolder(trainerID, trainerName, cardTitle, cardContent, picUrl);
            }
            reader.Close();
            conn.Close();
        }
        catch (Exception e)
        {
            //passwordTextBox.Value = e.ToString();
        }
    }
        private void DoSQLQueryPieBanque()
        {
            try
            {
                String connString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();
                conn = new MySql.Data.MySqlClient.MySqlConnection(connString);



                conn.Open();
                queryStr = "";
                queryStr = "SELECT * FROM database.detail WHERE detail.titre='Solde banque'";
                cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
                reader   = cmd.ExecuteReader();

                while (reader.HasRows && reader.Read())
                {
                    BIATD = reader.GetInt32(reader.GetOrdinal("t1"));
                    BIATE = reader.GetInt32(reader.GetOrdinal("t2"));
                    STB   = reader.GetInt32(reader.GetOrdinal("t3"));
                }



                reader.Close();
                conn.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        // retorna o valor da Id para salvar os dados e manter a referencia do sumario
        public int BuscarIdSumario(int IdPlano)
        {
            try
            {
                string QueryPesquisarIdSumario = "select * from sumarioexecutivo where id_Plano=@IdPlano;";
                int idSumario=0;

                Dal.ConectarBanco();
                ComandoPesquisarIdSumario = new MySqlCommand(QueryPesquisarIdSumario);
                ComandoPesquisarIdSumario.Connection = Dal.Conn;
                ComandoPesquisarIdSumario.Parameters.AddWithValue("@IdPlano", IdPlano);

                ConsultarIdSumario = ComandoPesquisarIdSumario.ExecuteReader();
                while (ConsultarIdSumario.Read())
                {
                    idSumario = int.Parse(ConsultarIdSumario["id"].ToString());
                }
                return idSumario;

            }
            catch
            {
              int idSumario = 0;
              return idSumario;

            }
            finally
            {
                ConsultarIdSumario.Close();
                Dal.FecharConexao();
            }
        }
Ejemplo n.º 36
0
        private void DoSQLAffiche1()
        {
            try
            {
                String connString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();
                conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
                conn.Open();
                queryStr = "";
                queryStr = "SELECT * FROM database.event WHERE event.iduser='******' AND event.idex='2'";
                cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
                reader   = cmd.ExecuteReader();

                while (reader.HasRows && reader.Read())
                {
                    namec1      = reader.GetString(reader.GetOrdinal("name"));
                    monthstart1 = reader.GetInt32(reader.GetOrdinal("monthstart"));
                    yearstart1  = reader.GetInt32(reader.GetOrdinal("yearstart"));
                    daystart1   = reader.GetInt32(reader.GetOrdinal("daystart"));
                    yearend1    = reader.GetInt32(reader.GetOrdinal("yearend"));
                    monthend1   = reader.GetInt32(reader.GetOrdinal("monthend"));
                    dayend1     = reader.GetInt32(reader.GetOrdinal("dayend"));
                    hstart1     = reader.GetInt32(reader.GetOrdinal("hstart"));
                    hend1       = reader.GetInt32(reader.GetOrdinal("hend"));
                    minstart1   = reader.GetInt32(reader.GetOrdinal("minstart"));
                    minend1     = reader.GetInt32(reader.GetOrdinal("minend"));
                }
                Labelnamec1.Text = namec1;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            reader.Close();
            conn.Close();
        }
Ejemplo n.º 37
0
        protected void LoginUser(object sender, EventArgs e)
        {
            string connectionString = @"Data Source=db4free.net; Database=centresportif420; user=centresportif420; password=stephane420;";

            using (MySqlConnection cn = new MySqlConnection(connectionString))
            {
                cn.Open();
                queryStr = "SELECT * FROM centresportif420.personne WHERE codebarre='" + Server.HtmlEncode(((TextBox)(Login1.FindControl("UserName"))).Text) + "' AND motdepasse='" + Server.HtmlEncode(((TextBox)(Login1.FindControl("Password"))).Text) + "'";
                cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, cn);
                reader   = cmd.ExecuteReader();
                name     = "";
                while (reader.HasRows && reader.Read())
                {
                    name                  = reader.GetString(reader.GetOrdinal("nom"));
                    role                  = reader.GetString(reader.GetOrdinal("role"));
                    idpersonne            = reader.GetString(reader.GetOrdinal("idpersonne"));
                    Session["idpersonne"] = idpersonne;
                    Session["urole"]      = role;
                }
                if (reader.HasRows)
                {
                    Session["uname"]      = name;
                    Response.BufferOutput = true;
                    Response.Redirect("~/Account/Membre.aspx", false);
                    FormsAuthentication.SetAuthCookie(Server.HtmlEncode(((TextBox)(Login1.FindControl("UserName"))).Text), true);
                }
                else
                {
                    Response.Redirect("~/Account/Login.aspx", false);
                }
                reader.Close();
                cn.Close();
            }
        }
Ejemplo n.º 38
0
    protected void Page_Load(object sender, EventArgs e)
    {
        topics_ids = new ArrayList();

        dbConnection = new MySqlConnection(ConfigurationManager.AppSettings["ConnectionString"].ToString());
        dbConnection.Open();

        slctTopics = new MySqlCommand("SELECT t_id FROM topics", dbConnection);
        dReaderTopics = slctTopics.ExecuteReader();

        while (dReaderTopics.Read())
        {
            topics_ids.Add(dReaderTopics[0].ToString());
            counter++;
        }

        dReaderTopics.Close();
        slctTopics.Dispose();

        while (i < counter)
        {
            updtTopicsNumberOfVideos = new MySqlCommand("UPDATE topics SET t_nb_videos=(SELECT count(*) FROM videos WHERE t_id=" + topics_ids[i].ToString() + ") WHERE t_id=" + topics_ids[i].ToString(), dbConnection);
            updtTopicsNumberOfVideos.ExecuteNonQuery();
            updtTopicsNumberOfVideos.Dispose();
            i++;
        }
    }
Ejemplo n.º 39
0
 public int Login(TextBox utilizador, TextBox password)
 {
     Conetar();
     int valor = 0;
     string query = "SELECT * FROM conta WHERE utilizador='" + utilizador.Text + "' AND password='******';";
     _cmdDataBase = new MySqlCommand(query, _conDataBase);
     try
     {
         _conDataBase.Open();
         _myReader = _cmdDataBase.ExecuteReader();
         while (_myReader.Read())
         {
         }
         if (_myReader.HasRows)
         {
             MessageBox.Show("Login Correto");
             valor = 1;
         }
         else
         {
             MessageBox.Show("Login Incorreto! Volte a Introduzir as suas Credenciais");
             valor = 0;
         }
         _myReader.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     return valor;
 }
        //funcionando
        public int BuscarIdPlanoDeMarketing(int IdPlano)
        {
            try
            {
                string QueryPesquisarIdSumario = "select * from planodemarketing where id_Plano=@IdPlano;";
                int idSumario = 0;

                Dal.ConectarBanco();
                ComandoPesquisarIdPlanoDeMarketing = new MySqlCommand(QueryPesquisarIdSumario);
                ComandoPesquisarIdPlanoDeMarketing.Connection = Dal.Conn;
                ComandoPesquisarIdPlanoDeMarketing.Parameters.AddWithValue("@IdPlano", IdPlano);

                ReaderPEsquisarIdPlanoDeMarketing = ComandoPesquisarIdPlanoDeMarketing.ExecuteReader();
                while (ReaderPEsquisarIdPlanoDeMarketing.Read())
                {
                    idSumario = int.Parse(ReaderPEsquisarIdPlanoDeMarketing["id"].ToString());
                }
                return idSumario;

            }
            catch
            {
                int idSumario = 0;
                return idSumario;

            }
            finally
            {
                ReaderPEsquisarIdPlanoDeMarketing.Close();
                Dal.FecharConexao();
            }
        }
Ejemplo n.º 41
0
    public void ChangeReviewSummary()
    {
        Transform starPanel  = reviewSummaryPanel.GetChild(1);
        Transform scorePanel = reviewSummaryPanel.GetChild(2);

        //string sql = "SELECT COUNT(*), AVG(CAST(score as FLOAT)) FROM review GROUP BY productID HAVING productID = " + product.id + ";";
        string sql = "SELECT COUNT(*), AVG(score) FROM review GROUP BY productID HAVING productID = " + product.id + ";";

        MySql.Data.MySqlClient.MySqlDataReader reader = DbConnecter.instance.Reader(sql);
        int   reviewer = 0;
        float score    = 0;

        if (reader.Read())
        {
            reviewer = reader.GetInt32(0);
            score    = (float)reader.GetDouble(1);
        }
        reader.Close();
        DbConnecter.instance.CloseConnection();
        for (int i = 0; i < 5; i++)
        {
            float fillAmount = Mathf.Clamp(score - i, 0, 1);
            Image yellowStar = starPanel.GetChild(i).GetChild(0).GetComponent <Image>();
            yellowStar.fillAmount = fillAmount;
        }
        Text scoreText = scorePanel.GetChild(0).GetComponent <Text>();

        scoreText.text = score.ToString("0.00") + " (" + reviewer + ")";
    }
Ejemplo n.º 42
0
        public List <string> ChatGetUsername()
        {
            //string chatInfo;
            String connString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ConnectionString;

            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            try
            {
                conn.Open();
                MySqlCommand  cmd       = new MySqlCommand(queryString, conn);
                List <string> storeDate = new List <string>();
                queryString     = "SELECT username FROM dububase.chat";
                cmd.CommandText = queryString;
                cmd             = new MySql.Data.MySqlClient.MySqlCommand(queryString, conn);
                reader          = cmd.ExecuteReader();
                while (reader.HasRows && reader.Read())
                {
                    storeDate.Add((reader["username"].ToString()));
                }
                return(storeDate);
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                string errorMsg = "Error";
                errorMsg += ex.Message;
                throw new Exception(errorMsg);
            }
            finally
            {
                reader.Close();
                conn.Close();
            }
        }
Ejemplo n.º 43
0
        // This is used for saving the messages to the database.
        // The messages need to have correct userIDs - used to establish who sent them - and correct caseIdDs - used to establish which case the message belongs to.
        public String[] getUserIDcaseID()
        {
            // Array is tidier than multiple strings, make use of indexes.
            String[] IDs = new String[2];
            IDs[0] = uID; // Populated with the Session method during Page_Load - no need to query DB for this.

            String connString = System.Configuration.ConfigurationManager.ConnectionStrings["projectConnectionString"].ToString();

            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();

            queryStr = "";

            // Use case_name to obtain case ID from the allcases table.
            queryStr = "SELECT case_id FROM project.allcases WHERE case_name=?cname";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
            cmd.Parameters.AddWithValue("?cname", case_name);

            reader = cmd.ExecuteReader();
            while (reader.HasRows && reader.Read())
            {
                // Grab caseID.
                IDs[1] = reader.GetString(reader.GetOrdinal("case_id"));
            }
            reader.Close();
            // Return the array, therefore method can be called and assigned to varaible due to return - efficient.
            return(IDs);
        }
    protected void selectthegrp(object sender, EventArgs e)
    {
        string clsid      = (String)Session["clsid"];
        string tgrpid     = "grp_" + clsid;
        Int32  mygrp      = Convert.ToInt32(grpnumber.Text);
        int    stuid      = (Int32)Session["stuid"];
        String connstring = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConString"].ToString();

        connectiong = new MySql.Data.MySqlClient.MySqlConnection(connstring);
        connectiong.Open();
        querystr1 = "select count(*) from " + tgrpid + " where groupid=" + mygrp + "";
        cmd       = new MySql.Data.MySqlClient.MySqlCommand(querystr1, connectiong);
        long  check  = (long)cmd.ExecuteScalar();
        Int32 checks = Convert.ToInt32(check);

        if (checks < 6)
        {
            querystr = "update " + tgrpid + " set groupid='" + mygrp + "' where uhclid=" + stuid + "";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(querystr, connectiong);
            reader   = cmd.ExecuteReader();
            reader.Close();
            Int32 num = Convert.ToInt32(grpnumber.Text);
            show.Text = "Your group number is " + num;
        }
        else
        {
            show.Text = "The maximum limit of group is only 6..Please select other group!!";
        }
    }
Ejemplo n.º 45
0
        private void DoSQLQuery1()
        {
            try
            {
                String connString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();
                conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
                conn.Open();
                queryStr = "";
                queryStr = "SELECT * FROM database.tbl_user WHERE tbl_user.id='" + Session["Id"] + "' ";
                cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
                reader   = cmd.ExecuteReader();
                while (reader.HasRows && reader.Read())
                {
                    education    = reader.GetString(reader.GetOrdinal("education"));
                    localisation = reader.GetString(reader.GetOrdinal("localisation"));
                }

                if (reader.HasRows)
                {
                    // Session["uname"] = name;

                    //  userName = (String)(Session["utname"]);
                    //    Label14.Text = userName;
                    LabelEducation.Text = education;
                    LabelLocation.Text  = localisation;
                }

                reader.Close();
                conn.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 46
0
       //when check name and password, get the user's information
       public PropertyClass CheckNameAndPasswd(string name,string password)
       {
           PropertyClass accountClass=null;


       string strSql="select * from account where accountName='"+name.Trim()+"' and accountPassword='******'";
        try{
           sdr=db.GetDataReader(strSql);
            sdr.Read();
            if(sdr.HasRows)
            {
            accountClass=new PropertyClass();
            accountClass.UserId=sdr.GetInt32("id");
            accountClass.AccountName=name.Trim();
            accountClass.AccountPassword=password.Trim();
            accountClass.Email=sdr["email"].ToString();
            accountClass.Job=sdr.GetInt32("job");;
            accountClass.Superviser=sdr.GetInt32("superviser");
            }
        }
           catch(Exception ex)
        {
           
          }
        finally
        {
            sdr.Close();
        }
          return accountClass; 
      
       }
Ejemplo n.º 47
0
		public System.Data.DataTable DataReaderToDataTable(MySqlDataReader Reader)
		{
			System.Data.DataTable dt = new System.Data.DataTable();
			System.Data.DataColumn dc;
			System.Data.DataRow dr;
			ArrayList arr = new ArrayList();
			int i;

			for(i=0;i<Reader.FieldCount;i++)
			{
				dc = new System.Data.DataColumn();

				dc.ColumnName = Reader.GetName(i);					
				arr.Add(dc.ColumnName);

				dt.Columns.Add(dc);
			}
			
			while(Reader.Read())
			{
				dr = dt.NewRow();

				for (i=0;i<Reader.FieldCount;i++)
				{
					dr[(string)arr[i]] = Reader[i].ToString();
				}
				dt.Rows.Add(dr);
			}

			Reader.Close();
			return dt;
		}
Ejemplo n.º 48
0
        private void ReviewRecipeData(String recId)
        {
            ///Get recipe data from database by recipe id
            try
            {
                CheckStateDB();
                String sql_get = "SELECT recipe_name, detail, materialCode FROM recipe WHERE recipe_id = @recipe_id";
                cmd = new MySqlCommand(sql_get, conn);
                cmd.Parameters.AddWithValue("@recipe_id", recId);
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    this.recipeName.Text = reader.GetString("recipe_name");
                    this.recipeDetail.Text = reader.GetString("detail");
                    this.recipeMaterial.Text = reader.GetString("materialCode");
                }
                reader.Close();

            }
            catch (Exception e)
            {
                ErrorLogCreate(e);
                MessageBox.Show("เกิดข้อผิดพลาด ข้อมูล error บันทึกอยู่ในไฟล์ log กรุณาแจ้งข้อมูลดังกล่าวแก่ทีมติดตั้ง"
                                    , "ข้อผิดพลาด", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Ejemplo n.º 49
0
        public bool deletePerson(long ID)
        {
            bool recordDeleted = false;

            MySql.Data.MySqlClient.MySqlDataReader mySqlReader = null;
            string sqlString = "SELECT * from tbl_personnel where ID = " + ID.ToString();
            var    cmd       = new MySql.Data.MySqlClient.MySqlCommand(sqlString, conn);

            try
            {
                mySqlReader = cmd.ExecuteReader();
                if (mySqlReader.Read())
                {
                    mySqlReader.Close();
                    sqlString = "DELETE FROM tbl_personnel where ID = " + ID.ToString();
                    cmd       = new MySql.Data.MySqlClient.MySqlCommand(sqlString, conn);
                    cmd.ExecuteNonQuery();
                    recordDeleted = true;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("SQL Exception in Delete");
                Console.WriteLine(ex);
                Console.WriteLine(ex.Data);
            }
            return(recordDeleted);
        }
Ejemplo n.º 50
0
        //When Login has been Pressed
        protected void SubmitEventMethod(object sender, EventArgs e)
        {
            string username = Username.Text;
            string pass     = Password.Text;

            query = "SELECT * FROM 17agileteam6db.users WHERE staff_no ='" + username + "' AND pass = '******';"; //checks user name and password
            DB db = new DB();

            reader = db.Select(query);

            while (reader.HasRows && reader.Read())
            {
                Session["role"]      = reader.GetString(reader.GetOrdinal("role"));
                Session["firstName"] = reader.GetString(reader.GetOrdinal("first_name"));
                Session["lastName"]  = reader.GetString(reader.GetOrdinal("last_name"));
            }

            if (reader.HasRows)
            {
                Session["loggedin"]   = "Loggedin";
                Session["StaffNo"]    = Username.Text;
                Response.BufferOutput = true;
                Response.Redirect("Index.aspx", false);
            }
            else
            {
                //If username and password not found return false
                Session["failed"] = "failed";
                Response.Redirect("Login.aspx", false);
            }
            reader.Close();
        }
Ejemplo n.º 51
0
 private void RetreiveProduct()
 {
     ///Get product list from database
     try
     {
         CheckStateDB();
         String sqlGet = "SELECT product_id FROM product";
         cmd = new MySqlCommand(sqlGet, conn);
         reader = cmd.ExecuteReader();
         if (reader.HasRows == false)
         {
             throw new Exception("No row were found!");
         }
         else
         {
             while (reader.Read())
             {
                 this.prodList.Items.Add(reader.GetString("product_id"));
             }
         }
         reader.Close();
     }
     catch (Exception ex)
     {
         ErrorLogCreate(ex);
         LockWindow(true);
     }
 }
Ejemplo n.º 52
0
        public bool UpdatePatient(long id, PatientInfo patientToSave)
        {
            MySql.Data.MySqlClient.MySqlConnection conn;
            conn = new MySql.Data.MySqlClient.MySqlConnection();

            try
            {
                conn.ConnectionString = myConnectionString;
                conn.Open();

                MySql.Data.MySqlClient.MySqlDataReader mySQLReader = null;

                //Get The Patient with that ID (For Deleting)
                String sqlString = "SELECT * FROM patientinfo WHERE patientid = " + id.ToString();
                MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(sqlString, conn);

                mySQLReader = cmd.ExecuteReader();

                if (mySQLReader.Read())
                {
                    mySQLReader.Close();

                    // Delete the Patient with the id that was found
                    sqlString = "UPDATE patientinfo" +
                                " SET firstname='" + patientToSave.Firstname + "'," +
                                " lastname='" + patientToSave.Lastname + "'," +
                                " primarydoctor='" + patientToSave.PrimaryDoctor + "'," +
                                " secondarydoctor='" + patientToSave.SecondaryDoctor + "'," +
                                " phonenumber='" + patientToSave.PhoneNumber + "'," +
                                " street='" + patientToSave.Street + "'," +
                                " number='" + patientToSave.Number + "'," +
                                " postalcode='" + patientToSave.PostalCode + "'," +
                                " city='" + patientToSave.City + "'," +
                                " emergencycontact='" + patientToSave.EmergencyContact + "'," +
                                " emergencycontactphone='" + patientToSave.EmergencyContactPhone + "'," +
                                " sex='" + patientToSave.Sex + "'," +
                                " weight='" + patientToSave.Weight + "'," +
                                " height='" + patientToSave.Height + "'," +
                                " department='" + patientToSave.Department + "'" +
                                " WHERE patientid = " + id.ToString();

                    cmd = new MySql.Data.MySqlClient.MySqlCommand(sqlString, conn);
                    cmd.ExecuteNonQuery();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
Ejemplo n.º 53
0
        private void AffichageAreaChart()
        {
            try
            {
                String connString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();
                conn = new MySql.Data.MySqlClient.MySqlConnection(connString);


                conn.Open();
                queryStr = "";

                queryStr = "SELECT * FROM database.moy_age WHERE moy_age.id='1' ";
                cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
                reader   = cmd.ExecuteReader();

                while (reader.HasRows && reader.Read())
                {
                    t20 = reader.GetInt32(reader.GetOrdinal("t20"));
                    t21 = reader.GetInt32(reader.GetOrdinal("t21"));
                    t22 = reader.GetInt32(reader.GetOrdinal("t22"));
                    t23 = reader.GetInt32(reader.GetOrdinal("t23"));
                    t24 = reader.GetInt32(reader.GetOrdinal("t24"));
                    t25 = reader.GetInt32(reader.GetOrdinal("t25"));
                    t26 = reader.GetInt32(reader.GetOrdinal("t26"));
                    t27 = reader.GetInt32(reader.GetOrdinal("t27"));
                    t28 = reader.GetInt32(reader.GetOrdinal("t28"));
                    t29 = reader.GetInt32(reader.GetOrdinal("t29"));
                    t30 = reader.GetInt32(reader.GetOrdinal("t30"));
                    t31 = reader.GetInt32(reader.GetOrdinal("t31"));
                    t32 = reader.GetInt32(reader.GetOrdinal("t32"));
                    t33 = reader.GetInt32(reader.GetOrdinal("t33"));
                    t34 = reader.GetInt32(reader.GetOrdinal("t34"));
                    t35 = reader.GetInt32(reader.GetOrdinal("t35"));
                    t36 = reader.GetInt32(reader.GetOrdinal("t36"));
                    t37 = reader.GetInt32(reader.GetOrdinal("t37"));
                    t38 = reader.GetInt32(reader.GetOrdinal("t38"));
                    t39 = reader.GetInt32(reader.GetOrdinal("t39"));
                    t40 = reader.GetInt32(reader.GetOrdinal("t40"));
                    t41 = reader.GetInt32(reader.GetOrdinal("t41"));
                    t42 = reader.GetInt32(reader.GetOrdinal("t42"));
                    t43 = reader.GetInt32(reader.GetOrdinal("t43"));
                    t44 = reader.GetInt32(reader.GetOrdinal("t44"));
                    t45 = reader.GetInt32(reader.GetOrdinal("t45"));
                    t46 = reader.GetInt32(reader.GetOrdinal("t46"));
                    t47 = reader.GetInt32(reader.GetOrdinal("t47"));
                    t48 = reader.GetInt32(reader.GetOrdinal("t48"));
                    t49 = reader.GetInt32(reader.GetOrdinal("t49"));
                    t50 = reader.GetInt32(reader.GetOrdinal("t50"));
                }



                reader.Close();
                conn.Close();
            }catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 54
0
        private void LoginWithPasswordHashFunction()
        {
            List <String> salthashList = null;
            List <String> namesList    = null;

            try
            {
                String connString = System.Configuration.ConfigurationManager.ConnectionStrings["projectConnectionString"].ToString();

                conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
                conn.Open();
                querystr = "SELECT `slowHashSalt`, `first_name`, `last_name`, `user_id` FROM `project`.`client` WHERE username=?uname";

                cmd = new MySql.Data.MySqlClient.MySqlCommand(querystr, conn);
                cmd.Parameters.AddWithValue("?uname", usernametextbox.Text);
                reader = cmd.ExecuteReader();

                while (reader.HasRows && reader.Read())
                {
                    if (salthashList == null)
                    {
                        salthashList = new List <String>();
                        namesList    = new List <String>();
                    }
                    String saltHashes = reader.GetString(reader.GetOrdinal("slowHashSalt"));
                    salthashList.Add(saltHashes);

                    String fullname = reader.GetString(reader.GetOrdinal("first_name")) + " " + reader.GetString(reader.GetOrdinal("last_name"));
                    namesList.Add(fullname);

                    user_id = reader.GetString(reader.GetOrdinal("user_id"));
                }
                reader.Close();
                //check to see whether the results from the query are empty
                if (salthashList != null)
                {
                    for (int i = 0; i < salthashList.Count; i++)
                    {
                        querystr = "";
                        bool ValidUser = PasswordHash.ValidatePassword(userpasswordtextbox.Text, salthashList[i]);
                        if (ValidUser == true)
                        {
                            Session["uname"]      = namesList[i];
                            Session["user_id"]    = user_id;
                            Response.BufferOutput = true;
                            Response.Redirect("LoggedIn.aspx", false);
                        }
                        else
                        {
                            userpasswordtextbox.Text = "User not authenticated";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                userpasswordtextbox.Text = ex.ToString();
            }
        }
Ejemplo n.º 55
0
 private static void forceCloserReader()
 {
     try
     {
         reader.Close();
     }
     catch { };
 }
        protected void DoSQLCountLike(object sender, EventArgs e)
        {
            try
            {
                String connString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();
                conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
                conn.Open();
                String queryStr = "";

                queryStr = "SELECT id FROM database.metadata WHERE metadata.codeuser='******'  ";
                cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
                reader   = cmd.ExecuteReader();

                while (reader.HasRows && reader.Read())
                {
                    idmetadata3 = reader.GetInt32(reader.GetOrdinal("id"));
                }
                reader.Close();



                String queryStr3;
                idLike    = 0;
                queryStr3 = "";
                queryStr3 = "SELECT id FROM database.like WHERE like.idmetadata='" + idmetadata3 + "' AND like.iduser='******'  ";
                cmd       = new MySql.Data.MySqlClient.MySqlCommand(queryStr3, conn);
                reader    = cmd.ExecuteReader();

                while (reader.HasRows && reader.Read())
                {
                    idLike = reader.GetInt32(reader.GetOrdinal("id"));
                }
                reader.Close();



                if (idLike == 0)
                {
                    String queryStr2 = "";

                    queryStr2 = "INSERT INTO database.like (iduser,idmetadata)VALUES('" + Session["Id"] + "','" + idmetadata3 + "')";

                    cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr2, conn);

                    cmd.ExecuteNonQuery();
                }



                conn.Close();
                DoSQLQueryyIm();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Ejemplo n.º 57
0
        private void DoSQLQueryy()
        {
            try
            {
                String connString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();
                conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
                conn.Open();
                queryStr = "";
                queryStr = "SELECT * FROM database.tb WHERE tb.codeuser='******'";
                cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
                reader   = cmd.ExecuteReader();
                z01      = "";
                z02      = "";
                z03      = "";
                z04      = "";
                z05      = "";
                z06      = "";
                z07      = "";
                z08      = "";
                z09      = "";
                z10      = "";
                while (reader.HasRows && reader.Read())
                {
                    z01 = reader.GetString(reader.GetOrdinal("z01"));
                    z02 = reader.GetString(reader.GetOrdinal("z02"));
                    z03 = reader.GetString(reader.GetOrdinal("z03"));
                    z04 = reader.GetString(reader.GetOrdinal("z04"));
                    z05 = reader.GetString(reader.GetOrdinal("z05"));
                    z06 = reader.GetString(reader.GetOrdinal("z06"));
                    z07 = reader.GetString(reader.GetOrdinal("z07"));
                    z08 = reader.GetString(reader.GetOrdinal("z08"));
                    z09 = reader.GetString(reader.GetOrdinal("z09"));
                    z10 = reader.GetString(reader.GetOrdinal("z10"));
                }
                if (reader.HasRows)
                {
                    LabelT1.Text  = z01;
                    LabelT2.Text  = z02;
                    LabelT3.Text  = z03;
                    LabelT4.Text  = z04;
                    LabelT5.Text  = z05;
                    LabelT6.Text  = z06;
                    LabelT7.Text  = z07;
                    LabelT8.Text  = z08;
                    LabelT9.Text  = z09;
                    LabelT10.Text = z10;
                    LabelZ04.Text = z04;
                }

                reader.Close();
                conn.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 58
0
    private void qrScanFinished(string dataText)
    {
        if (isOpenBrowserIfUrl)
        {
            if (Utility.CheckIsUrlFormat(dataText))
            {
                if (!dataText.Contains("http://") && !dataText.Contains("https://"))
                {
                    dataText = "http://" + dataText;
                }
                Application.OpenURL(dataText);
            }
        }
        if (this.UiText != null)
        {
            this.UiText.text = dataText;
        }
        if (this.resetBtn != null)
        {
            this.resetBtn.SetActive(true);
        }
        if (this.scanLineObj != null)
        {
            this.scanLineObj.SetActive(false);
        }
        if (dataText.Length == 13)
        {
            string sql = "SELECT * FROM product WHERE barcode='" + dataText + "';";
            MySql.Data.MySqlClient.MySqlDataReader reader = DbConnecter.instance.Reader(sql);
            if (reader.Read())
            {
                Product product = new Product();
                product.id          = reader.GetInt32(0);
                product.name        = reader.GetString(1);
                product.barcode     = reader.GetString(2);
                product.company     = reader.GetString(3);
                product.category    = product.koreanToCategory(reader.GetString(4));
                product.ingredients = reader.GetString(5);
                product.imagePath   = reader.GetString(6);

                reader.Close();
                DbConnecter.instance.CloseConnection();
                Stop();
                Panels.instance.productInfoPanel.gameObject.SetActive(true);
                Panels.instance.productInfoPanel.PanelOn(product, Panels.instance.homePanel.gameObject);
            }
            else if (this.isNullPanel != null)
            {
                isNullPanel.SetActive(true);
                DbConnecter.instance.CloseConnection();
            }
        }
        else if (this.isNullPanel != null)
        {
            isNullPanel.SetActive(true);
        }
    }
Ejemplo n.º 59
-1
 public bool IsNameExist(string name)
 {
 string strSql="select * from account where accountName='"+name.Trim()+"'";
     try{
         sdr=db.GetDataReader(strSql);
         sdr.Read();
         if(sdr.HasRows)
         {
           sdr.Close();
          return true;
         }
         else
         {
         sdr.Close();
         return false;
         }
      
     }
     catch(Exception e)
     {
     
     }
     finally
     {
     sdr.Close();
     }
     return true;
 }
Ejemplo n.º 60
-44
        public void add_date_firstDay(string date, int line, string first, string sec, string thi, string four, string fiv, string six, string sev, string eig, string nin, string ten, string ele,string twe)
        {
            DateTime dt = Convert.ToDateTime(date);
            //string connect = "datasource = 127.0.0.1; port = 3306;Connection Timeout=30; Min Pool Size=20; Max Pool Size=200;  username = root; password = ;";
            MySqlConnection conn = new MySqlConnection(connect);
            MySqlCommand sda = new MySqlCommand(@"insert into shedulling.tablelayout1 values
                    ('" + dt + "','" + line + "','" + first + "','" + sec + "','" + thi + "','" + four + "','" + fiv + "','" + six + "','" + sev + "','" + eig + "','" + nin + "','" + ten + "', '" + ele + "','"+twe+ "')", conn);

            MySqlDataReader reader;
            try
            {
                conn.Open();
                reader = sda.ExecuteReader();
                while (reader.Read())
                {

                }
                reader.Close();
                conn.Close();
                conn.Dispose();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            finally
            {
                if (conn != null && conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
        }