Ejemplo n.º 1
0
        private void btnGetData_Click(object sender, EventArgs e)
        {
            //try
            //{
            //    MySqlDataReader myReader = DBConnection_MySQL.Query_MySQL("SELECT * FROM TAIKHOAN");
            //    if (myReader.Read())
            //    {
            //        //tbContent.Text = myReader.GetString(1);
            //    }
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message + ((DBConnection_MySQL.ErrorString != "") ? "\n\n" + DBConnection_MySQL.ErrorString : ""));
            //}
            //finally
            //{
            //    DBConnection_MySQL.closeConnection();
            //}

            //string selected = cbbTables.GetItemText(cbbTables.SelectedItem);
            string selected = cbbTables.Text;

            if (string.IsNullOrWhiteSpace(selected))
            {
                return;
            }
            string  query = "SELECT * FROM " + selected;
            DataSet ds    = DBConnection_MySQL.getData(query);

            dgvContent.DataSource = ds.Tables[0];
        }
Ejemplo n.º 2
0
 private void btnQuery_Click(object sender, EventArgs e)
 {
     try
     {
         DataSet ds = DBConnection_MySQL.getData(rtbQuery.Text);
         dgvQueryResult.DataSource = ds.Tables[0];
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 3
0
        public MainGUI()
        {
            InitializeComponent();
            this.Text = BUS.Show.name;

            DataSet tables = DBConnection_MySQL.getData("show tables from dbquanlynhankhau");

            foreach (DataRow item in tables.Tables[0].Rows)
            {
                cbbTables.Items.Add(item[0].ToString());
            }
        }
Ejemplo n.º 4
0
 protected void checkLogin()
 {
     if (tbUsername.Text == "" || tbPassword.Text == "")
     {
         MessageBox.Show(this, "Vui lòng điền đầy đủ tài khoản và mật khẩu!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         DataSet ds = DBConnection_MySQL.getData("SELECT * FROM TAIKHOAN WHERE TAIKHOAN='"
                                                 + tbUsername.Text + "' AND MATKHAU='" + tbPassword.Text + "'");
         if (ds == null || ds.Tables[0].Rows.Count == 0)
         {
             MessageBox.Show(this, "Tài khoản hoặc mật khẩu không đúng!\n" + DBConnection_MySQL.ErrorString, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             this.Hide();
             var mainGUI = new MainGUI();
             mainGUI.Closed += (s, args) => this.Close();
             mainGUI.Show();
         }
     }
 }