Esempio n. 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Home);
            session = new UserSessionManagement(Application.Context);

            button1   = FindViewById <Button>(Resource.Id.connect);
            textview1 = FindViewById <TextView>(Resource.Id.TextView1);
            textview2 = FindViewById <TextView>(Resource.Id.textView2);

            button1.Click += Button1_Click;


            if (session.checkLogin())
            {
                Finish();
            }

            Dictionary <string, string> user = session.getUserDetails();

            string name  = user[UserSessionManagement.KEY_NAME];
            string email = user[UserSessionManagement.KEY_EMAIL];

            MySqlConnection con = new MySqlConnection("Server=cl1-sql22.phpnet.org;Port=3306;database=yzi38822; User Id=yzi38822;Password=M0kTZX33pyO6;");

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }

            string query = "SELECT user,password FROM members WHERE user = '******'";

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

            if (reader.Read())
            {
                new AlertDialog.Builder(this)
                .SetMessage("Bienvenue " + (reader["user"].ToString()))
                .Show();
                StartActivity(typeof(Profil));
            }
            else
            {
                reader.Close();
            }
        }
Esempio n. 2
0
        public StartConcept()
        {
            InitializeComponent();
            this.local_program_version.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            SQLiteConnection connection = null;
            SQLiteDataReader reader     = null;

            try
            {
                connection = new SQLiteConnection(this.dbPath);
                connection.Open();
                reader = new SQLiteCommand("select content from version where id=1", connection).ExecuteReader();

                reader.Read();
                this.local_db_version.Text = reader["content"].ToString();
                reader.Close();
                connection.Close();
            }
            catch (Exception)
            {
                this.local_db_version.Text = "取版本号错";
            }

            MySqlConnection connection1 = new MySqlConnection("Database=zyg;Data Source=sirius0427.jios.org;User Id=cst;Password=q1w2e3r4t5Y^U&I*O(P);pooling=false;CharSet=utf8;port=3307");

            connection1.Open();
            MySqlDataReader reader1 = null;

            try
            {
                reader1 = new MySqlCommand("select content from version order by id", connection1).ExecuteReader();
                reader1.Read();
                this.server_program_version.Text = reader1["content"].ToString();
                reader1.Read();
                this.server_db_version.Text = reader1["content"].ToString();
            }
            catch (Exception)
            {
                MessageBox.Show("取不到数据库版本号");
            }
            finally
            {
                reader1.Close();
                connection1.Close();
            }
        }
        //Get the student's full name
        public static string getFullName(string username)
        {
            List <string> classlist = new List <string>();
            string        name      = "~N/A";

            try {
                Console.WriteLine("SELECT CONCAT(first_name,' ',last_name) FROM student WHERE login_id = '" + username + "';");
                MySqlDataReader reader = new MySqlCommand("SELECT CONCAT(first_name,' ',last_name) as name FROM student WHERE login_id = '" + username + "';", conn).ExecuteReader();
                while (reader.Read())
                {
                    name = reader.GetString("name");
                }
                reader.Close();
            } catch (Exception e) {
                Console.WriteLine(e.StackTrace);
            }
            return(name);
        }
Esempio n. 4
0
        public static void GetFromDB(List <Disciple> DataList, string str)
        {
            conn.Open();
            MySqlDataReader reader = new MySqlCommand
            {
                CommandText = str, Connection = conn
            }.ExecuteReader();

            while (reader.Read())
            {
                DataList.Add(new Disciple(
                                 ((int)reader["DID"]).ToString(),
                                 (string)reader["Title"],
                                 (string)reader["ZvitForm"],
                                 ((int)reader["HoursCount"]).ToString()));
            }
            reader.Close();
            conn.Close();
        }
Esempio n. 5
0
        public static void GetFromDB(List <Res4Storage> DataList, string str)
        {
            conn.Open();
            MySqlDataReader reader = new MySqlCommand
            {
                CommandText = str, Connection = conn
            }.ExecuteReader();

            while (reader.Read())
            {
                DataList.Add(new Res4Storage(
                                 (string)reader["SName"],
                                 (string)reader["Surname"],
                                 (string)reader["GName"],
                                 ((int)reader["Course"]).ToString()));
            }
            reader.Close();
            conn.Close();
        }
Esempio n. 6
0
        static private void genReport(string start, string end)
        {
            MySqlConnection connect;
            MySqlDataReader dataReader;

            try
            {
                connect = new MySqlConnection(ConfigurationManager.AppSettings["connectionStr"]);
                connect.Open();
                Console.WriteLine("Connected!");
                string sqlQuery = "SELECT order_date,store_name,quantity,list_price,first_name,last_name FROM orders " +
                                  "INNER JOIN stores ON stores.store_id = orders.store_id " +
                                  "INNER JOIN order_items ON order_items.order_id = orders.order_id " +
                                  "INNER JOIN customers ON orders.customer_id = customers.customer_id " +
                                  "WHERE order_date BETWEEN " + "'" + start + "'" + " AND " + "'" + end + "'";

                dataReader = new MySqlCommand(sqlQuery, connect).ExecuteReader();
                var columns = new List <string>();
                for (int i = 0; i < dataReader.FieldCount; i++)
                {
                    columns.Add(dataReader.GetName(i));
                }
                string colOutput = string.Format("{0,-10}\t|{1,-10}\t| {2,-10} | {3,-10} | {4,-10} | {5,-10}",
                                                 columns[0], columns[1], columns[2], columns[3], columns[4], columns[5]);
                Console.WriteLine(colOutput);
                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        string output = string.Format("{0} | {1} | {2} | {3} | {4} | {5}",
                                                      dataReader.GetString(0), dataReader.GetString(1), dataReader.GetString(2),
                                                      dataReader.GetString(3), dataReader.GetString(4), dataReader.GetString(5));
                        Console.WriteLine(output);
                    }
                }
                dataReader.Close();
                connect.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Conncection Error!");
            }
        }
Esempio n. 7
0
        public void LoadBanedIP(ref object banips)
        {
            MySqlConnection connection = DAO.GetConnection();

            try
            {
                connection.Open();
                string          cmdText         = "SELECT * FROM banned_ip";
                MySqlDataReader mySqlDataReader = new MySqlCommand(cmdText, connection).ExecuteReader();
                while (mySqlDataReader.Read())
                {
                    string   @string  = mySqlDataReader.GetString("mask");
                    DateTime dateTime = mySqlDataReader.GetDateTime("time_end");
                    object[] array;
                    bool[]   array2;
                    NewLateBinding.LateCall(banips, null, "Add", array = new object[2]
                    {
                        @string,
                        new BannedIP(@string, dateTime)
                    }, null, null, array2 = new bool[2]
                    {
                        true,
                        false
                    }, IgnoreReturn: true);
                    if (array2[0])
                    {
                        @string = (string)Conversions.ChangeType(RuntimeHelpers.GetObjectValue(array[0]), typeof(string));
                    }
                }
                mySqlDataReader.Close();
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                Exception ex2 = ex;
                log.Error((object)ex2);
                ProjectData.ClearProjectError();
            }
            finally
            {
                connection.Close();
            }
        }
Esempio n. 8
0
 public static bool SearchUserByName(string username)
 {
     using (MySqlDataReader reader = new MySqlCommand("SELECT * FROM sg_account", Manager.MySqlConnection).ExecuteReader())
     {
         while (reader.Read())
         {
             if (username == (String)reader["char_name"])
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         reader.Close();
         return(false);
     }
 }
Esempio n. 9
0
        public static List <Dictionary <string, string> > CheckStockForSupplier(MySqlConnection conn)
        {
            List <Dictionary <string, string> > List = new List <Dictionary <string, string> >();

            conn.Open();

            string          query  = "SELECT * FROM Piece";
            MySqlDataReader reader = new MySqlCommand(query, conn).ExecuteReader();

            while (reader.Read())
            {
                Dictionary <string, string> component = new Dictionary <string, string>
                {
                    { "Ref", reader["Ref"].ToString() },
                    { "Code", reader["Code"].ToString() },
                    { "Dimensions", reader["Dimensions(cm)"].ToString() },
                    { "Height", reader["hauteur"].ToString() },
                    { "Width", reader["largeur"].ToString() },
                    { "Depth", reader["profondeur"].ToString() },
                    { "Color", reader["Couleur"].ToString() },
                    { "CustomerPrice", reader["Prix-Client"].ToString() },
                    { "Stock", reader["Enstock"].ToString() },
                    { "StockMin", reader["Stock minimum"].ToString() },
                    { "SupplierOnePrice", reader["Prix-Fourn 1"].ToString() },
                    { "SupplierTwoPrice", reader["Prix-Fourn2"].ToString() },
                    { "SupplierOneDelay", reader["Delai-Fourn 1"].ToString() },
                    { "SupplierTwoDelay", reader["Delai-Fourn2"].ToString() }
                };

                int inStock  = int.Parse(component["Stock"].ToString());
                int minStock = int.Parse(component["StockMin"].ToString());

                if (inStock < minStock)
                {
                    List.Add(component);
                }
            }

            reader.Close();

            conn.Close();
            return(List);
        }
Esempio n. 10
0
 internal static PlayerData GetPlayerData(string username)
 {
     if (IsConnected())
     {
         MySqlDataReader rdr = new MySqlCommand($"SELECT * FROM player_data WHERE name = '{username}'", con).ExecuteReader();
         PlayerData      p   = new PlayerData();
         while (rdr.Read())
         {
             p.name           = rdr.GetString(0);
             p.wins           = rdr.GetInt32(1);
             p.kills          = rdr.GetInt32(2);
             p.deaths         = rdr.GetInt32(3);
             p.tasksCompleted = rdr.GetInt32(4);
         }
         rdr.Close();
         return(p);
     }
     return(null);
 }
Esempio n. 11
0
        public static void GetFromDB(List <Groups> DataList, string str)
        {
            conn.Open();
            MySqlDataReader reader = new MySqlCommand
            {
                CommandText = str, Connection = conn
            }.ExecuteReader();

            while (reader.Read())
            {
                DataList.Add(new Groups(
                                 ((int)reader["GID"]).ToString(),
                                 ((int)reader["Starosta"]).ToString(),
                                 ((int)reader["FID"]).ToString(),
                                 (string)reader["GName"],
                                 ((bool)reader["IsTemp"])?"True":"False"));
            }
            reader.Close();
            conn.Close();
        }
Esempio n. 12
0
        public List <string>[] Select(long n, string query)
        {
            List <string>[] listArray = new List <string> [n];
            int             index     = 0;

            while (index < n)
            {
                listArray[index] = new List <string>();
                index++;
            }
            if (this.OpenConnection())
            {
                MySqlDataReader reader = new MySqlCommand(query, this.connection).ExecuteReader();
                try
                {
                    while (reader.Read())
                    {
                        for (index = 0; index < n; index++)
                        {
                            if (reader.GetString(index).Equals((string)null))
                            {
                                listArray[index].Add("");
                            }
                            else
                            {
                                listArray[index].Add(reader.GetString(index));
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Check Again!");
                }
                reader.Close();
                this.CloseConnection();
                return(listArray);
            }
            return(listArray);
        }
Esempio n. 13
0
        public List <Dictionary <string, object> > custom(string query, string[] _fields = null)
        {
            List <Dictionary <string, object> > result = new List <Dictionary <string, object> >();
            MySqlDataReader reader = new MySqlCommand(query, this.con).ExecuteReader();

            string[] useFields = this.fields.ToArray();
            if (_fields != null)
            {
                useFields = _fields;
            }
            while (reader.Read())
            {
                Dictionary <string, object> row = new Dictionary <string, object>();
                foreach (string field in useFields)
                {
                    row.Add(field, reader[field]);
                }
                result.Add(row);
            }
            reader.Close();
            return(result);
        }
Esempio n. 14
0
        public MembersPage()
        {
            this.InitializeComponent();

            string content = null;
            string sql     = "SELECT * FROM web.xe_documents WHERE document_srl=163";

            App.conn.Open();

            MySqlDataReader connreader = new MySqlCommand(sql, App.conn).ExecuteReader();

            while (connreader.Read())
            {
                content = connreader["content"].ToString();
            }

            content = HtmlTo_String(content);
            ContentTextBlock.Text = content;

            connreader.Close();
            App.conn.Close();
        }
Esempio n. 15
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            var parameters = e.Parameter as DocumentsInfo;

            string date   = null;
            string userID = null;

            docsNum = parameters.docNumber;
            string sql = "SELECT * FROM web.xe_documents WHERE document_srl=\"" + docsNum + "\"";

            App.conn.Open();

            MySqlDataReader connreader = new MySqlCommand(sql, App.conn).ExecuteReader();

            while (connreader.Read())
            {
                title   = connreader["title"].ToString();
                name    = connreader["nick_name"].ToString();
                date    = connreader["last_update"].ToString().Substring(0, 4) + "." + connreader["last_update"].ToString().Substring(4, 2) + "." + connreader["last_update"].ToString().Substring(6, 2);
                content = connreader["content"].ToString();
                userID  = connreader["user_id"].ToString();
            }
            TitleTextBlock.Text = title;
            NameTextBlock.Text  = name;
            DateTextBlock.Text  = date;
            //content HTML -> string
            content = HtmlTo_String(content);
            ContentTextBlock.Text = content;

            connreader.Close();
            App.conn.Close();

            if (userID != App.currentUserInfo.currentUserID)
            {
                EditButton.IsEnabled   = false;
                DeleteButton.IsEnabled = false;
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Get all movie genres from the database
        /// </summary>
        /// <returns>A String list contains all the genres</returns>
        public List <String> GetGenreStringList()
        {
            List <String>   list = new List <String>();
            MySqlConnection conn = new MySqlConnection(connStr);

            try
            {
                conn.Open();
                MySqlDataReader reader = new MySqlCommand("SELECT DISTINCT(GENRE) FROM MOVIE", conn).ExecuteReader();

                while (reader.Read())
                {
                    list.Add(reader.GetString("genre"));
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            conn.Close();
            return(list);
        }
Esempio n. 17
0
        public List <Dictionary <string, object> > SelectAll(string sql)
        {
            var allValues = new List <Dictionary <string, object> >();

            lock (Lock)
            {
                try
                {
                    MySqlDataReader dataReader  = new MySqlCommand(sql, Connection).ExecuteReader();
                    DataTable       schemaTable = null;
                    while (dataReader.Read())
                    {
                        allValues.Add(GetValues(dataReader, schemaTable));
                    }
                    dataReader.Close();
                }
                catch (MySqlException ex)
                {
                    Log.Warn("MySQL", ex);
                }
            }

            return(allValues);
        }
Esempio n. 18
0
        ///
        /// \brief Constructor for the GenConfig page.
        ///
        /// \details <b>Details</b>
        /// This method is the constructor for the GenConfig page. It
        /// It queries the database for all GenConfig options and then
        /// displays them in TextBoxes that are in GenConfig.xaml.
        ///
        /// \param none - This method has no parameters.
        ///
        /// \return <b>void</b> - This method doesn't return anything.
        ///
        public GenConfig()
        {
            InitializeComponent();

            //MySqlCommand displayTheCarrier = new MySqlCommand(genConfigQuery, connectToDatabase).ExecuteReader();

            // Open connection to the TMS database and create the query string
            MySqlConnection connectToDatabase = DAL.OpenDatabaseConnection(DAL.ConnectionString_tms);
            string          genConfigQuery    = "SELECT * FROM GenConfigOptions";
            // Execute the query
            MySqlDataReader reader = new MySqlCommand(genConfigQuery, connectToDatabase).ExecuteReader();

            try
            {
                //Read the information in the database and display in textboxes
                while (reader.Read())
                {
                    var targettingIPAddress = reader.GetString("TargetIPAddress");
                    var CommPorts           = reader.GetString("CommPorts");

                    //LogFileDirectory.Text = logDirectory;
                    LogFileDirectory.Text = Logger.LogPath_m;
                    TargetingIP.Text      = targettingIPAddress;
                    TargetingPort.Text    = CommPorts;
                }
            }
            catch (MySqlException configLoad_e)
            {
                Logger.Log("An error has occurred while loading General Configuration Options from the TMS database.", configLoad_e.Message);
            }
            finally
            {
                // Always call Close when done reading.
                reader.Close();
            }
        }
Esempio n. 19
0
        public void Form1_Load(object sender, EventArgs e)
        {
            {
                //Загрузка строки подключения
                if (!File.Exists("connection.txt"))
                {
                    File.Create("connection.txt");
                    MetroFramework.MetroMessageBox.Show(this, "Это первый запуск программы, задайте настройки подключения", "Внимание");
                    return;
                }
                else
                {
                    ConnectionString = File.ReadAllText("connection.txt");
                }
            }


            try
            {
                MySqlConnection conn = new MySqlConnection(ConnectionString);
                conn.Open();
                MySqlDataReader reader = new MySqlCommand($"SELECT * FROM manufacturer_warehouses;", conn).ExecuteReader();

                while (reader.Read())
                {
                    Storehouse.Items.Add(reader[2].ToString());
                }

                reader.Close();
                conn.Close();
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, "Невозможно подключится к серверу, обратитесь к администратору", "Ошибка подключения");
            }
        }
Esempio n. 20
0
        // Token: 0x060000E9 RID: 233 RVA: 0x0001695C File Offset: 0x00014B5C
        public XElement Serialize(Client User)
        {
            XElement result2;

            using (MySqlConnection result = SQL.GetConnection().GetAwaiter().GetResult())
            {
                int num = 0;
                using (MySqlDataReader mySqlDataReader = new MySqlCommand("SELECT ID FROM clans ORDER BY Points DESC;", result).ExecuteReader())
                {
                    if (mySqlDataReader.HasRows)
                    {
                        mySqlDataReader.Read();
                        try
                        {
                            while (mySqlDataReader.Read())
                            {
                                num++;
                                if (mySqlDataReader.GetInt64(0) == this.ID)
                                {
                                    mySqlDataReader.Close();
                                    break;
                                }
                            }
                            mySqlDataReader.Close();
                        }
                        catch
                        {
                        }
                    }
                }
                this.Points = 0;
                XElement xelement = new XElement("clan");
                try
                {
                    xelement.Add(new XAttribute("name", this.Name));
                    xelement.Add(new XAttribute("description", Convert.ToBase64String(Encoding.UTF8.GetBytes(this.Description))));
                    xelement.Add(new XAttribute("clan_id", this.ID));
                    xelement.Add(new XAttribute("creation_date", this.CreationTime));
                    xelement.Add(new XAttribute("leaderboard_position", num));
                    Client client = ArrayList.OnlineUsers.Find((Client Attribute) => Attribute.Player.Nickname == this.LeaderName);
                    if (client != null)
                    {
                        xelement.Add(new XAttribute("master_badge", client.Player.BannerBadge));
                        xelement.Add(new XAttribute("master_stripe", client.Player.BannerStripe));
                        xelement.Add(new XAttribute("master_mark", client.Player.BannerMark));
                    }
                    else
                    {
                        Player player = new Player
                        {
                            Nickname = this.LeaderName
                        };
                        player.Clan.ID = this.ID;
                        if (player.Load(false).Result)
                        {
                            xelement.Add(new XAttribute("master_badge", player.BannerBadge));
                            xelement.Add(new XAttribute("master_stripe", player.BannerStripe));
                            xelement.Add(new XAttribute("master_mark", player.BannerMark));
                        }
                    }
                    foreach (XElement content in this.ClanMembers.Elements("clan_member_info"))
                    {
                        xelement.Add(content);
                    }
                    xelement.Add(new XAttribute("clan_points", User.Player.Clan.Points));
                    User.Player.Clan.ID = this.ID;
                    User.Player.Save();
                    result2 = xelement;
                }
                catch (Exception)
                {
                    result2 = xelement;
                }
            }
            return(result2);
        }
Esempio n. 21
0
        private void updateUser()
        {
            String surname            = textbox_surname.Text;
            String surname_col        = "";
            String type               = combobox_clienttype.SelectedIndex.ToString();
            String type_col           = "";
            String business_name      = textBox_business_name.Text;
            String business_name_col  = "";
            String vat_id_1           = textBox_vat_id.Text;
            String vat_id_1_col       = "";
            String vat_id_2           = textBox_vat_id_2.Text;
            String vat_id_2_col       = "";
            String vat_id_3           = textBox_vat_id_3.Text;
            String vat_id_3_col       = "";
            String address_street     = textBox_address_route.Text;
            String address_street_col = "";
            String number             = textBox_address_number.Text;
            String number_col         = "";
            String city               = textBox_address_city.Text;
            String city_col           = "";
            String region             = textBox_address_region.Text;
            String region_col         = "";
            String phone              = textBox_phone.Text;
            String phone_col          = "";
            String mail               = textBox_mail_address.Text;
            String mail_col           = "";

            if (surname != "")
            {
                surname     = "\"" + surname + "\"";
                surname_col =
                    ",`"
                    + Properties.Settings.Default.col_customer_surname + "`=";
            }

            if (type != "")
            {
                type_col =
                    ",`"
                    + Properties.Settings.Default.col_customer_type + "`=";
            }

            if (business_name != "")
            {
                business_name     = "\"" + business_name + "\"";
                business_name_col =
                    ",`"
                    + Properties.Settings.Default.col_customer_business_name + "`=";
            }

            if (vat_id_1 != "")
            {
                vat_id_1     = "\"" + vat_id_1 + "\"";
                vat_id_1_col =
                    ",`"
                    + Properties.Settings.Default.col_customer_vat_id_1 + "`=";
            }

            if (vat_id_2 != "")
            {
                vat_id_2     = "\"" + vat_id_2 + "\"";
                vat_id_2_col =
                    ",`"
                    + Properties.Settings.Default.col_customer_vat_id_2 + "`=";
            }

            if (vat_id_3 != "")
            {
                vat_id_3     = "\"" + vat_id_3 + "\"";
                vat_id_3_col =
                    ",`"
                    + Properties.Settings.Default.col_customer_vat_id_3 + "`=";
            }

            if (address_street != "")
            {
                address_street     = "\"" + address_street + "\"";
                address_street_col =
                    ",`"
                    + Properties.Settings.Default.col_customer_address_street + "`=";
            }
            if (number != "")
            {
                number     = "\"" + number + "\"";
                number_col =
                    ",`"
                    + Properties.Settings.Default.col_customer_address_number + "`=";
            }


            if (city != "")
            {
                city     = "\"" + city + "\"";
                city_col =
                    ",`"
                    + Properties.Settings.Default.col_customer_address_city + "`=";
            }


            if (region != "")
            {
                region     = "\"" + region + "\"";
                region_col =
                    ",`"
                    + Properties.Settings.Default.col_customer_address_region + "`=";
            }


            if (phone != "")
            {
                phone     = "\"" + phone + "\"";
                phone_col =
                    ",`"
                    + Properties.Settings.Default.col_customer_phone + "`=";
            }


            if (mail != "")
            {
                mail     = "\"" + mail + "\"";
                mail_col =
                    ",`"
                    + Properties.Settings.Default.col_customer_mail_address + "`=";
            }



            string query =
                "UPDATE `" + Properties.Settings.Default.customers_table_name
                + "` SET `"
                + Properties.Settings.Default.col_customer_name
                + "`="
                + '\"'
                + textbox_name.Text
                + '\"'
                + surname_col
                + surname
                + type_col
                + type
                + business_name_col
                + business_name
                + vat_id_1_col
                + vat_id_1
                + vat_id_2_col
                + vat_id_2
                + vat_id_3_col
                + vat_id_3
                + address_street_col
                + address_street
                + number_col
                + number
                + city_col
                + city
                + region_col
                + region
                + phone_col
                + phone
                + mail_col
                + mail
                + " WHERE `"
                + Properties.Settings.Default.col_customers_customer_id
                + "`="
                + customer_index.ToString();

            Debug.WriteLine(query);
            var reader = new MySqlCommand(query, dBConnection.Connection).ExecuteReader();

            reader.Close();
        }
        private void сдатьНакладнуюToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (InputInvoices.SelectedItems.Count == 0)
            {
                return;
            }
            if (InputInvoices.SelectedItems[0].SubItems[6].Text.Length > 1)
            {
                return;                                                             //Если уже сдана
            }
            MySqlConnection connection = new MySqlConnection(Properties.Resources.MySqlConnectionString);

            try
            {
                connection.Open();

                List <string> cells = new List <string>();

                {
                    //Получаем свободные складские ячейки
                    MySqlDataReader reader = new MySqlCommand($"SELECT `WarehouseCell`.`ID` FROM `WarehouseCell` WHERE `WarehouseCell`.`ID` NOT IN (SELECT `technique`.`Cell_Id` FROM technique)", connection).ExecuteReader();
                    while (reader.Read())
                    {
                        cells.Add(reader[0].ToString());
                    }
                    reader.Close();
                }

                if (cells.Count == 0)
                {
                    MetroFramework.MetroMessageBox.Show(this, "Нет свободных складских ячеек", "Предупреждение");
                    connection.Close();
                    return;
                }

                CloseInputInvoice CloseInvoiceForm = new CloseInputInvoice(cells);
                CloseInvoiceForm.ShowDialog();

                if (!CloseInvoiceForm.OK)
                {
                    return;
                }

                {
                    //Обновляем накладную в таблицe
                    new MySqlCommand($"UPDATE Invoices SET `Passed the invoice` = '{FIO}' WHERE Number = {InputInvoices.SelectedItems[0].SubItems[0].Text}", connection).ExecuteNonQuery();
                }

                {
                    //Добавляем в таблицу товаров на складе
                    new MySqlCommand($"INSERT INTO technique VALUES ('{warehouseId}', '{CloseInvoiceForm.metroComboBox1.Text}', '{InputInvoices.SelectedItems[0].SubItems[1].Text}', '{InputInvoices.SelectedItems[0].SubItems[2].Text}', '{InputInvoices.SelectedItems[0].SubItems[3].Text}')", connection).ExecuteNonQuery();
                }

                {
                    //Изменяем запись
                    InputInvoices.SelectedItems[0].SubItems[6].Text = FIO;

                    //Добавляем в лист товаров
                    ListViewItem item = TovarsListView.Items.Add(InputInvoices.SelectedItems[0].SubItems[1].Text);
                    item.SubItems.Add(CloseInvoiceForm.metroComboBox1.Text);
                    item.SubItems.Add(InputInvoices.SelectedItems[0].SubItems[2].Text);
                    item.SubItems.Add(InputInvoices.SelectedItems[0].SubItems[3].Text);
                }

                connection.Close();
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, $"Ошибка \n{ex.Message}", "Ошибка");
            }
        }
        private void WarehouseBrowser_Load(object sender, EventArgs e)
        {
            MySqlConnection conn = new MySqlConnection(Properties.Resources.MySqlConnectionString);

            conn.Open();

            {
                //Заполнение таблицы товаров
                MySqlDataReader reader = new MySqlCommand($"SELECT * FROM technique WHERE Warehouse_ID = '{warehouseId}';", conn).ExecuteReader();
                while (reader.Read())
                {
                    ListViewItem item = TovarsListView.Items.Add(reader[2].ToString());

                    item.SubItems.Add(reader[1].ToString());
                    item.SubItems.Add(reader[3].ToString());
                    item.SubItems.Add(reader[4].ToString());
                }

                reader.Close();
            }


            {
                //Заполнение приходных накладных
                MySqlDataReader reader = new MySqlCommand($"SELECT * FROM Invoices WHERE Warehouse_ID = '{warehouseId}' AND Type = 'Приходная';", conn).ExecuteReader();
                while (reader.Read())
                {
                    ListViewItem item = InputInvoices.Items.Add(reader[0].ToString());
                    item.SubItems.Add(reader[2].ToString());
                    item.SubItems.Add(reader[3].ToString());
                    item.SubItems.Add(reader[4].ToString());
                    item.SubItems.Add(reader[5].ToString());
                    item.SubItems.Add(reader[6].ToString());
                    item.SubItems.Add(reader[7].ToString());
                }

                reader.Close();
            }

            {
                //Заполнение расходных накладных
                MySqlDataReader reader = new MySqlCommand($"SELECT * FROM Invoices WHERE Warehouse_ID = '{warehouseId}' AND Type = 'Расходная';", conn).ExecuteReader();
                while (reader.Read())
                {
                    ListViewItem item = OutputListView.Items.Add(reader[0].ToString());
                    item.SubItems.Add(reader[2].ToString());
                    item.SubItems.Add(reader[3].ToString());
                    item.SubItems.Add(reader[4].ToString());
                    item.SubItems.Add(reader[5].ToString());
                    item.SubItems.Add(reader[6].ToString());
                    item.SubItems.Add(reader[7].ToString());
                }

                reader.Close();
            }

            {
                //Заполнение таблицы складских ячеек
                MySqlDataReader reader = new MySqlCommand($"SELECT * FROM WarehouseCell WHERE Warehouse_ID = '{warehouseId}';", conn).ExecuteReader();
                while (reader.Read())
                {
                    ListViewItem item = WarehouseCell.Items.Add(reader[1].ToString());
                    item.SubItems.Add($"{reader[2].ToString()}-{reader[3].ToString()}-{reader[4].ToString()}-{reader[5].ToString()}-{reader[6].ToString()}");
                    item.SubItems.Add(reader[2].ToString());
                    item.SubItems.Add(reader[3].ToString());
                    item.SubItems.Add(reader[4].ToString());
                    item.SubItems.Add(reader[5].ToString());
                    item.SubItems.Add(reader[6].ToString());
                }

                reader.Close();
            }


            {
                //Заполнение таблицы внутренних переводов
                MySqlDataReader reader = new MySqlCommand($"SELECT * FROM Transfers WHERE Warehouse_ID = '{warehouseId}';", conn).ExecuteReader();
                while (reader.Read())
                {
                    ListViewItem item = TransferOperations.Items.Add(reader[1].ToString());
                    item.SubItems.Add(reader[2].ToString());
                    item.SubItems.Add(reader[3].ToString());
                    item.SubItems.Add(reader[4].ToString());
                    item.SubItems.Add(reader[5].ToString());
                }

                reader.Close();
            }



            UpdateCellSize();
            conn.Close();
        }
        private void добавитьПриходнуюНакладнуюToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MySqlConnection connection = new MySqlConnection(Properties.Resources.MySqlConnectionString);
            List <string>   types      = new List <string>();

            {
                //Запись в список всех типов техники, которые доступны для этого склада
                try
                {
                    connection.Open();

                    MySqlDataReader reader = new MySqlCommand($"SELECT Name FROM technique_types WHERE Warehouse_ID = '{warehouseId}'", connection).ExecuteReader();

                    while (reader.Read())
                    {
                        types.Add(reader[0].ToString());
                    }

                    reader.Close();
                    connection.Close();
                }
                catch (Exception ex)
                {
                    MetroFramework.MetroMessageBox.Show(this, $"{ex.Message}", "Ошибка получения типов");
                    return;
                }
            }

            AddInputInvoice AddForm = new AddInputInvoice(types);

            AddForm.ShowDialog();

            if (!AddForm.OK)
            {
                return;
            }

            try
            {
                connection.Open();
                new MySqlCommand($"INSERT INTO Invoices VALUES (null, '{warehouseId}', '{AddForm.TechniqueComboBox.Text}', '{AddForm.NameTextBox.Text}', {AddForm.CountTextBox.Text}, '{DateTime.Now.ToString()}', '{FIO}', '', 'Приходная') ", connection).ExecuteNonQuery();
                connection.Close();


                {
                    ListViewItem item = null;

                    item = InputInvoices.Items.Count == 0 ? InputInvoices.Items.Add("1") : InputInvoices.Items.Add((int.Parse(InputInvoices.Items[InputInvoices.Items.Count - 1].SubItems[0].Text) + 1).ToString());

                    item.SubItems.Add(AddForm.TechniqueComboBox.Text);
                    item.SubItems.Add(AddForm.NameTextBox.Text);
                    item.SubItems.Add(AddForm.CountTextBox.Text);
                    item.SubItems.Add(DateTime.Now.ToString());
                    item.SubItems.Add(FIO);
                    item.SubItems.Add("");
                }
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, $"{ex.Message}", "Ошибка");
            }
        }
        private void metroButton1_Click(object sender, EventArgs e)
        {
            //Вывести статистику
            chart1.Series["Количество"].Points.Clear();
            DateTime[] diapazon = new DateTime[] { this.metroDateTime1.Value, this.metroDateTime2.Value };

            MySqlConnection conn = new MySqlConnection(Properties.Resources.MySqlConnectionString);

            try
            {
                conn.Open();
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, ex.Message, "Ошибка");
                return;
            }

            int Day = 0;

            MySqlDataReader readbuff = null;

            switch (metroComboBox1.Text)
            {
            case "Количеству приходных накладных":
            {
                for (DateTime active = metroDateTime1.Value; active.Month <= metroDateTime2.Value.Month && active.Day <= metroDateTime2.Value.Day; active = active.AddDays(1), Day++)
                {
                    readbuff = new MySqlCommand($"SELECT * FROM Invoices WHERE Type = 'Приходная' ORDER BY CreateDate", conn).ExecuteReader();

                    //MessageBox.Show(active.ToString());
                    int count = 0;

                    while (readbuff.Read())
                    {
                        if (DateTime.Parse(readbuff[5].ToString()).Year == active.Year &&
                            DateTime.Parse(readbuff[5].ToString()).Month == active.Month &&
                            DateTime.Parse(readbuff[5].ToString()).Day == active.Day)
                        {
                            count++;
                        }
                    }

                    chart1.Series["Количество"].Points.Add(count, Day);
                    readbuff.Close();
                }

                break;
            }

            case "Количеству расходных накладных":
            {
                for (DateTime active = metroDateTime1.Value; active.Month <= metroDateTime2.Value.Month && active.Day <= metroDateTime2.Value.Day; active = active.AddDays(1), Day++)
                {
                    readbuff = new MySqlCommand($"SELECT * FROM Invoices WHERE Type = 'Расходная' ORDER BY CreateDate", conn).ExecuteReader();

                    int count = 0;

                    while (readbuff.Read())
                    {
                        if (DateTime.Parse(readbuff[5].ToString()).Year == active.Year &&
                            DateTime.Parse(readbuff[5].ToString()).Month == active.Month &&
                            DateTime.Parse(readbuff[5].ToString()).Day == active.Day)
                        {
                            count++;
                        }
                    }

                    chart1.Series["Количество"].Points.Add(count, Day);
                    readbuff.Close();
                }

                break;
            }
            }


            conn.Close();
        }
Esempio n. 26
0
 private void Btn_AjandekHozzaadas_Click(object sender, EventArgs e)
 {
     if (Btn_AjandekHozzaadas.Text == "Ajándék hozzáadása")
     {
         try
         {
             string ajandekNev = TxtBox_AjandekNev.Text;
             string ajandekUzlet;
             if (TxtBox_AjandekUzlet.ForeColor == Color.Gray)
             {
                 ajandekUzlet = null;
             }
             else
             {
                 ajandekUzlet = TxtBox_AjandekUzlet.Text;
             }
             string          sql = "INSERT INTO ajandek.ajandek(nev,uzlet) VALUES('" + ajandekNev + "','" + ajandekUzlet + "');";
             MySqlDataReader reader;
             reader = new MySqlCommand(sql, conn).ExecuteReader();
             while (reader.Read())
             {
             }
             reader.Close();
             ajandekListBox.Items.Clear();
             AdatBetoltes();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     else
     {
         try
         {
             string ajandekNev = TxtBox_AjandekNev.Text;
             string ajandekUzlet;
             int    ajandekID = ((Ajandek)ajandekListBox.SelectedItem).Id;
             if (TxtBox_AjandekUzlet.ForeColor == Color.Gray)
             {
                 ajandekUzlet = null;
             }
             else
             {
                 ajandekUzlet = TxtBox_AjandekUzlet.Text;
             }
             string          sql = "UPDATE ajandek SET nev='" + ajandekNev + "', uzlet='" + ajandekUzlet + "' WHERE id = " + ajandekID + ";";
             MySqlDataReader reader;
             reader = new MySqlCommand(sql, conn).ExecuteReader();
             while (reader.Read())
             {
             }
             reader.Close();
             ajandekListBox.Items.Clear();
             AdatBetoltes();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     TxtBox_AjandekNev.Text        = "Ajándék neve";
     TxtBox_AjandekNev.ForeColor   = Color.Gray;
     TxtBox_AjandekUzlet.Text      = "Üzlet neve";
     TxtBox_AjandekUzlet.ForeColor = Color.Gray;
 }
Esempio n. 27
0
            internal static Dictionary <string, object> Get(int CharacterID)
            {
                Dictionary <string, object> CharacterData = new Dictionary <string, object>();

                MySqlDataReader ResultReader;

                ResultReader = new MySqlCommand($"select * FROM usercharacter WHERE UserCharacterID = {CharacterID}")
                {
                    Connection = Connection
                }.ExecuteReader();

                ResultReader.Read();

                CharacterData.Add("CharacterID", ResultReader.GetInt64(0));
                CharacterData.Add("Name", ResultReader.GetString(2)); //The 0 here is an Ordinal
                CharacterData.Add("GuildID", ResultReader.GetInt64(3));
                CharacterData.Add("Credits", ResultReader.GetInt64(4));
                CharacterData.Add("LastInInstanceID", ResultReader.GetInt16(5));
                CharacterData.Add("LastInInstance", ResultReader.GetInt64(6));
                CharacterData.Add("PositionX", ResultReader.GetFloat(7));
                CharacterData.Add("PositionY", ResultReader.GetFloat(8));
                CharacterData.Add("Deleted", ResultReader.GetBoolean(10));

                ResultReader.Close();

                ResultReader = new MySqlCommand($"select * FROM usercharacterxp WHERE UserCharacterID = {CharacterID}")
                {
                    Connection = Connection
                }.ExecuteReader();

                ResultReader.Read();
                CharacterData.Add("MageXP", ResultReader.GetInt64(1));
                CharacterData.Add("HealerXP", ResultReader.GetInt64(2));
                CharacterData.Add("AttackerXP", ResultReader.GetInt64(3));
                CharacterData.Add("TankXP", ResultReader.GetInt64(4));
                CharacterData.Add("WoodcuttingXP", ResultReader.GetInt64(5));
                CharacterData.Add("CombatXP", ResultReader.GetInt64(6));

                ResultReader.Close();

                ResultReader = new MySqlCommand($"select * FROM usercharacteroutfit WHERE CharacterID = {CharacterID} AND IsEquipped = 1")
                {
                    Connection = Connection
                }.ExecuteReader();

                ResultReader.Read();
                CharacterData.Add("HeadIndex", ResultReader.GetInt16(3));
                CharacterData.Add("HeadColor", ResultReader.GetString(4));
                CharacterData.Add("HairIndex", ResultReader.GetInt16(5));
                CharacterData.Add("HairColor", ResultReader.GetString(6));
                CharacterData.Add("EyesIndex", ResultReader.GetInt16(7));
                CharacterData.Add("EyesColor", ResultReader.GetString(8));
                CharacterData.Add("TorsoIndex", ResultReader.GetInt16(9));
                CharacterData.Add("TorsoColor", ResultReader.GetString(10));
                CharacterData.Add("ArmsIndex", ResultReader.GetInt16(11));
                CharacterData.Add("ArmsColor", ResultReader.GetString(12));
                CharacterData.Add("HandsIndex", ResultReader.GetInt16(13));
                CharacterData.Add("HandsColor", ResultReader.GetString(14));
                CharacterData.Add("LegsIndex", ResultReader.GetInt16(15));
                CharacterData.Add("LegsColor", ResultReader.GetString(16));
                CharacterData.Add("FeetIndex", ResultReader.GetInt16(17));
                CharacterData.Add("FeetColor", ResultReader.GetString(18));

                ResultReader.Close();

                return(CharacterData);
            }
Esempio n. 28
0
        /// <inheritdoc />
        /// <summary>
        ///     Initializes a new DatabaseConnection to the MySQL database specified within the connection
        ///     parameters. This also ensures that a database will be created if none is present.
        /// </summary>
        /// <param name="keyWordCache">
        ///     Cache all existing keywords locally, used by the crawer for faster cheks of existing
        ///     keywords, used for the crawler
        /// </param>
        public DatabaseConnection(bool keyWordCache = false)
        {
            if (DatabaseConnectionString == null)
                throw new InvalidOperationException("DatabaseConnectionString must be set before initialising objects");

            _generatedKeywordsUncached = new Dictionary<string, Keyword>();

            Database.EnsureCreated();

            // Check if a fulltext index is given, since entity framework has no support for it
            // we use the "classic" MySqlConnection
            if (!_fullTextChecked)
            {
                bool fulltextsearch = false;
                using MySqlConnection connection = new MySqlConnection(DatabaseConnectionString);
                connection.Open();

                MySqlDataReader reader = new MySqlCommand("SHOW INDEX FROM SearchIndex;", connection).ExecuteReader();

                // Check if the fulltext index exists
                while (reader.Read())
                    if (reader.GetString("Key_name") == "SearchIndex" &&
                        reader.GetString("Column_name") == "SearchString" &&
                        reader.GetString("Index_type") == "FULLTEXT")
                        fulltextsearch = true;

                reader.Close();

                // if the fulltext index was not found add it
                if (!fulltextsearch)
                {
                    MySqlCommand commandCreateFulltext =
                        new MySqlCommand(
                            "ALTER TABLE SearchIndex ADD FULLTEXT INDEX SearchIndex (SearchString);",
                            connection);
                    commandCreateFulltext.ExecuteNonQuery();
                }

                connection.Close();

                bool fulltextrepo = false;

                using MySqlConnection connection2 = new MySqlConnection(DatabaseConnectionString);
                connection2.Open();

                MySqlDataReader reader2 =
                    new MySqlCommand("SHOW INDEX FROM GitHubRepositories;", connection2).ExecuteReader();

                // Check if the fulltext index exists
                while (reader2.Read())
                    if (reader2.GetString("Key_name") == "DescriptionIndex" &&
                        reader2.GetString("Column_name") == "Description" &&
                        reader2.GetString("Index_type") == "FULLTEXT")
                        fulltextrepo = true;

                reader2.Close();

                // if the fulltext index was not found add it
                if (!fulltextrepo)
                {
                    MySqlCommand commandCreateFulltext =
                        new MySqlCommand(
                            "ALTER TABLE GitHubRepositories ADD FULLTEXT INDEX DescriptionIndex (Description);",
                            connection2);
                    commandCreateFulltext.ExecuteNonQuery();
                }

                connection2.Close();
                _fullTextChecked = true;
            }


            // Generating a local database of keywords because a search for an existing keyword in the DbSet
            // is extremely slow.
            if (!keyWordCache) return;

            foreach (Keyword keyword in Keywords) GeneratedKeywords.Add(keyword.Word, keyword.KeywordId);
        }
Esempio n. 29
0
        private void hudong_Thread_Timer_Method(object o)
        {
            long            hudong_maxtime;
            MySqlConnection connection = new MySqlConnection("Database=zyg;Data Source=sirius0427.jios.org;User Id=cst;Password=q1w2e3r4t5Y^U&I*O(P);pooling=false;CharSet=utf8;port=3307");

            connection.Open();
            MySqlDataReader reader = new MySqlCommand("select max(collectiontime) as time from newsinfo where articletype='2'", connection).ExecuteReader();

            reader.Read();
            hudong_maxtime = reader["time"].ToLong();
            reader.Close();
            object[] objArray1 = new object[] { "select from_unixtime(collectiontime/1000) as time,title,digest,sourcename from newsinfo where articletype='2' and collectiontime >", hudong_lasttime, " and collectiontime <=", hudong_maxtime, " order by collectiontime" };
            reader = new MySqlCommand(string.Concat(objArray1), connection).ExecuteReader();
            try
            {
                int insertflag = 0;
                while (reader.Read())
                {
                    if (reader.HasRows)
                    {
                        int    startIndex = 0;
                        int    num2       = 0;
                        string str        = "";
                        string str2       = "";
                        MyData data       = new MyData
                        {
                            time = reader["time"].ToString()
                        };
                        string str3 = reader["title"].ToString().Replace("\n", "");
                        if (reader["sourcename"].Equals("深证互动"))
                        {
                            startIndex = str3.IndexOf("问", 0) + 2;
                            num2       = str3.IndexOf("):", 0) + 2;
                            str        = str3.Substring(startIndex, (num2 - startIndex) - 1);
                            str2       = str3.Substring(num2, str3.Length - num2);
                        }
                        else if (reader["sourcename"].Equals(" 上证互动"))
                        {
                            startIndex = str3.IndexOf(":", 0) + 1;
                            num2       = str3.IndexOf(")", 0) + 1;
                            str        = str3.Substring(startIndex, num2 - startIndex);
                            str2       = str3.Substring(num2, str3.Length - num2);
                        }
                        str.Trim();
                        str2.Trim();
                        string[] textArray1 = new string[] { "  问:", str2, Environment.NewLine, "  答:", reader["digest"].ToString() };
                        data.title      = string.Concat(textArray1);
                        data.sourcename = str + "\n" + reader["time"].ToString();
                        string[] textArray2 = new string[] { str, "\t", reader["time"].ToString(), "\n问:", str2, Environment.NewLine, "\n答:", reader["digest"].ToString() };
                        string   parameter  = string.Concat(textArray2);
                        //Thread thread1 = new Thread(new ParameterizedThreadStart(new StartMessageBox().CreateCounterWindowThread));
                        //thread1.SetApartmentState(ApartmentState.STA);
                        //thread1.IsBackground = true;
                        //thread1.Start(parameter);

                        //base.Dispatcher.BeginInvoke((Action)delegate
                        //{
                        //    NotifyData data1 = new NotifyData();
                        //    data1.Title = "抓妖股实时互动";
                        //    data1.Content = parameter;

                        //    NotificationWindow dialog = new NotificationWindow();//new 一个通知
                        //    dialog.Closed += Dialog_Closed;
                        //    dialog.TopFrom = GetTopFrom();
                        //    _dialogs.Add(dialog);
                        //    dialog.DataContext = data1;//设置通知里要显示的数据
                        //    dialog.Show();
                        //}, null);

                        Dispatcher.BeginInvoke((Action) delegate
                        {
                            if (hudong_filter.IsChecked.Value)
                            {
                                insertflag = 0;
                                foreach (string str1 in Regex.Split(hudong_filtertext.Text, ",", RegexOptions.IgnoreCase))
                                {
                                    if (data.title.IndexOf(str1) >= 0)
                                    {
                                        insertflag += 1;
                                    }
                                    else
                                    {
                                        insertflag += 0;
                                    }
                                }
                            }
                            else
                            {
                                insertflag = 1;
                            }
                            if (insertflag >= 1)
                            {
                                dataset_hudong.Insert(0, data);
                                new SoundPlayer("ring.wav").Play();
                                NotifyData data1 = new NotifyData();
                                data1.Title      = "抓妖股实时互动" + insertflag.ToString();
                                data1.Content    = parameter;

                                NotificationWindow dialog = new NotificationWindow();//new 一个通知
                                dialog.Closed            += Dialog_Closed;
                                dialog.TopFrom            = GetTopFrom();
                                _dialogs.Add(dialog);
                                dialog.DataContext = data1;//设置通知里要显示的数据
                                dialog.Show();
                            }
                        }, null);
                    }
                }
                hudong_lasttime = hudong_maxtime;
                Dispatcher.BeginInvoke((Action) delegate()
                {
                    ListView_hudong.ItemsSource = dataset_hudong;
                }, null);
            }
            catch (Exception)
            {
                MessageBox.Show("查询失败了!" + reader["title"].ToString().Replace("\n", ""));
            }
            finally
            {
                reader.Close();
                connection.Close();
            }
        }
Esempio n. 30
0
        internal Dictionary <string, List <string> > QueryAllByCustomString(string Columns, string Tables, string Conditions,
                                                                            string GroupBy, string HavingCondions, string OrderBy,
                                                                            int Limit)
        {
            Dictionary <string, List <string> > result = new Dictionary <string, List <string> >();


            #region Construct SQL Phrase

            StringBuilder sqlCommandStr = new StringBuilder();

            sqlCommandStr.Append(string.Format("SELECT {0} FROM {1}", Columns, Tables));

            if (Conditions != null && Conditions != "")
            {
                sqlCommandStr.Append(" WHERE " + Conditions);
            }

            if (GroupBy != null && GroupBy != "")
            {
                sqlCommandStr.Append(" GROUP BY " + GroupBy);
            }

            if (HavingCondions != null && HavingCondions != "")
            {
                sqlCommandStr.Append(" HAVING " + HavingCondions);
            }

            if (OrderBy != null && OrderBy != "")
            {
                sqlCommandStr.Append(" ORDER BY " + OrderBy);
            }

            if (Limit > 0)
            {
                sqlCommandStr.Append(" LIMIT " + Limit);
            }

            string SQLString = sqlCommandStr.ToString() + ";";

            //Console.Write(SQLString);

            #endregion


            #region ExecuteSQLPhrase and get result

            string[] columnItems = Columns.Split(',');

            try
            {
                mc.Open();

                MySqlDataReader reader = new MySqlCommand(SQLString, mc).ExecuteReader();

                while (reader.Read())
                {
                    if (reader.HasRows)
                    {
                        foreach (var columnItem in columnItems)
                        {
                            if (!result.ContainsKey(columnItem))
                            {
                                result.Add(columnItem, new List <string>());
                            }

                            result[columnItem].Add(reader.GetString(columnItem));
                        }
                    }
                }

                reader.Close();

                mc.Close();

                return(result);
            }
            catch (Exception e)
            {
                Console.Write(e.Message, 0);

                try
                {
                    mc.Close();
                }catch {}
                return(null);
            }

            #endregion
        }