Inheritance: DbDataReader, IDataReader, IDisposable, IDataRecord
Exemple #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:
        }
 public static StatusFilmDTO readerToStatusFilmDTO(MySqlDataReader reader)
 {
     StatusFilmDTO status = new StatusFilmDTO();
     status.Id = reader.GetInt32("idStatusFilm");
     status.Naziv = reader["nazivStatusFilm"].ToString();
     return status;
 }
Exemple #3
0
        public dynamic GetUserBetPointsDetails(int userID)
        {
            oCon.Open();

            string fetchQuery = "SELECT * FROM view_userdetails WHERE UserID = " + userID;

            List <UserPointsModel> userbets = new List <UserPointsModel>();

            oMySQLData.MySqlCommand cmd = new oMySQLData.MySqlCommand(fetchQuery, oCon);
            cmd.ExecuteNonQuery();

            oMySQLData.MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                UserPointsModel userbet = new UserPointsModel();
                userbet.UserID           = Convert.ToInt32(reader["UserID"]);
                userbet.TournamentID     = Convert.ToInt32(reader["TournamentID"]);
                userbet.TotalPoints      = Convert.ToInt32(reader["TotalBetPoints"]);
                userbet.TournamentPoints = Convert.ToInt32(reader["TournamentPoints"]);

                userbets.Add(userbet);
            }

            oCon.Close();
            return(userbets);
        }
 protected Game GetGameFromDataReader(MySqlDataReader dataReader)
 {
     string gameNaam = dataReader.GetString("gamenaam");
     int gameId = dataReader.GetInt32("game_id");
     Game game = new Game { ID = gameId, Naam = gameNaam };
     return game;
 }
        public void findAll()
        {
            db = new Database();

            brands.Clear();

            brandQuery = new MySqlCommand();

            brandQuery.Connection = db.Connection();

            brandQuery.CommandText = "SELECT * FROM brand ORDER BY brandname ASC";

            this.brandResult = brandQuery.ExecuteReader();

            while (brandResult.Read())
            {
                if (!brandResult.IsDBNull(0))
                {
                    idbrand = brandResult.GetInt32(0);
                }

                if (!brandResult.IsDBNull(1))
                {
                    brandname = brandResult.GetString(1);
                }

                brands.Add(new Brand { idbrand = this.idbrand, brandname = this.brandname});
            }

            db.Close();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string pwss = textBox1.Text.ToString();
            string confirm = textBox2.Text.ToString();
            if (pwss == confirm)
            {
                if (this.textBox3.Text.ToString() == usuario_activo.pw)
                {
                    sentenciaSQL = "UPDATE sql28127.usuarios SET pw='" + this.textBox2.Text + "' where id_usuario= '" + usuario_activo.id + "' ;";
                    // sentenciaSQL = "UPDATE test.usuarios SET pw='" + this.textBox2.Text + "' where id_usuario= '" + usuario_activo.id + "' ;";
                    comando = new MySqlCommand(sentenciaSQL, conexion);
                    resultado = comando.ExecuteReader();
                    MessageBox.Show("Cambio completado", "Aceptado");
                    this.Close();

                    Form3 principal = new Form3();
                    principal.Show();
                }

                else
                {
                    MessageBox.Show("Tercer campo \"Repetir Contraseña\" erroneo", "ERROR");
                }

            }
            else
            {
                MessageBox.Show("Igualar Contraseñas", "ERROR");
            }
        }
 private static ContractType rdrParse(MySqlDataReader rdr)
 {
     return new ContractType {
         Id = rdr.GetInt32 ("id"),
         Name = rdr.GetString ("name")
     };
 }
Exemple #8
0
 private static void show(MySqlDataReader mysqlDataReader)
 {
     Console.WriteLine ();
     while (mysqlDataReader.Read()) {
         Console.WriteLine ("{0}         {1}", mysqlDataReader ["id"], mysqlDataReader ["nombre"]);
     }
 }
        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);
        }
        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);
            }
        }
        public ArrayList getCustomer()
        {
            ArrayList       CustomerArray = new ArrayList();
            MySqlConnection conn          = mysqlDbConnect.GetConnection();

            MySql.Data.MySqlClient.MySqlDataReader mySqlReade = null;
            String sqlString = "SELECT * FROM customer";

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

            while (mySqlReade.Read())
            {
                Customer p = new Customer();
                p.contactNo = mySqlReade.GetInt32(0);
                p.firstName = mySqlReade.GetString(1);
                p.lastName  = mySqlReade.GetString(2);
                p.email     = mySqlReade.GetString(3);
                p.address   = mySqlReade.GetString(4);
                p.password  = mySqlReade.GetString(5);
                CustomerArray.Add(p);
            }

            return(CustomerArray);
        }
        public Customer getCustomer(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())
            {
                p.contactNo = mySqlReade.GetInt32(0);
                p.firstName = mySqlReade.GetString(1);
                p.lastName  = mySqlReade.GetString(2);
                p.email     = mySqlReade.GetString(3);
                p.address   = mySqlReade.GetString(4);
                p.password  = mySqlReade.GetString(5);
                return(p);
            }

            else
            {
                return(null);
            }
        }
Exemple #13
0
        public Drink loadDrinkDetails(int drinkId)
        {
            Drink           p    = new Drink();
            MySqlConnection conn = mysqlDbConnect.GetConnection();

            MySql.Data.MySqlClient.MySqlDataReader mySqlReade = null;
            String sqlString = "SELECT * FROM drink WHERE drinkId='" + drinkId + "'";

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

            if (mySqlReade.Read())
            {
                p.drinkId    = mySqlReade.GetInt32(0);
                p.drinkName  = mySqlReade.GetString(1);
                p.drinkPrice = mySqlReade.GetInt32(2);

                return(p);
            }

            else
            {
                return(null);
            }
        }
Exemple #14
0
        public Food loadFoodDetails(int foodId)
        {
            Food            p    = new Food();
            MySqlConnection conn = mysqlDbConnect.GetConnection();

            MySql.Data.MySqlClient.MySqlDataReader mySqlReade = null;
            String sqlString = "SELECT * FROM food WHERE foodId='" + foodId + "'";

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

            if (mySqlReade.Read())
            {
                p.foodId    = mySqlReade.GetInt32(0);
                p.foodName  = mySqlReade.GetString(1);
                p.foodPrice = mySqlReade.GetInt32(2);

                return(p);
            }

            else
            {
                return(null);
            }
        }
        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);
            }
        }
        public List <Person> getPersons()
        {
            List <Person> personList = new List <Person>();

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

            try
            {
                mySqlReader = cmd.ExecuteReader();
                while (mySqlReader.Read())
                {
                    Person p = new Person();
                    p.ID        = mySqlReader.GetInt32(0);
                    p.FirstName = mySqlReader.GetString(1);
                    p.LastName  = mySqlReader.GetString(2);
                    p.PayRate   = mySqlReader.GetFloat(3);
                    p.StartDate = mySqlReader.GetDateTime(4);
                    p.EndDate   = mySqlReader.GetDateTime(5);
                    personList.Add(p);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("MySQL exception");
                Console.WriteLine(ex);
                Console.WriteLine(ex.Data);
            }
            return(personList);
        }
        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);
            }
        }
Exemple #18
0
 public static void show(MySqlDataReader mySqlDataReader)
 {
     // METODO QUE MUESTRA TODO EL CONETNIDO DE LA TABLA
     Console.WriteLine ("FILAS : ");													// EL SHOW MUESTRA EL SHOWROW (FILA). EL SHOWROW MUESTRA LA FILA
     while (mySqlDataReader.Read())
         showRow (mySqlDataReader);
 }
        protected void btn_show_Click(object sender, EventArgs e)
        {
            conn = new MySql.Data.MySqlClient.MySqlConnection(ConnString);
            conn.Open();
            try
            {
                cmd             = conn.CreateCommand();
                cmd.CommandText = "SELECT * FROM assigned_employee where reqid='" + tb_reqid.Text + "'";

                reader = cmd.ExecuteReader();
                //int x =reader.ro;
                //Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('COUNT IS '+'"+x+"');</script>");
                //("COUNT IS " + x);

                //DataTable dt = new DataTable();
                //dt.Load(reader);
                //int numberOfResults = dt.Rows.Count;
                //Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('COUNT IS '+'" + numberOfResults + "');</script>");
                //for (int z=0; z< numberOfResults; z++)
                //{
                while (reader.Read())
                {
                    tb_assignedto.Text = tb_assignedto.Text + reader.GetString("name") + "\n";
                }
                //}
            }
            catch { }
            conn.Close();
        }
Exemple #20
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;
		}
Exemple #21
0
        public static ArrayList MySQL_Column(string server, string username, string password, string database, string table, string port = "3306")
        {
            //Ip+端口+数据库名+用户名+密码
            string          connectStr = "server=" + server + ";port=" + port + ";database=information_schema" + ";user="******";password="******";";
            ArrayList       columns    = new ArrayList();
            MySqlConnection conn       = new MySqlConnection(connectStr);;

            try
            {
                conn.Open();//跟数据库建立连接,并打开连接
                string       sql = "select column_name from information_schema.columns where table_schema='" + database + "' and table_name='" + table + "'";
                MySqlCommand cmd = new MySqlCommand(sql, conn);
                MySql.Data.MySqlClient.MySqlDataReader msqlReader = cmd.ExecuteReader();
                while (msqlReader.Read())
                {   //do something with each record
                    columns.Add(msqlReader[0]);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                conn.Clone();
            }
            return(columns);
        }
Exemple #22
0
 public void InitFromData(MySqlDataReader reader)
 {
     Id = (int)reader["id"];
     Ip = (string)reader["ip"];
     Port = (int)reader["port"];
     Status = ServerStatusEnum.OFFLINE;
 }
Exemple #23
0
        public static ArrayList  MySQL_DateBase(string server, string username, string password, string port = "3306")
        {
            //Ip+端口+数据库名+用户名+密码
            string          connectStr = "server=" + server + ";port=" + port + ";database=information_schema" + ";user="******";password="******";";
            ArrayList       datebase   = new ArrayList();
            MySqlConnection conn       = new MySqlConnection(connectStr);;

            try
            {
                conn.Open();//跟数据库建立连接,并打开连接
                string       sql = "select schema_name from  information_schema.schemata";
                MySqlCommand cmd = new MySqlCommand(sql, conn);
                MySql.Data.MySqlClient.MySqlDataReader msqlReader = cmd.ExecuteReader();
                while (msqlReader.Read())
                {   //do something with each record
                    //  Console.WriteLine(" Datebase: " + msqlReader[0]);
                    if ((msqlReader[0].ToString() != "information_schema") && (msqlReader[0].ToString() != "mysql") && (msqlReader[0].ToString() != "performance_schema") && (msqlReader[0].ToString() != "sys"))
                    {
                        datebase.Add(msqlReader[0]);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                conn.Clone();
            }
            return(datebase);
        }
Exemple #24
0
        //管理员创建用户
        public int registUser(UserBean bean)
        {

            try
            {
                string selectSql = "select * from users as u where u.ACCOUNT='" + @bean.Account + "'";
                reade = MySqlHelper.ExecuteReader(MySqlHelper.Conn, CommandType.Text,selectSql, new MySqlParameter("@bean.Account", bean.Account));
                if (reade.Read()) return HAS;
                string pawMd = Session.MD5Encrypt(bean.Password);
                string sql = "insert into users(ACCOUNT,USER_NAME,TYPE,PASSWORD,STATUS,CREATE_ID,CREATE_TIME,PHONE) values('" +
                            @bean.Account + "','" + @bean.UserName + "'," + @bean.Type + ",'" + @pawMd + "'," + @bean.Status + "," +
                            @bean.CreateId + ",'" + @bean.CreateTime + "','"[email protected]+"')";
                MySqlParameter[] parameter = 
            {
                new MySqlParameter("@bean.Account",bean.Account),
                new MySqlParameter("@bean.UserName",bean.UserName),
                new MySqlParameter("@bean.Type",bean.Type),
                new MySqlParameter("@pawMd",pawMd),
                new MySqlParameter("@bean.Status",bean.Status),
                new MySqlParameter("@bean.CreateId",bean.CreateId),
                new MySqlParameter("@bean.CreateTime",bean.CreateTime.ToString("yyyy-MM-dd hh:mm:ss")),
                 new MySqlParameter("@bean.Phone",bean.Phone),
            };
                MySqlHelper.ExecuteNonQuery(MySqlHelper.Conn, CommandType.Text,sql, parameter);
            }
            catch (Exception e)
            {
                e.GetBaseException();
                return SYSTEM_EXCEPTION;
            }
            return SUCCESS;
        }
    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!!";
        }
    }
Exemple #26
0
        List <UserBetModel> GetUserBetList(int userID, int tournamentID)
        {
            oCon.Open();

            string fetchQuery = "SELECT * FROM view_userbetdetails WHERE fldBettorID = " + userID + " AND fldTournamentID = " + tournamentID;

            List <UserBetModel> bets = new List <UserBetModel>();

            oMySQLData.MySqlCommand cmd = new oMySQLData.MySqlCommand(fetchQuery, oCon);
            cmd.ExecuteNonQuery();

            oMySQLData.MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                UserBetModel bet = new UserBetModel();
                bet.BettorID     = Convert.ToInt32(reader["fldBettorID"]);
                bet.TournamentID = Convert.ToInt32(reader["fldTournamentID"]);
                bet.MatchID      = Convert.ToInt32(reader["fldMatchID"]);
                bet.TeamID       = Convert.ToInt32(reader["fldTeamBetID"]);
                bet.PlaceBet     = Convert.ToInt32(reader["fldPlaceBetPoints"]);

                bets.Add(bet);
            }

            oCon.Close();
            return(bets);
        }
        // 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);
        }
Exemple #28
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();
            }
        }
        public getSingleDept oneProgID(string als)
        {
            MySql.Data.MySqlClient.MySqlConnection conn;
            string feashConn;

            feashConn = ConfigurationManager.ConnectionStrings["localDB"].ConnectionString;
            conn      = new MySql.Data.MySqlClient.MySqlConnection();
            try
            {
                conn.ConnectionString = feashConn;
                conn.Open();
                getSingleDept d = new getSingleDept();
                MySql.Data.MySqlClient.MySqlDataReader getReader = null;
                string getString = "SELECT * FROM Dept_ProgramID WHERE DeptProgramID = '" + als.ToString() + "';";
                MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(getString, conn);
                getReader = cmd.ExecuteReader();
                if (getReader.Read())
                {
                    d.DName = getReader.IsDBNull(0) == false?getReader.GetString(0) : null;

                    d.DEntity = getReader.IsDBNull(1) == false?getReader.GetString(1) : null;

                    d.ProgramID = getReader.IsDBNull(2) == false?getReader.GetString(2) : null;

                    return(d);
                }
                else
                {
                    return(null);
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            { throw ex; }
            finally { conn.Close(); }
        }
Exemple #30
0
        public Values getValues(int id)
        {
            Values v = new Values();

            MySql.Data.MySqlClient.MySqlDataReader mySQLReader = null;
            string sqlString = $"SELECT * FROM Products WHERE id ={id}";

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

            if (mySQLReader.Read())
            {
                v.id             = mySQLReader.GetInt32(0);
                v.product_name   = mySQLReader.GetString(1);
                v.stock_quantity = mySQLReader.GetInt32(2);
                v.des_box        = mySQLReader.GetString(3);
                v.URL            = mySQLReader.GetString(4);
                v.categories     = mySQLReader.GetString(5);
                return(v);
            }
            else
            {
                return(null);
            }
        }
        //private MySql.Data.MySqlClient.MySqlConnection conn;

        /*public DepartmentPersistence()
         * {
         *  string feashConn;
         *  feashConn = "server=localhost;port=3306;database=fea_starhub;username=root;password=135246;";
         *  try
         *  {
         *      conn = new MySql.Data.MySqlClient.MySqlConnection();
         *      conn.ConnectionString = feashConn;
         *      conn.Open();
         *  }
         *  catch (MySql.Data.MySqlClient.MySqlException ex)
         *  { throw ex; }
         * }*/

        public ArrayList allDepts()
        {
            MySql.Data.MySqlClient.MySqlConnection conn;
            string feashConn;

            feashConn = ConfigurationManager.ConnectionStrings["localDB"].ConnectionString;
            conn      = new MySql.Data.MySqlClient.MySqlConnection();
            try
            {
                conn.ConnectionString = feashConn;
                conn.Open();
                ArrayList d = new ArrayList();
                MySql.Data.MySqlClient.MySqlDataReader getReader = null;
                string getString = "SELECT * FROM Dept_ProgramID;";
                MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(getString, conn);
                getReader = cmd.ExecuteReader();
                while (getReader.Read())
                {
                    getSingleDept adept = new getSingleDept();
                    adept.DName = getReader.IsDBNull(0) == false?getReader.GetString(0) : null;

                    adept.DEntity = getReader.IsDBNull(1) == false?getReader.GetString(1) : null;

                    adept.ProgramID = getReader.IsDBNull(2) == false?getReader.GetString(2) : null;

                    d.Add(adept);
                }
                return(d);
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            { throw ex; }
            finally { conn.Close(); }
        }
        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);
        }
Exemple #33
0
 public override void FillFields(MySqlDataReader reader)
 {
     EventId = (long)reader["EventId"];
     EventTime = (long)reader["EventTime"];
     EventName = (Logger.EventLogNames)Enum.Parse(typeof(Logger.EventLogNames), reader["EventName"].ToString());
     EventData = reader["EventData"].ToString();
 }
Exemple #34
0
        public static void PopulateListView(ListView lst, String strQuery)
        {
            ListViewItem lstItem = null;
            int x;

            lst.Items.Clear();

            conn.Open();
            comm.Connection = conn;
            comm.CommandText = strQuery;
            reader = comm.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    lstItem = lst.Items.Add(reader.GetValue(0).ToString());
                    for (x = 1; x < reader.FieldCount; x++)
                    {
                        lstItem.SubItems.Add(reader.GetValue(x).ToString());
                    }
                }
            }
            conn.Close();
        }
Exemple #35
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();
            }
        }
Exemple #36
0
        private static void showColumNames(MySqlDataReader mysqlDataReader)
        {
            // SOLUCION YO
            int columns = mysqlDataReader.FieldCount;
            //Console.Write (columns);

            for (int i=0; i < columns; i++) {
                Console.Write (mysqlDataReader.GetName(i)+"        ");
            }

            //			// OTRA OPCION
            //			int count = mysqlDataReader.FieldCount;  //cuenta  las columnas
            //			List<string> columnNames = new List<string> ();  //crea una lista
            //			for (int i=0; i< count; i++) {    //la recorre
            //				columnNames.Add (mysqlDataReader.GetName (i));
            return columnNames.ToArray ();
            //			}

            //			/* SOLUCION PROFESOR
            //			int columns = mysqlDataReader.FieldCount;
            //			String [] columnNames = new string[columns];
            //			for (int i=0; i<columns;i++){
            //				columnNames [i] = mysqlDataReader.GetName (i);
            //		}*/
        }
        //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();
            }
        }
Exemple #38
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);
            }
        }
Exemple #39
0
 private static void show(MySqlDataReader mySqlDataReader)
 {
     Console.WriteLine ("show");
     while (mySqlDataReader.Read()) {
         showRow (mySqlDataReader);
     }
 }
 //metodo que devuelve un array con el nombre de las columnas de la tabla que contiene el mySqlDataReader
 private string[] getColumnNames(MySqlDataReader mySqlDataReader)
 {
     List<string> columnNames = new List<string>();//Lista de valores que almacenara el nombre de las columnas de la tabla en la base de datos
     for (int index = 0; index < mySqlDataReader.FieldCount; index++)//se obtienen del mySqlDataReader el nombre de las columnas
         columnNames.Add (mySqlDataReader.GetName (index));//se añade el nombre a la lista
     return columnNames.ToArray ();
 }
Exemple #41
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++;
        }
    }
Exemple #42
0
 // TODO: Klassen som kaller på CreateNewUser må sjekke om epost og passord  er VARCHAR(50)
 public bool CreateNewUser(string epost, string password)
 {
     command = connection.CreateCommand();
     command.CommandText = "INSERT INTO login (epost, passord) VALUES ('" + epost + "','" + password + "');";
     reader = command.ExecuteReader();
     return true;
 }
        /// <summary>
        /// Gets schema from reader taking Query.ResultRowType in consideration
        /// </summary>
        public static Schema GetSchemaForQuery(string target, Query query, MySqlDataReader reader, QuerySource qSource, out Schema.FieldDef[] toLoad)
        {
            Schema schema;
              var rtp = query.ResultRowType;

              if (rtp != null && typeof(TypedRow).IsAssignableFrom(rtp))
                schema = Schema.GetForTypedRow(query.ResultRowType);
              else
                schema = GetSchemaFromReader(query.Name, qSource, reader);

              //determine what fields to load
              toLoad = new Schema.FieldDef[reader.FieldCount];
              for (int i = 0; i < reader.FieldCount; i++)
              {
                var name = reader.GetName(i);
                var fdef = schema[name];

              //todo A gde GetBackendNameFor target?
                if (fdef==null) continue;
                var attr =  fdef[target];
                if (attr!=null)
                {
                  if (attr.StoreFlag!=StoreFlag.LoadAndStore && attr.StoreFlag!=StoreFlag.OnlyLoad) continue;
                }
                toLoad[i] = fdef;
              }

              return schema;
        }
Exemple #44
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;
 }
Exemple #45
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; 
      
       }
 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);
     }
 }
Exemple #47
0
        protected override DBEntity getDBEntity(MySql.Data.MySqlClient.MySqlDataReader reader)
        {
            Efficiency eff = new Efficiency(this.filter);

            eff.date                          = (DateTime)reader[TimeEvent.ST.ST_DATE];//.TODO: we must review this line when reading from the DB. Visto por Ademir
            eff.mileseconds                   = (int)reader[TimeEvent.ST.ST_MILESECONDS];
            eff.id_pergunta                   = (int)reader[TimeEvent.ST.ST_ID_PERGUNTA];
            eff.event_type                    = (string)reader[TimeEvent.ST.ST_EVENT_TIPE];
            eff.id_processos                  = (int)reader[TimeEvent.ST.ST_ID_PROCESS];
            eff.id_especialista               = (int)reader[Process.ST.ID_EXPERT];
            eff.id_projeto                    = (int)reader[Process.ST.ID_PROJECT];
            eff.idElicitationMethod           = (int)reader[Process.ST.ID_ELICITATION_METHOD];
            eff.idTrainingMethod              = (int)reader[Process.ST.ID_TRAINING_METHOD];
            eff.idAnalyst                     = (int)reader[Process.ST.ID_ANALYST];
            eff.index_lastTrainingQuestion    = (int)reader[Process.ST.INDEX_LAST_TRAINING_QUESTION];
            eff.index_lastElicitationQuestion = (int)reader[Process.ST.INDEX_LAST_ELICITATION_QUESTION];
            eff.name_project                  = (string)reader[Project.ST.ST_NAME];
            eff.name_analyst                  = (string)reader[Analyst.ST.ST_NAME];//retornaListaEstatisticaString("nome");
            eff.intimityMath                  = (int)reader[Expert.ST.ST_INTIMITY_MATH];
            eff.intimityUncertainty           = (int)reader[Expert.ST.ST_INTIMITY_UNC];
            eff.expertiseField                = (string)reader[Expert.ST.ST_EXPERTISE_FIELD];
            eff.email                         = (string)reader[Expert.ST.ST_EMAIL];
            eff.id_titulacao                  = (int)reader["idTitulacao"];//o id da titulação está no construtor de titration então teria que se insanciar um objeto para se pegar essa string
            eff.titulacao                     = (string)reader[Titration.ST.ST_TITULACAO];
            eff.especialidade                 = (string)reader[Titration.ST.ST_ESPECIALIDADE];
            return(eff);
        }
Exemple #48
0
        public List <EUsuario> getAll()
        {
            EUsuario        objUser = null;
            List <EUsuario> lista   = new List <EUsuario>();
            string          sql     = "SELECT * FROM USUARIOS ";

            using (conexion cnx = new conexion())
            {
                cnx.cadena = ConfigSAE.Instanciar.cadenaSAE();
                using (MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand())
                {
                    cmd.CommandText = sql;
                    cmd.Connection  = cnx.getConexion();
                    if (cnx.abrirConexion())
                    {
                        MySql.Data.MySqlClient.MySqlDataReader dr = cmd.ExecuteReader();
                        while (dr.Read())
                        {
                            objUser = mapearObjeto(dr);
                            lista.Add(objUser);
                        }
                        cnx.cerrarConexion();
                    }
                }
                return(lista);
            }
        }
 public static RobaDTO readerToRobaDTO(MySqlDataReader reader)
 {
     RobaDTO roba = new RobaDTO();
     roba.SifraRoba = reader.GetInt32("SifraRoba");
     roba.Naziv = reader.GetString("Naziv");
     return roba;
 }
Exemple #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();
        }
Exemple #51
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;
     }
 }
Exemple #52
0
 public override void SetUp(MySqlDataReader reader)
 {
     this.ProductTypeName = reader["UsingProductType"].ToString();
     this.RollingStockType = reader["OnRollingStockType"].ToString();
     this.IndustryName = reader["ForIndustry"].ToString();
     this.isProducer = (bool)reader["IsProducer"];
 }
Exemple #53
0
 public Person(MySql.Data.MySqlClient.MySqlDataReader reader)
 {
     navyid     = Convert.ToString(reader["navyid"]);
     statuscode = Convert.ToString(reader["statuscode"]);
     yearin     = Convert.ToString(reader["yearin"]);
     batt       = Convert.ToString(reader["batt"]);
     company    = Convert.ToString(reader["company"]);
     name       = Convert.ToString(reader["name"]);
     sname      = Convert.ToString(reader["sname"]);
     id8        = Convert.ToString(reader["id8"]);
     unit3      = Convert.ToString(reader["unit3"]);
     unitname   = Convert.ToString(reader["unitname"]);
     ask        = Convert.ToString(reader["ask"]);
     oldyearin  = Convert.ToString(reader["oldyearin"]);
     regdate    = reader.GetDateTime("regdate");
     movedate   = reader.GetDateTime("movedate");
     //stitle = Core.DataDefinition.GetStatusSTitle(statuscode);
     stitle   = Convert.ToString(reader["stitle"]);
     postname = Convert.ToString(reader["postname"]);
     unit4    = Convert.ToString(reader["unit4name"]);
     item     = Convert.ToString(reader["sxitem"]);
     percent  = Convert.ToString(reader["percent"]);
     educname = Convert.ToString(reader["educname"]);
     skill    = Convert.ToString(reader["skill"]);
     platoon  = Convert.ToString(reader["platoon"]);
     pseq     = Convert.ToString(reader["pseq"]);
     unit1    = Convert.ToString(reader["unit1name"]);
     unit2    = Convert.ToString(reader["unit2name"]);
 }
Exemple #54
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();
        }
Exemple #55
0
        public EParametros getParamentro()
        {
            EParametros objPar = null;
            // List<EParametros> lista = new List<EParametros>();
            string sql = "SELECT * FROM  afparametros  WHERE codigo = 1";

            using (conexion cnx = new conexion())
            {
                cnx.cadena = Configuracion.Instanciar.conexionBD();
                using (MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand())
                {
                    cmd.CommandText = sql;
                    cmd.Connection  = cnx.getConexion();
                    if (cnx.abrirConexion())
                    {
                        MySql.Data.MySqlClient.MySqlDataReader dr = cmd.ExecuteReader();
                        while (dr.Read())
                        {
                            objPar = mapearObjeto(dr);
                            //lista.Add(objPar);
                        }
                        cnx.cerrarConexion();
                    }
                }
                return(objPar);
            }
        }
 public TableInformations(MySqlDataReader reader)
 {
     _primaryKey = new List<string>();
     _uniqueConstraints = new List<string>();
     _foreignConstraints = new List<string>();
     this.setProperty(reader);
 }
        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);
            }
        }
        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);
            }
        }
Exemple #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;
 }
Exemple #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();
                }
            }
        }