ExecuteReader() public method

public ExecuteReader ( ) : MySqlDataReader
return MySqlDataReader
        public static bool validateLogin(UserLog ul)
        {
            DBConnector dbcon = new DBConnector();
            dbcon.openConnection();

            //try {

            MySqlCommand cmd = new MySqlCommand();
            cmd.CommandText = "SELECT * FROM user WHERE username='******' AND password=MD5('" + ul.getPassword() + "')";
            cmd.Connection = dbcon.connection;

            MySqlDataReader login = cmd.ExecuteReader();

            if (login.Read())
            {
                LoginSession.setSession(login.GetString("iduser"));

                //login.Close();
                dbcon.closeConnection();
                return true;
            }
            else
            {
                //login.Close();
                dbcon.closeConnection();
                return false;
            }
            //}
            //catch (MySqlException e){
            //int errorcode = e.Number;
            //return false;
            //}
        }
Exemplo n.º 2
1
        public static void LoadItemsSets()
        {
            lock (DatabaseHandler.ConnectionLocker)
            {
                var sqlText = "SELECT * FROM datas_items_sets";
                var sqlCommand = new MySqlCommand(sqlText, DatabaseHandler.Connection);

                var sqlReader = sqlCommand.ExecuteReader();

                while (sqlReader.Read())
                {
                    var set = new Models.Items.SetModel();

                    set.ID = sqlReader.GetInt16("ID");
                    set.ParseBonus(sqlReader.GetString("bonus"));
                    set.ParseItems(sqlReader.GetString("items"));

                    lock(SetsList)
                        SetsList.Add(set);
                }

                sqlReader.Close();
            }

            Utilities.Loggers.StatusLogger.Write(string.Format("Loaded @'{0}' items sets@ from the database !", SetsList.Count));
        }
Exemplo n.º 3
1
        public Account LoadAccount(string username)
        {
            string SqlQuery = "SELECT * FROM `accounts` WHERE `username` = ?username";
                MySqlCommand SqlCommand = new MySqlCommand(SqlQuery, AccountDAOConnection);
                SqlCommand.Parameters.AddWithValue("?username", username);
                MySqlDataReader AccountReader = SqlCommand.ExecuteReader();

                Account acc = new Account();
                if (AccountReader.HasRows)
                {
                    while (AccountReader.Read())
                    {
                        acc.AccountId = AccountReader.GetInt32(0);
                        acc.Username = AccountReader.GetString(1);
                        acc.Password = AccountReader.GetString(2);
                        acc.Email = AccountReader.GetString(3);
                        acc.AccessLevel = (byte)AccountReader.GetInt32(4);
                        acc.Membership = (byte)AccountReader.GetInt32(5);
                        acc.isGM = AccountReader.GetBoolean(6);
                        acc.LastOnlineUtc = AccountReader.GetInt64(7);
                        acc.Coins = (int)AccountReader.GetInt32(8);
                        acc.Ip = AccountReader.GetString(9);
                        acc.UiSettings = ByteUtilities.StringToByteArray(AccountReader.GetString(10));

                    }
                }
                AccountReader.Close();
                return (acc.Username == "") ? null : acc;
        }
Exemplo n.º 4
1
        public static Trayecto buscarPorId(int id)
        {
            Trayecto trayecto = null;
            if (id > -1)
            {
                MySqlConnection con = conexionDB.ObtenerConexion();
                try
                {
                    string sql = "select id, origen, destino, precio from trayecto where id = " + id;
                    MySqlCommand cmd = new MySqlCommand(sql, con);
                    MySqlDataReader dr = cmd.ExecuteReader();

                    while (dr.Read())
                    {
                        trayecto = new Trayecto(dr.GetInt32(0), CiudadFacade.buscarPorId(dr.GetInt32(1)), CiudadFacade.buscarPorId(dr.GetInt32(2)), dr.GetInt32(3));
                    }
                    dr.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    trayecto = null;
                }
                finally
                {
                    con.Close();
                }
            }
            return trayecto;
        }
Exemplo n.º 5
1
        public static List<Trayecto> buscarOrigenes()
        {
            List<Trayecto> trayectos = new List<Trayecto>(); ;

            MySqlConnection con = conexionDB.ObtenerConexion();
            try
            {
                string sql = "select id, origen, destino, precio from trayecto group by origen";
                MySqlCommand cmd = new MySqlCommand(sql, con);
                MySqlDataReader dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    trayectos.Add(new Trayecto(dr.GetInt32(0), CiudadFacade.buscarPorId(dr.GetInt32(1)), CiudadFacade.buscarPorId(dr.GetInt32(2)), dr.GetInt32(3)));
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                con.Close();
            }

            return trayectos;
        }
Exemplo n.º 6
1
        public static Models.AccountsModel LoadAccount(int accountID)
        {
            DatabaseProvider.CheckConnection();

            lock (DatabaseProvider.ConnectionLocker)
            {
                var account = new Models.AccountsModel();

                var sqlText = "SELECT * FROM dyn_accounts WHERE id=@id";
                var sqlCommand = new MySqlCommand(sqlText, DatabaseProvider.Connection);
                sqlCommand.Parameters.Add(new MySqlParameter("@id", accountID));

                var sqlReader = sqlCommand.ExecuteReader();

                if (sqlReader.Read())
                {
                    account.ID = sqlReader.GetInt16("id");
                    account.Username = sqlReader.GetString("username");
                    account.Password = sqlReader.GetString("password");
                    account.Pseudo = sqlReader.GetString("pseudo");
                    account.Communauty = sqlReader.GetInt16("communauty");
                    account.Level = sqlReader.GetInt16("gmLevel");
                    account.Question = sqlReader.GetString("question");
                    account.Answer = sqlReader.GetString("answer");
                    account.SubscriptionDate = sqlReader.GetDateTime("subscription");
                }

                sqlReader.Close();

                return account;
            }
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            String cbid = TextBox1.Text;
            conn = new MySqlConnection(GetConnectionString());

            try
            {
                conn.Open();
                MySqlCommand comm = new MySqlCommand("Select Stock, Amount, DATE_FORMAT(Valid_From, '%d-%m-%Y'),DATE_FORMAT(Valid_To, '%d-%m-%Y') from Combopack where Combo_ID='" + cbid + "'", conn);
                MySqlDataReader dr = comm.ExecuteReader();
                dr.Read();
                TextBox3.Text = dr.GetValue(0).ToString();
                TextBox2.Text = dr.GetValue(1).ToString();
                TextBox4.Text = dr.GetValue(2).ToString();
                TextBox5.Text = dr.GetValue(3).ToString();
                dr.Close();

                comm.CommandText = "Select p.Product_ID, p.Company_Name, p.Product_Name, c.Quantity from Current_Store_Products p,Combopack_Schemes c where c.Product_ID=p.Product_ID and c.Combo_ID='" + cbid + "'";
                dr = comm.ExecuteReader();
                GridView1.DataSource = dr;
                GridView1.DataBind();
                dr.Close();

                comm.CommandText = "Select Sum(Quantity),Sum(Price) from Combopack_Schemes where Combo_ID='" + cbid + "'";
                dr = comm.ExecuteReader();
                dr.Read();
                Label9.Text = dr.GetValue(0).ToString();
                Label10.Text = dr.GetValue(1).ToString();
                dr.Close();

            }
            catch (Exception ex)
            { Response.Write("In Button2Click"+ex.Message); }
            finally { conn.Close(); }
        }
Exemplo n.º 8
0
        public void AggregateTypesTest()
        {
            execSQL("CREATE TABLE foo (abigint bigint, aint int)");
              execSQL("INSERT INTO foo VALUES (1, 2)");
              execSQL("INSERT INTO foo VALUES (2, 3)");
              execSQL("INSERT INTO foo VALUES (3, 4)");
              execSQL("INSERT INTO foo VALUES (3, 5)");

              // Try a normal query
              string NORMAL_QRY = "SELECT abigint, aint FROM foo WHERE abigint = {0}";
              string qry = String.Format(NORMAL_QRY, 3);
              MySqlCommand cmd = new MySqlCommand(qry, conn);
              using (MySqlDataReader reader = cmd.ExecuteReader())
              {
            while (reader.Read())
            {
              reader.GetInt64(0);
              reader.GetInt32(1); // <--- aint... this succeeds
            }
              }

              cmd.CommandText = "SELECT abigint, max(aint) FROM foo GROUP BY abigint";
              using (MySqlDataReader reader = cmd.ExecuteReader())
              {
            while (reader.Read())
            {
              reader.GetInt64(0);
              reader.GetInt64(1); // <--- max(aint)... this fails
            }
              }
        }
Exemplo n.º 9
0
 private void GetValues()
 {
     qry = "SELECT In_Stock,Hired_Out FROM books WHERE ISBN = @ISBN";
     using (MySqlConnection Connection = new MySqlConnection(MyConString))
     {
         try
         {
             MySqlCommand cmd = new MySqlCommand(qry, Connection);
             cmd.Parameters.Add(new MySqlParameter("@ISBN",(object)ISBN));
             MySqlDataReader reader;
             Connection.Open();
             reader = cmd.ExecuteReader();
             in_stock = int.Parse(reader["In_Stock"].ToString());
             hired_out = int.Parse(reader["Hired_Out"].ToString());
             reader.Close();
             cmd.Parameters.Clear();
             qry = "SELECT Books_purchased,Books_hired FROM clients WHERE FirstName = @FirstName AND LastName = @LastName";
             cmd.Parameters.Add(new MySqlParameter("@FirstName", (object)firstname));
             cmd.Parameters.Add(new MySqlParameter("@LastName", (object)lastname));
             reader = cmd.ExecuteReader();
             books_purchased = int.Parse(reader["Books_purchased"].ToString());
             books_hired = int.Parse(reader["Books_hired"].ToString());
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         finally
         {
             Connection.Close();
         }
     }
 }
Exemplo n.º 10
0
        public ReportData getPatientReport(int patientID)
        {
            ReportData reportData = new ReportData();

            using (MySqlConnection conn = new MySqlConnection(connectionString))
            {
                conn.Open();

                MySqlCommand cmd = new MySqlCommand();
                cmd.Connection = conn;
                cmd.CommandText = "SELECT * FROM patient where patientID=@pID";
                cmd.Prepare();
                cmd.Parameters.Add("@pID", MySqlDbType.Int32).Value = patientID;

                using (MySqlDataReader rdr = cmd.ExecuteReader())
                {

                    while (rdr.Read())
                    {
                        reportData.PatientData.PatientID = rdr.GetInt32("patientID");
                        reportData.PatientData.FirstName = rdr.GetString("firstName");
                        reportData.PatientData.LastName = rdr.GetString("lastName");
                        reportData.PatientData.DateAdmitted = rdr.GetDateTime("dateAdmitted");
                    }
                }

                //TODO new reach specific, fix later
                cmd.CommandText = "SELECT * FROM reach where patientID=@pID";
                cmd.Prepare();

                using (MySqlDataReader rdr = cmd.ExecuteReader())
                {

                    while (rdr.Read())
                    {
                        ExerciseData exerciseData = new ExerciseData();
                        exerciseData.ExerciseName = "reach";
                        exerciseData.PatientID = rdr.GetInt32("patientID");
                        exerciseData.EmployeeID = rdr.GetInt32("employeeID");
                        exerciseData.SessionID = rdr.GetInt32("sessionID");

                        //specific to reach
                        exerciseData.Hands = rdr.GetString("hands");
                        exerciseData.Angle = rdr.GetDouble("angle");
                        exerciseData.Date = rdr.GetDateTime("exerciseDate");
                        exerciseData.Time = rdr.GetDouble("time");

                        reportData.ExerciseDataList.Add(exerciseData);
                    }
                }

            }

            return reportData;

        }
Exemplo n.º 11
0
        public static List<OgrenciDersleri> OgrenciDersGetir(Ogrenci ogrenci)
        {
            List<OgrenciDersleri> ogrenciDersleri = new List<OgrenciDersleri>();
            MySqlConnection connection=null;
            try
            {
                string connectionString="SERVER=localhost;DATABASE=OgrenciYonetimSistemi; UID=root;PASSWORD=hy050491;";
                 connection = new MySqlConnection(connectionString);
                connection.Open();
                string query = "SELECT * FROM OgrenciDersleri";

                MySqlCommand cmd = new MySqlCommand(query, connection);
                MySqlDataReader reader= cmd.ExecuteReader();

                while (reader.Read())
                {
                    OgrenciDersleri ogreciDers = new OgrenciDersleri();
                    ogreciDers.Id = Convert.ToInt32(reader["Id"]);

                    ogreciDers.Ogrenci = new Ogrenci();
                    ogreciDers.Ogrenci.Id = Convert.ToInt32(reader["Ogrenci"]);
                    ogreciDers.Ders = new Ders();

                    ogreciDers.Ders.Id = Convert.ToInt32(reader["Ders"]);

                    string studentQuery = "SELECT * FROM Ogrenci WHERE Id = '" + ogreciDers.Ogrenci.Id + "'";

                    MySqlCommand cmdStudent = new MySqlCommand(query, connection);
                    MySqlDataReader readerStudent = cmd.ExecuteReader();
                    while (readerStudent.Read())
                    {
                        ogreciDers.Ogrenci.Adi = readerStudent["Adi"].ToString();
                        ogreciDers.Ogrenci.Soyadi = readerStudent["Soyadi"].ToString();
                    }

                    ogrenciDersleri.Add(ogreciDers);
                }
                connection.Close();
                    DataTable table = new DataTable();
                    table.Load(reader);
                    for (int i = 0; i < table.Rows.Count; i++)
                {
                    string adi = table.Rows[i]["Id"].ToString();
                }
                //DersBilgileriDoldur(ogrenciDersleri);
            }
            catch (Exception ex)
            {

            }
            finally
            {
                connection.Close();
            }
            return ogrenciDersleri;
        }
Exemplo n.º 12
0
    public int AddNewCustomer()
    {
        int newCustomerID = 0;
        int existingCustomerResult = 0; //Used to check if this customer already exists in the database

        MySqlConnection conn = new MySqlConnection("Server=database2.cs.tamu.edu; Database=gcopley-car_dealership; Uid=gcopley ;Pwd=add431;");
        MySqlCommand findExistingCmd = new MySqlCommand("SELECT MAX(id) from customer where f_name ='" + m_txtCrtPendingCustFirstNameVal.Text + "' and l_name ='" + m_txtCrtPendingCustLastNameVal.Text + "'", conn);
        findExistingCmd.Connection.Open();

        //First check to see if the customer already exists in the database, if he does, return his ID, as there is no need to add him
        MySqlDataReader queryReader = findExistingCmd.ExecuteReader();
        while (queryReader.Read())
        {
            if (queryReader.FieldCount != 0)
            {
                existingCustomerResult = (queryReader.GetInt32(0));
            }
        }

        queryReader.Close();

        if (existingCustomerResult != 0)
        {
            queryReader.Dispose();
            return existingCustomerResult;
        }

        //If the customer doesn't exist, add him into the database, and if its a success, extract his id and return it.
        MySqlCommand addNewCustomerCmd = new MySqlCommand("INSERT INTO customer(f_name, l_name, addr_city, addr_state, addr_zip, phone, email) " +
                                               "VALUES('" + m_txtCrtPendingCustFirstNameVal.Text + "','" + m_txtCrtPendingCustLastNameVal.Text + "','" + m_txtCrtPendingCustCityVal.Text + "','" + m_txtCrtPendingCustStateVal.Text + "','" + m_txtCrtPendingCustZipVal.Text + "','" + m_txtCustomerPhoneNumber.Text + "','" + m_txtCustomerEmail.Text + ")", conn);

        addNewCustomerCmd.ExecuteNonQuery();

        //queryReader.();
        queryReader = findExistingCmd.ExecuteReader();
        while (queryReader.Read())
        {
            newCustomerID = (queryReader.GetInt32(0));
        }

        if (newCustomerID != 0)
        {
            queryReader.Close();
            queryReader.Dispose();
            return newCustomerID;
        }

        else
        {
            queryReader.Close();
            queryReader.Dispose();
            return 0;
        }
    }
Exemplo n.º 13
0
        private void button1_Click(object sender, EventArgs e)
        {
            string strconn;
            strconn = "SERVER = " + server + "; DATABASE = " + DBtext + "; User ID =" + user + " ; password = "******";Charset=utf8";

            MySqlConnection mys_conn = new MySqlConnection(strconn);
            mys_conn.Open();

            string sql = "select * from " + DBtable + " order by mdl_code asc";

            MySqlCommand mys_com = new MySqlCommand(sql,mys_conn);

            MySqlDataReader mys_read = mys_com.ExecuteReader();
            int listcount = 0;
            while (mys_read.Read())
            {
                if (mys_read.HasRows)
                {
                    listcount++;
                }
            }
            result = new string[listcount][];

            //釋放資源
            mys_read.Dispose();

            //重新載入
            mys_read = mys_com.ExecuteReader();
            int times = 0;
            while (mys_read.Read())
            {
                result[times] = new string[mys_read.FieldCount];
                string str="";
                for (int i = 0; i < mys_read.FieldCount; i++)
                {
                    result[times][i] = mys_read[i].ToString();
                    if (i == 0)
                    {
                        str += mys_read[i].ToString();
                        continue;
                    }
                    str += " , "+ mys_read[i].ToString();
                }
                times++;
                listBox1.Items.Add(str.ToString());
            }

            mys_read.Dispose();
            mys_read.Close();
            mys_com.Dispose();
            mys_conn.Dispose();
            mys_conn.Close();
        }
Exemplo n.º 14
0
        //Vrakja lista na knigi
        public List<Book> SelectListBooks(string search,string language, string category)
        {
            List<Book> list = new List<Book>();

            using (MySqlConnection connection = new MySqlConnection())
            {
                connection.ConnectionString = connString;
                connection.Open();

                string query = "SELECT IDBook, Name, ImageSrc, Description, Date FROM Books, Categories, Tags, BelongsTo, Tagged";
                MySqlCommand command = new MySqlCommand(query, connection);
                MySqlDataReader dataReader = command.ExecuteReader();

                Dictionary<string, string> dictionary = new Dictionary<string, string>();
                List<Dictionary<string, string>> books = new List<Dictionary<string, string>>();
                List<Author> authors;

                while (dataReader.Read())
                {
                    dictionary.Add("IDBook", dataReader["IDBook"].ToString());
                    dictionary.Add("Name", dataReader["Name"].ToString());
                    dictionary.Add("ImageSrc", dataReader["ImageSrc"].ToString());
                    dictionary.Add("Description", dataReader["Description"].ToString());
                    dictionary.Add("Date", dataReader["YearPublished"].ToString());
                    books.Add(dictionary);
                }
                dataReader.Close();

                for (int i = 0; i < books.Count; i++)
                {
                    //Lista na avtori za sekoja kniga
                    authors = new List<Author>();
                    query = "SELECT a.Name, a.Surname,a.Country FROM Authors as a, Books as b, Wrote as w WHERE w.IDAuthor = a.IDAuthor AND w.IDBook =" + books[i]["IDBook"];
                    command.CommandText = query;
                    dataReader = command.ExecuteReader();

                    while (dataReader.Read())
                    {
                        Author a = new Author(dataReader["Name"].ToString(), dataReader["Surname"].ToString(), dataReader["Countrey"].ToString());
                        authors.Add(a);
                    }
                    dataReader.Close();

                    //Dodavanje na knigata vo listata
                    Book b = new Book(books[i]["Name"], authors, books[i]["ImageSrc"], books[i]["Description"], books[i]["Date"]);
                    list.Add(b);
                    }

                    connection.Close();
                    return list;
            }
        }
        protected void Confirm_Click(object sender, EventArgs e)
        {
            conn = new MySqlConnection(GetConnectionString());
            String orderid = TextBox7.Text;
            List<String> ProductID = new List<String>();
            List<int> Quantity = new List<int>();
            try
            {
            conn.Open();
               // MySqlCommand comm=new MySqlCommand("Update Order_Detail_Store set Order_Received='Completed' where Order_ID='"+orderid+"'",conn);
            MySqlCommand comm=new MySqlCommand("Select Order_Received from Order_Detail_Store where Order_ID='"+orderid+"'",conn);
            MySqlDataReader dr=comm.ExecuteReader();
            dr.Read();
                String flag=dr.GetValue(0).ToString();
                dr.Close();
                if(flag.Equals("Pending"))
                {
                    comm.CommandText="Update Order_Detail_Store set Order_Received='Completed' where Order_ID='"+orderid+"'";
            comm.ExecuteNonQuery();
            comm.CommandText = "Update Order_Detail_Store_Central set Order_Received='Completed' where Order_ID='" + orderid + "'";
            comm.ExecuteNonQuery();

            comm.CommandText = "Select Product_ID,Quantity from Order_Product_Store where Order_ID='"+orderid+"'";
            MySqlDataReader dr1 = comm.ExecuteReader();

            while (dr1.Read())
            {
                ProductID.Add(dr1.GetValue(0).ToString());
                Quantity.Add(int.Parse(dr1.GetValue(1).ToString()));
            }
            dr1.Close();
            int i=0;

            foreach (String pid in ProductID)
            {
                int quant = Quantity.ElementAt(i);
                i++;
                comm.CommandText = "Update Current_Store_Products set Stock=Stock+" + quant + " where Product_ID='" + pid + "'";
                comm.ExecuteNonQuery();
            }
                }
            }
            catch (Exception ex)
            { Response.Write(ex.Message); }
            finally { conn.Close(); }

            TextBox7.Text="";
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            MySqlConnection conn = new MySqlConnection(GetConnectionString());
            String[] top = new String[5];
            String[] bottom = new String[5];
            MySqlDataReader dr;
            String query1 = "Select Product_Name,Company_Name,Sp4_Value,Sp5_Value,Sp6_Value,Sp7_Value,Sp8_Value from Master_Products where Product_ID in (Select Product_ID from Transactions where Bill_No in (Select Bill_No from Bills where MONTH(Bill_Date) = MONTH(NOW())) GROUP BY(Product_ID) ORDER BY SUM(Quantity) desc) ORDER BY(Product_ID) desc";
            String query2 = "Select Product_Name,Company_Name,Sp4_Value,Sp5_Value,Sp6_Value,Sp7_Value,Sp8_Value from Master_Products where Product_ID in (Select Product_ID from Transactions where Bill_No in (Select Bill_No from Bills where MONTH(Bill_Date) = MONTH(NOW())) GROUP BY(Product_ID) ORDER BY SUM(Quantity) ORDER BY (Product_ID))";
            try
            {
                conn.Open();
                MySqlCommand comm = new MySqlCommand(query1, conn);
                dr = comm.ExecuteReader();

                for (int i = 0; i < 5; i++)
                {
                    dr.Read();
                    top[i] = dr.GetValue(1).ToString() + " " + dr.GetValue(0).ToString() + " " + dr.GetValue(2).ToString() + " " + dr.GetValue(3).ToString() + " " + dr.GetValue(4).ToString() + " " + dr.GetValue(5).ToString() + " " + dr.GetValue(6).ToString();
                }
                dr.Close();
                comm.CommandText = query2;
                dr = comm.ExecuteReader();

                for (int i = 0; i < 5; i++)
                {
                    dr.Read();
                    bottom[i] = dr.GetValue(1).ToString() + " " + dr.GetValue(0).ToString() + " " + dr.GetValue(2).ToString() + " " + dr.GetValue(3).ToString() + " " + dr.GetValue(4).ToString() + " " + dr.GetValue(5).ToString() + " " + dr.GetValue(6).ToString();
                }
                dr.Close();

            }
            catch (Exception ex)
            { Response.Write(ex.Message); }
            finally
            { conn.Close(); }

            Label3.Text = top[0];
            Label5.Text = top[1];
            Label4.Text = top[2];
            Label6.Text = top[3];
            Label7.Text = top[4];

            Label8.Text = bottom[0];
            Label9.Text = bottom[1];
            Label10.Text = bottom[2];
            Label11.Text = bottom[3];
            Label12.Text = bottom[4];
        }
Exemplo n.º 17
0
        public List<Categoria> ObterCategoriasCadastradas(string idioma)
        {
            List<Categoria> lista = new List<Categoria>();

            MySqlConnection conn = new MySqlConnection(connectionString);
            MySqlCommand cmd = new MySqlCommand();
            cmd.Connection = conn;
            cmd.CommandText = "SELECT id, nome, urlImagem FROM tb_categorias order by nome";

            conn.Open();
            MySqlDataReader dr = cmd.ExecuteReader();

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    lista.Add(new Categoria
                    {
                        id = (int)dr["id"],
                        nome = Tradutor.Traduzir(dr["nome"].ToString(), idioma),
                        urlImagem = dr["urlImagem"].ToString()
                    });
                }
            }
            conn.Close();

            return lista;
        }
Exemplo n.º 18
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);
            }
        }
Exemplo n.º 19
0
        /* =====================================================================================
         * ================== G E T  V A L U E S  B Y  O T H E R  V A L U E S ==================
         * ===================================================================================== */
        static string[] getCharakByNameAndKodas(string name, string kodas)
        {
            string[] result = { "", "" };

            MySqlConnection con = new MySqlConnection(connectionStringAlt);
            con.Open();

            //query
            string query = "SELECT pr_z.pr_pavad as 'name',g_v.prid, g_v.g_kodas as 'kodas' FROM pg_zodynas INNER JOIN pg_seima on pg_seima.pg_id_v=pg_zodynas.pg_id INNER JOIN goods_v g_v on g_v.pgs_id = pg_seima.pgs_id INNER JOIN pr_zodynas AS pr_z ON g_v.pr_id=pr_z.pr_id AND g_v.del_date IS NULL WHERE pg_zodynas.pavaddgs = '" + name + "'";
            MySqlCommand cmd = new MySqlCommand(query, con);

            //executing query
            MySqlDataReader data = cmd.ExecuteReader();

            while (data.Read())
            {
                if (data["kodas"].ToString() == kodas)
                    result[0] = data["name"].ToString();
                {
                    result[1] = data["prid"].ToString();
                }
            }

            data.Close();
            con.Close();

            return result;
        }
 public static List<NetworkProcessor> CreateNetProcs()
 {
     AppLog.WriteLine(5, "STATUS", "Entered IRCStatistician.Program.CreateNetProcs().");
     List<NetworkProcessor> returnList = new List<NetworkProcessor>();
     // Get the tbn_networks table
     MySqlCommand NetworkCmd = new MySqlCommand("SELECT * FROM " + Config.SQLTablePrefix + "networks", MyDBConn.Connection);
     MySqlDataReader NetworkDataReader = NetworkCmd.ExecuteReader();
     DataTable NetworkTable = new DataTable();
     NetworkTable.Load(NetworkDataReader);
     NetworkDataReader.Close();
     // Get the tbn_channels table
     MySqlCommand ChannelCmd = new MySqlCommand("SELECT * FROM " + Config.SQLTablePrefix + "channels", MyDBConn.Connection);
     MySqlDataReader ChannelDataReader = ChannelCmd.ExecuteReader();
     DataTable ChannelTable = new DataTable();
     ChannelTable.Load(ChannelDataReader);
     ChannelDataReader.Close();
     // Organize them together.
     foreach (DataRow CurNetwork in NetworkTable.Rows) {
         NetworkProcessor tempLW = new NetworkProcessor(CurNetwork);
         foreach (DataRow CurChannel in ChannelTable.Rows) {
             if (Convert.ToInt32(CurChannel["networkid"]) == tempLW.Network.Id) {
                 tempLW.Network.Channels.Add(CurChannel["name"].ToString(), new Channel(CurChannel["name"].ToString()));
             }
         }
         returnList.Add(tempLW);
     }
     return returnList;
 }
        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);
            }
        }
Exemplo n.º 22
0
        private void buttonCadastrar_Click(object sender, EventArgs e)
        {
            MySqlConnection conn = null;

            try
            {
                conn = Conexao.getConexao();
                MySqlCommand cmd = new MySqlCommand("call cadastra_pizza(@nome, @tamanho, @preco)", conn);
                cmd.Prepare();
                cmd.Parameters.AddWithValue("@nome", this.txt_nome.Text);
                cmd.Parameters.AddWithValue("@tamanho", this.cmb_tamanho.Text);
                cmd.Parameters.AddWithValue("@preco", this.txt_preco.Text);

                MySqlDataReader rs = cmd.ExecuteReader();
                rs.Read();

                if (!rs.HasRows)
                {
                    conn.Close();
                    new SuccessDialog("Pizza cadastrada com sucesso!");
                    this.Close();
                }
                else
                {
                    String error = rs.GetString(0);
                    conn.Close();
                    new ErrorDialog(error);
                }
            }
            catch (Exception err)
            {
                if (conn != null) conn.Close();
                new ErrorDialog(err.Message);
            }
        }
Exemplo n.º 23
0
        public List <Contato> BuscarTodos(Contato contato)
        {
            List <Contato>  todos = new List <Contato>();
            MySqlConnection conn  = new ConexaoBancoMySql().getConnection();

            conn = new MySqlConnection(connectionString);
            String selecionaTodos = "select id, nome, telefone from contato ";

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

            try
            {
                MySqlDataReader reader = cmd.ExecuteReader();


                while (reader.Read())
                {
                    Contato novo = new Contato();


                    novo.id       = (int)reader["id"];
                    novo.nome     = reader["nome"].ToString();
                    novo.telefone = reader["telefone"].ToString();
                    todos.Add(novo);
                }

                conn.Close();
                return(todos);
            }
            finally
            {
                conn.Close();
            }
        }
Exemplo n.º 24
0
        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);
        }
Exemplo n.º 25
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);
        }
Exemplo n.º 26
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();
            }
        }
Exemplo n.º 27
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);
        }
Exemplo n.º 28
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);
        }
Exemplo n.º 29
0
        private void btn_load_Click(object sender, EventArgs e)
        {
            MySqlConnection connection;
            var sql = String.Format("SELECT * FROM creature_ai_scripts WHERE creature_id = {0}", UInt32.Parse(tb_entry.Text));

            try
            {
                connection = new MySqlConnection("server=127.0.0.1;uid=root;pwd=;database=world2;");
                connection.Open();

                MySqlCommand cmd = new MySqlCommand(sql, connection);
                var data = cmd.ExecuteReader();

                if (!data.HasRows)
                    return;

                while(data.Read())
                {
                    tc_content.TabPages.Add("AI");
                    var newTab = tc_content.TabPages[tc_content.TabCount - 1];
                    var aiTab = new AiTab();
                    aiTab.Dock = DockStyle.Fill;
                    aiTab.FromDatabase(data);

                    newTab.Controls.Add(aiTab);
                }
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        //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(); }
        }
Exemplo n.º 31
0
        public bool checkExistance()
        {
            string connStr = "server=csshrpt.eku.edu;user=csc834;database=csc834;port=3306;password=CSC834student;";

            MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(connStr);
            try
            {
                Console.WriteLine("Connecting to MySQL...");
                conn.Open();
                string sql = "SELECT * FROM changitemtable WHERE name = @name";
                MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@name", name);
                MySqlDataReader myReader = cmd.ExecuteReader();
                if (myReader.Read())
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            conn.Close();
            Console.WriteLine("Done.");
            return(false);
        }
Exemplo n.º 32
0
 public UserModel(int id)
 {
     try {
         MySqlConnection Conn = new MySqlConnection("server=sql9.freemysqlhosting.net;database=sql9140372;user=sql9140372;password=WSx2C8iRZx;");
         var             cmd  = new MySql.Data.MySqlClient.MySqlCommand();
         Conn.Open();
         cmd.Connection  = Conn;
         cmd.CommandText = "SELECT username,currency,avatar,email FROM users WHERE id = @id";
         cmd.Prepare();
         cmd.Parameters.AddWithValue("@id", id);
         MySqlDataReader rdr = cmd.ExecuteReader();
         if (rdr.Read())
         {
             username = rdr[0].ToString();
             currency = Convert.ToInt32(rdr[1]);
             avatar   = rdr[2].ToString();
             if (avatar.Length == 0)
             {
                 avatar = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/2wBDAQMDAwQDBAgEBAgQCwkLEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBD/wAARCACAAIADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD9Cvh98PvBGpeCNDvr7wtps9xPYxSSyyW6lnYrySe5rof+FX/D3/oTtJ/8Blo+F/8AyT3w9/2Dof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E/8Ck/xoA+VpvB/iPPNmx/A1m3PgzxG5wtkfzP+FfWreJ/hK/XxPon/AIFJ/jUR8QfCM8jxRov/AIEp/jQB8eXPw38TzglbRfpk/wCFUJPgz4sujxbQqD2Jb/CvtMeIfhHjnxPov/gSn+NPXxL8JU6eJ9F/8Ck/xoA+Jk/Zx8UXzAS3kcIJydtuXJHsSRXQab+ybYzlP7V/tC75yV3iNT/3yAf1r6+Txh8KkOV8UaJ/4FJ/jVhPHvwxj+54q0Qf9vKf40AeJ+B/gRp3hbb/AGH4ftrFsbWkjiG9h7v94/ia9X0LwVdWu0uMAVtL8R/hyn3fF+jD6XSf40//AIWZ8Pf+hy0j/wAC0/xoA2rCx+yIAWyQKxfib/yT3xF/2DZ//QDR/wALM+Hv/Q5aR/4Fp/jXP+P/AB/4I1HwRrtjY+K9LnnnsJo4oo7lGd3KHAAzzQB//9k=";
             }
             email = rdr[3].ToString();
         }
         else
         {
             username = "******";
             currency = 0;
             avatar   = "";
         }
         Conn.Close();
     } catch (Exception e)
     {
     }
 }
Exemplo n.º 33
0
        private void button3_Click(object sender, EventArgs e)
        {
            string CommandString = "update kitbox_database.kitbox set Enstock='" + this.Enstock.Text + "' where CodeBarre='" + this.CodeBarre.Text + "';";

            MySql.Data.MySqlClient.MySqlCommand Command;
            Command = new MySql.Data.MySqlClient.MySqlCommand(CommandString, connection);
            MySqlDataReader myReader;

            if (CodeBarre.Text.Trim() == string.Empty || Enstock.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Please make sure that all fields are completed");
                return; // return because we don't want to run normal code of buton click
            }
            else
            {
                try
                {
                    connection.Open();
                    myReader = Command.ExecuteReader();
                    MessageBox.Show("saved");
                    while (myReader.Read())
                    {
                    }
                }



                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                LoadTable();
                connection.Close();
            }
        }
Exemplo n.º 34
0
        /*!
         * \brief This method populates the cityInfo Combo Box.
         * \details This methos populates the cityInfo CB by querying the CarrierCities table in the database for all of the unique city names.
         * \param <b>void</b>
         */

        private void fillCityComboBox()
        {
            string          conStr = ConfigurationManager.ConnectionStrings[localUser.CONSTR].ConnectionString;
            StringBuilder   cmdSB  = new StringBuilder("SELECT distinct(cityName) FROM CarrierCities;");
            MySqlDataReader reader = null;

            using (MySqlConnection connection = new MySqlConnection(conStr))
            {
                MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(cmdSB.ToString(), connection);
                try
                {
                    connection.Open();
                    reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        cityInput.Items.Add(reader["cityName"].ToString());
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    connection.Close();
                }
            }
        }
Exemplo n.º 35
0
        private void Lockbtn_Click(object sender, EventArgs e)
        {
            //UPDATE PASSWORD TO DATABASE
            using (MySqlConnection con = new MySqlConnection("server = 35.240.129.112; user id = asguarduser; database = da_schema"))
            {
                con.Open();
                string queryStr = "";
                queryStr = "UPDATE Userinfo set verificationflag=@vflag, statusDate=@statusDate where userid = @userid";

                MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, con);
                if (vflag.Text == "L")
                {
                    //lock to unlock
                    cmd.Parameters.AddWithValue("@vflag", "T");
                    cmd.Parameters.AddWithValue("@statusDate", "NULL");
                    dblog.Log("Account status changed(L -> T) by Admin", "Accounts", Logininfo.userid, Logininfo.email);
                }
                else if (vflag.Text == "T")
                {
                    //unlock to lock
                    cmd.Parameters.AddWithValue("@vflag", "L");
                    cmd.Parameters.AddWithValue("@statusDate", DateTime.Now.ToString("dd'/'MM'/'yyyy HH:mm:ss"));
                    dblog.Log("Account status changed(T -> L) by Admin", "Accounts", Logininfo.userid, Logininfo.email);
                }
                else if (vflag.Text == "A")
                {
                    MessageBox.Show("User had been archived.");
                }
                cmd.Parameters.AddWithValue("@userid", AdminSession.userid);
                cmd.ExecuteReader();
                con.Close();
            }

            userdataRetrieval();
        }
        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);
            }
        }
Exemplo n.º 37
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);
            }
        }
Exemplo n.º 38
0
        /// <summary>
        /// 根据主键查询
        /// </summary>
        /// <param name="primaryKey"></param>
        /// <returns></returns>
        public DialogueSettingBO Get(string primaryKey)
        {
            string sql = "SELECT client,username,password,database_id,workspace_id,emailtype_id,email_id,ftp_account_id,prefix,sms_account,sms_password,sms_pid FROM t_dialoguesetting where APIKey=@APIKey";
            using (MySqlConnection mycn = new MySqlConnection(mysqlConnection))
            {
                mycn.Open();
                MySqlCommand command = new MySqlCommand(sql, mycn);
                command.Parameters.AddWithValue("@APIKey", primaryKey);
                MySqlDataReader reader = command.ExecuteReader();
                DialogueSettingBO DB_DialogueSetting = null;
                if (reader.Read())
                {
                    DB_DialogueSetting = new DialogueSettingBO();
                    DB_DialogueSetting.client = reader["client"] == DBNull.Value ? "" : reader["client"].ToString();
                    DB_DialogueSetting.username = reader["username"] == DBNull.Value ? "" : reader["username"].ToString();
                    DB_DialogueSetting.password = reader["password"] == DBNull.Value ? "" : reader["password"].ToString();
                    DB_DialogueSetting.contactDatabaseId = reader["database_id"] == DBNull.Value ? "" : reader["database_id"].ToString();
                    DB_DialogueSetting.workspaceId = reader["workspace_id"] == DBNull.Value ? "" : reader["workspace_id"].ToString();
                    DB_DialogueSetting.emailTypeId = reader["emailtype_id"] == DBNull.Value ? "" : reader["emailtype_id"].ToString();
                    DB_DialogueSetting.directEmailId = reader["email_id"] == DBNull.Value ? "" : reader["email_id"].ToString();
                    DB_DialogueSetting.ftpAccountId = reader["ftp_account_id"] == DBNull.Value ? "" : reader["ftp_account_id"].ToString();
                    DB_DialogueSetting.sms_account = reader["sms_account"] == DBNull.Value ? "" : reader["sms_account"].ToString();
                    DB_DialogueSetting.sms_password = reader["sms_password"] == DBNull.Value ? "" : reader["sms_password"].ToString();
                    DB_DialogueSetting.sms_pid = reader["sms_pid"] == DBNull.Value ? "" : reader["sms_pid"].ToString();
                    DB_DialogueSetting.prefix = reader["prefix"] == DBNull.Value ? "" : reader["prefix"].ToString();

                }
                return DB_DialogueSetting;
            }

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Button2.Visible = false;
            DateTime dNow = DateTime.Now;


            TextBox1.Text = (dNow.ToString("MM/dd/yyyy"));


            txtReqId.Text   = Request.QueryString["val"];
            txtReqDate.Text = Request.QueryString["val2"];
            txtapprove.Text = Request.QueryString["val5"];

            if (!this.IsPostBack)
            {
                // MySql.Data.MySqlClient.MySqlCommand cmd;
                conn = new MySql.Data.MySqlClient.MySqlConnection(ConnString);
                conn.Open();

                string query = "SELECT item_name,itemid FROM procurement.item where reqid ='" + txtReqId.Text + "' ";
                cmd = new MySql.Data.MySqlClient.MySqlCommand(query, conn);
                ListBox1.DataSource     = cmd.ExecuteReader();
                ListBox1.DataTextField  = "item_name";
                ListBox1.DataValueField = "itemid";
                ListBox1.DataBind();


                conn.Close();
            }
        }
        public void Initialize()
        {
            Logger.WriteLog("Loading the server list...", Logger.LogType.Initialize);

            MySqlCommand cmd = new MySqlCommand("SELECT * FROM servers", DatabaseFactory.Instance.GetDBConnection());

            using (MySqlDataReader dr = cmd.ExecuteReader())
            {
                while (dr.Read())
                {
                    GameServerList.Add(dr.GetString(1), new GameServerInfo()
                    {
                        ServerID = dr.GetByte(0),
                        ServerName = dr.GetString(1),
                        ServerAddr = IPAddress.Parse(dr.GetString(2)),
                        ServerPort = dr.GetInt16(3),
                        OnlineUsers = dr.GetInt16(7),
                        DateCreated = dr.GetDateTime(4),
                        DeveloperOnly = Convert.ToBoolean(dr.GetByte(6))
                    });
                }

                dr.Close();
            }
        }
Exemplo n.º 41
0
        /// <summary>
        /// Gets the Clients by logged in User role
        /// </summary>
        /// <param name="LoggedInUser"></param>
        /// <returns></returns>
        public List <User> getClients(User LoggedInUser)
        {
            MySql.Data.MySqlClient.MySqlCommand Using;
            List <User> Clients = new List <User>();

            DAL.DBRoleConnection dBRoleConnection = new DBRoleConnection();
            switch (LoggedInUser.RoleID)
            {
            case 2:
                Using = new MySql.Data.MySqlClient.MySqlCommand("select user.ID, user.BsnNumber,user.FirstName,user.LastName from user where user.Confirmed!=0", con);
                break;

            case 6:
                Using = new MySql.Data.MySqlClient.MySqlCommand("select user.ID, user.BsnNumber,user.FirstName,user.LastName from user where user.MainTherapistID=@therapistid and user.Confirmed!=0", con);
                break;

            case 7:
                Using = new MySql.Data.MySqlClient.MySqlCommand("select user.ID, user.BsnNumber,user.FirstName,user.LastName from user where user.Confirmed!=0", con);
                break;

            default:
                Using = new MySql.Data.MySqlClient.MySqlCommand("select user.ID, user.BsnNumber,user.FirstName,user.LastName from user where user.MainTherapistID=@therapistid and user.Confirmed!=0", con);
                break;
            }

            using (MySql.Data.MySqlClient.MySqlCommand cmd = Using)
            {
                cmd.Parameters.AddWithValue("@therapistid", (LoggedInUser.ID != 0) ? LoggedInUser.ID : throw new Exception("No rights to perform this action (User.ID = null)"));

                try
                {
                    con.Open();
                    MySqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        User Client = new User();
                        Client.ID        = (int)reader["ID"];
                        Client.BsnNumber = (string)reader["BsnNumber"];
                        Client.FirstName = (string)reader["BsnNumber"] + " " + (string)reader["FirstName"] + " " + (string)reader["LastName"];
                        Clients.Add(Client);
                    }
                }
                catch (Exception ex)
                {
                    if (con.State != System.Data.ConnectionState.Closed)
                    {
                        con.Close();
                    }
                    throw new Exception(ex.Message);
                }
                if (con.State != System.Data.ConnectionState.Closed)
                {
                    con.Close();
                }
            }


            return(Clients);
        }
Exemplo n.º 42
0
        public IDataReader ExecuteDataReader(Saga.Data.IQueryProvider query, CommandBehavior behavior)
        {
            MySqlConnection connection = ConnectionPool.Request();
            MySqlCommand command = new MySqlCommand();
            MySqlDataReader reader = null;

            try
            {

                command.CommandText = query.CmdText;
                command.Connection = connection;
                foreach (KeyValuePair<string, object> pair in query.Parameters)
                {
                    command.Parameters.AddWithValue(pair.Key, pair.Value);
                }

                return command.ExecuteReader(behavior);
            }
            catch (Exception e)
            {
                __dbtracelog.WriteError("Database", e.Message);
                return null;
            }
            finally
            {
                //ALWAYS CLOSE THE CONNECTION AND REPOOL THE ITEMS
                if (reader != null && reader.IsClosed == false) reader.Close();
                ConnectionPool.Release(connection);
            }
        }
Exemplo n.º 43
0
        public static void LoadItems()
        {
            lock (DatabaseHandler.ConnectionLocker)
            {
                var sqlText = "SELECT * FROM datas_items";
                var sqlCommand = new MySqlCommand(sqlText, DatabaseHandler.Connection);

                var sqlReader = sqlCommand.ExecuteReader();

                while (sqlReader.Read())
                {
                    var item = new Models.Items.ItemModel();

                    item.ID = sqlReader.GetInt32("ID");
                    item.Pods = sqlReader.GetInt16("Weight");
                    item.Price = sqlReader.GetInt32("Price");
                    item.Type = sqlReader.GetInt16("Type");
                    item.Level = sqlReader.GetInt16("Level");
                    item.Jet = sqlReader.GetString("Stats");
                    item.Condistr = sqlReader.GetString("Conditions");

                    item.ParseWeaponInfos(sqlReader.GetString("WeaponInfo"));

                    item.ParseRandomJet();

                    lock(ItemsList)
                        ItemsList.Add(item);
                }

                sqlReader.Close();
            }

            Utilities.Loggers.StatusLogger.Write(string.Format("Loaded @'{0}' items@ from the database !", ItemsList.Count));
        }
Exemplo n.º 44
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();
        }
Exemplo n.º 45
0
        protected void Onayla(object sender, EventArgs e)
        {
            belge = h.InnerText;

            String connStr = System.Configuration.ConfigurationManager.ConnectionStrings["WebConnString"].ToString();

            using (conn = new MySql.Data.MySqlClient.MySqlConnection(connStr))
            {
                conn.Open();

                if (OnayRadio.SelectedValue == "Makaleyi Onayla")
                {
                    queryStr = "Update tasarimdersi.yazarmakale set onay = 'Hakem tarafından Onaylandı' WHERE makalepdf ='" + belge + "'";
                }
                else if (OnayRadio.SelectedValue == "Makaleyi Reddet")
                {
                    queryStr = "Update tasarimdersi.yazarmakale set onay = 'Hakem tarafından ONAYLANMADI' WHERE makalepdf ='" + belge + "'";
                }
                else if (OnayRadio.SelectedValue == "Makaleyi Onay Sürecinde Bırak")
                {
                    queryStr = "Update tasarimdersi.yazarmakale set onay = 'Hakem İncelemesinde' WHERE makalepdf ='" + belge + "'";
                }
                else
                {
                    queryStr = "Update tasarimdersi.yazarmakale set onay = 'Editör İncelemesinde' WHERE makalepdf ='" + belge + "'";
                }

                cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
                cmd.ExecuteReader();
                conn.Close();
                Response.Redirect(Request.RawUrl);
            }
        }
Exemplo n.º 46
0
        public List<Categoria> getCategoriaConProductosParaImprimirCodigos()
        {

            int totalCat = getTotalCategoria();
            ProductoFacade prodFac = new ProductoFacade();
            
            string consulta = "SELECT*FROM categoria";
            List<Categoria> listaCategoria = new List<Categoria>();

            MySqlCommand cmd = new MySqlCommand(consulta, getconexion.getConexion());
            MySqlDataReader read = cmd.ExecuteReader();

            while (read.Read())
            {

                if (prodFac.getProductosBynombreCategoria(read.GetString(1)).Count > 0)
                {
                    listaCategoria.Add(new Categoria(read.GetInt32(0), read.GetString(1), read.GetDateTime(2)));
                }
            }
            getconexion.CerrarConexion();

            return listaCategoria;

        }
Exemplo n.º 47
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);
        }
        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(); }
        }
Exemplo n.º 49
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();
            }
        }
    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!!";
        }
    }
Exemplo n.º 51
0
        public int GetStaffID(string loginName)
        {
            int id = 0;

            using (MySqlConnection connection = new MySqlConnection(GetConnection()))
            {
                MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand();
                cmd.Connection  = connection;
                cmd.CommandText = string.Format("SELECT staff_id FROM sakila.staff where first_name = '{0}'", loginName);
                try
                {
                    connection.Open();
                    MySqlDataReader myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                    while (myReader.Read())
                    {
                        id = myReader.GetInt32(0);
                        break;
                    }
                    myReader.Close();
                }
                finally
                {
                    connection.Close();
                }
            }
            return(id);
        }
Exemplo n.º 52
0
 private static void LoadCharacters()
 {
     Utilities.ConsoleStyle.Infos("Loading @characters@ ..");
     var query = new MySqlCommand("SELECT * FROM characters", DatabaseManager.Connection);
     var reader = query.ExecuteReader();
     while (reader.Read())
     {
         var character = new Models.Character()
         {
             ID = reader.GetInt32("id"),
             Account = reader.GetInt32("account"),
             Nickname = reader.GetString("nickname"),
             Level = reader.GetInt32("level"),
             Experience = reader.GetInt64("experience"),
             Sex = reader.GetInt32("sex"),
             Breed = reader.GetInt32("breed"),
             SkinColor = reader.GetInt32("skincolor"),
             HairColor = reader.GetInt32("haircolor"),
             PupilColor = reader.GetInt32("pupilcolor"),
             SkinColorFactor = reader.GetInt32("skincolorfactor"),
             HairColorFactor = reader.GetInt32("haircolorfactor"),
             Cloth = reader.GetInt32("cloth"),
             Face = reader.GetInt32("face"),
             Title = reader.GetInt32("title"),
         };
         Characters.Add(character);
     }
     reader.Close();
     Utilities.ConsoleStyle.Infos("Loaded @'" + Characters.Count + "'@ characters !");
 }
        public List <getAllDepts> OneEntName(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();
                string getString = "SELECT * FROM Dept_ProgramID WHERE DeptEntity = '" + als.ToString() + "';";
                var    d         = new List <getAllDepts>();
                MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(getString, conn);
                MySqlDataReader fetch_query             = cmd.ExecuteReader();
                while (fetch_query.Read())
                {
                    d.Add(
                        new getAllDepts(
                            fetch_query["DeptName"] != DBNull.Value ? fetch_query["DeptName"].ToString() : null,
                            fetch_query["DeptEntity"] != DBNull.Value ? fetch_query["DeptEntity"].ToString() : null,
                            fetch_query["DeptProgramID"] != DBNull.Value ? fetch_query["DeptProgramID"].ToString() : null
                            )
                        );
                }
                return(d);
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            { throw ex; }
            finally { conn.Close(); }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ManagerGeneralItemStagesGui"/> class.
        /// </summary>
        /// <param name="itemid">The itemid.</param>
        public ManagerGeneralItemStagesGui(string itemid)
        {
            //Login.close = 1;
            InitializeComponent();
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            this.itemID = itemid;
            try
            {
                MySqlConnection MySqlConn = new MySqlConnection(Login.Connectionstring);
                MySqlConn.Open();
                string Query1 = "select itemName from item where itemid='" + itemID + "'";
                MySqlCommand MSQLcrcommand1 = new MySqlCommand(Query1, MySqlConn);
                MSQLcrcommand1.ExecuteNonQuery();
                MySqlDataAdapter mysqlDAdp = new MySqlDataAdapter(MSQLcrcommand1);
                MySqlDataReader dr = MSQLcrcommand1.ExecuteReader();

                while (dr.Read())
                {
                    if (!dr.IsDBNull(0))
                    {
                        itemName = dr.GetString(0);
                    }

                }
                MySqlConn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            type_comboBox.Items.Add("רישום");
            type_comboBox.Items.Add("בעבודה");
            type_comboBox.Items.Add("תיקון");
            type_comboBox.Items.Add("פסול");
            type_comboBox.Items.Add("גמר ייצור");
            type_comboBox.Items.Add("הסתיים");
            type_comboBox.SelectedIndex = 0;
            itemidlabel.Content = itemID;
            itemnamelabel.Content = itemName;

            try
            {
                MySqlConnection MySqlConn = new MySqlConnection(Login.Connectionstring);
                MySqlConn.Open();
                string Query1 = ("SELECT itemStageOrder as `מספר שלב`,stageName as `שם שלב` ,stage_discription as `תאור השלב`  FROM item WHERE itemid='" + itemID + "'  and itemStatus='רישום' ");
                MySqlCommand MSQLcrcommand1 = new MySqlCommand(Query1, MySqlConn);
                MSQLcrcommand1.ExecuteNonQuery();
                MySqlDataAdapter mysqlDAdp = new MySqlDataAdapter(MSQLcrcommand1);
                dt.Clear();
                mysqlDAdp.Fill(dt);
                dataGrid1.ItemsSource = dt.DefaultView;
                mysqlDAdp.Update(dt);
                MySqlConn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 55
0
        public SignalProp getCurSigProp()
        {
            SignalProp   prop = null;
            String       sql  = " SELECT s.lampId, s.signalName, s.type, s.state, c.state as specState, direction, dir_to, s.ip FROM cursignal c LEFT JOIN signal s ON c.lampId=s.lampId AND c.type=1 ";
            MySqlCommand cmd  = new MySql.Data.MySqlClient.MySqlCommand(sql, myConn);

            System.Data.Common.DbDataReader reader = cmd.ExecuteReader();
            try
            {
                if (reader.Read())
                {
                    prop            = new SignalProp();
                    prop.SignalID   = reader.GetString(0).ToUpper();
                    prop.SignalName = DBStringToNormal(reader.GetString(1));
                    prop.Type       = reader.IsDBNull(2)? (byte)0 : (byte)reader.GetInt16(2);
                    prop.State      = reader.GetString(3);
                    prop.SpecState  = reader.IsDBNull(4) ? (byte)0 : (byte)reader.GetInt16(4);
                    prop.DirFrom    = reader.IsDBNull(5) ? (byte)0 : (byte)reader.GetInt16(5);
                    prop.DirTo      = reader.IsDBNull(6) ? (byte)0 : (byte)reader.GetInt16(6);
                    prop.Ip         = reader.GetString(7);
                }
                reader.Close();
            }
            catch (Exception e)
            {
                reader.Close();
                Trace.TraceError("get cur signal prop " + e.StackTrace);
            }

            return(prop);
        }
Exemplo n.º 56
0
        private static string pobierzDane(string name, string column)
        {
            var pos = "";

            try
            {
                string server = @"SERVER=localhost;PORT=3306;DATABASE=pizzeria;UID=pizzeria;";
                using (MySql.Data.MySqlClient.MySqlConnection connection = new MySql.Data.MySqlClient.MySqlConnection(server))
                {
                    MySql.Data.MySqlClient.MySqlCommand command = new MySql.Data.MySqlClient.MySqlCommand("SELECT " + column + " FROM Menu WHERE name LIKE '" + name + "'", connection);
                    connection.Open();
                    using (MySqlDataReader read = command.ExecuteReader())
                    {
                        while (read.Read())
                        {
                            pos = read[column].ToString();
                        }
                        connection.Close();
                    }
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                MessageBox.Show("Błąd." + ex, ex.ToString());
            }
            return(pos);
        }
Exemplo n.º 57
0
        protected void Page_Load(object sender, EventArgs e)    // Open the connection to the database, read data from a table, display it on the page
        {
            Globals.conn.Open();

            string query = "SELECT * FROM book";        // Change the 'book' table to a table name in your database

            var cmd    = new MySql.Data.MySqlClient.MySqlCommand(query, Globals.conn);
            var reader = cmd.ExecuteReader();

            //        lblMyOutput.Text = String.Empty;

            while (reader.Read())
            {
                var titleValue = reader["Title"];       // get data from the 'Title' column of the book table
                var isbnValue  = reader["isbn"];

                // Do something with the retrieved values
//             lblMyOutput.Text += "Book title is " + titleValue.ToString()
//                                                + " and its ISBN is " + isbnValue.ToString()
//                                              + "<br>";
            }


            searchTerm = Session["searchTerm"].ToString();
            searchMethod(searchTerm);
        }
Exemplo n.º 58
0
        public string GetSchedule(string phone, string ordernum)
        {
            con.Open();
            MySqlCommand cmd = new MySqlCommand("select TechnicianName, Phone, sdate,slotnumber,idtechnician,order_id  from fosimple.technician t  join fosimple.schedule s on s.technician_id = t.idTechnician join fosimple.orders o on o.idorders =s.order_id where idorders = " + ordernum + " and mobilenumber = '" + phone + "'", con);
            MySqlDataReader dr = cmd.ExecuteReader();

            string techname = "", ph = "", sdate = "", slot = "";
            int tid = 0;
            if (dr.Read())
            {
                techname = dr[0].ToString();
                ph = dr[1].ToString();
                sdate = dr[2].ToString();
                slot = dr[3].ToString();
               // tid = Convert.ToInt16(dr[4].ToString());
            }
            if(sdate != "")
            {
                if (Convert.ToDateTime(sdate) < DateTime.Now)
                {
                    techname = "Completed";
                }
                sdate = Convert.ToDateTime(sdate).Month.ToString() + "/" + Convert.ToDateTime(sdate).Day.ToString() + "/" + Convert.ToDateTime(sdate).Year.ToString();

            }
            dr.Dispose();

            con.Close();
            return techname + "##" + ph + "##" + sdate + "##" + slot;
        }
Exemplo n.º 59
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);
            }
        }
Exemplo 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();
                }
            }
        }