コード例 #1
0
        public void fillUserDataGrid(DataGridView grid, UsersFilter filter)
        {
            /*string Query =
             * "SELECT marsud.bts_users.id, marsud.bts_users.username AS  'Vartotojo vardas', " +
             * "marsud.bts_users.email AS  'El. Pastas', locked AS  'Blokuotas', " +
             * "last_login AS 'Paskutinis prisijungimas', marsud.bts_groups.name AS  'Teises'" +
             * "FROM marsud.bts_users, marsud.bts_users__groups INNER JOIN marsud.bts_groups ON " +
             * "marsud.bts_users__groups.group_id = marsud.bts_groups.id WHERE user_id = bts_users.id";
             */
            string Query = "SELECT marsud.bts_users.id, marsud.bts_users.username AS  'Vartotojo vardas', " +
                           "marsud.bts_users.email AS  'El. Pastas', locked AS  'Blokuotas', " +
                           "last_login AS 'Paskutinis prisijungimas' from marsud.bts_users";

            string str = "";

            if (filter != null)
            {
                if (!string.IsNullOrEmpty(filter.Username))
                {
                    Query = Query + " where username LIKE'" + filter.Username + "%'";
                }

                if (filter.State != 0)
                {
                    if (!string.IsNullOrEmpty(str))
                    {
                        Query = Query + " and locked = " + (filter.State == 2 ? 1 : 0);
                    }
                    else
                    {
                        Query = Query + " where locked = " + (filter.State == 2 ? 1 : 0);
                    }
                }
            }
            Query = Query + str;

            try
            {
                connection = new MySQLConnection(connectionString);
                connection.Open();

                MySqlCommand     cmd       = new MySqlCommand(Query, connection);
                MySqlDataAdapter dbAdapter = new MySqlDataAdapter(cmd);

                DataTable dtRecords = new DataTable();
                dbAdapter.Fill(dtRecords);
                grid.DataSource = dtRecords;                 //dataGrid
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
        }
コード例 #2
0
 private void UserEdit_UsernameFilterButton_Click(object sender, EventArgs e)
 {
     UsersFilterObj = new UsersFilter()
     {
         State    = UserEdit_UserStateFilterComboBox.SelectedIndex,
         Username = UserEdit_UsernameFilterTextBox.Text
     };
     database.fillUserDataGrid(this.dataGridView1, UsersFilterObj);
     dataGridView1.Rows[0].Cells[0].Selected = false;
 }
コード例 #3
0
		public void fillUserDataGrid(DataGridView grid, UsersFilter filter)
		{
			/*string Query =
			"SELECT marsud.bts_users.id, marsud.bts_users.username AS  'Vartotojo vardas', " +
			"marsud.bts_users.email AS  'El. Pastas', locked AS  'Blokuotas', " +
			"last_login AS 'Paskutinis prisijungimas', marsud.bts_groups.name AS  'Teises'" +
			"FROM marsud.bts_users, marsud.bts_users__groups INNER JOIN marsud.bts_groups ON " +
			"marsud.bts_users__groups.group_id = marsud.bts_groups.id WHERE user_id = bts_users.id";
			*/
			string Query = "SELECT marsud.bts_users.id, marsud.bts_users.username AS  'Vartotojo vardas', " +
			"marsud.bts_users.email AS  'El. Pastas', locked AS  'Blokuotas', " +
			"last_login AS 'Paskutinis prisijungimas' from marsud.bts_users";

			string str = "";
			if (filter != null)
			{
				if (!string.IsNullOrEmpty(filter.Username))
					Query = Query + " where username LIKE'" + filter.Username+"%'";

				if (filter.State != 0)
				{
					if (!string.IsNullOrEmpty(str))
					{
						Query = Query + " and locked = " + (filter.State == 2 ? 1 : 0);
					}
					else
					{
						Query = Query + " where locked = " + (filter.State == 2 ? 1 : 0);
					}
				}
				
			}
			Query = Query + str;

			try
			{

				connection = new MySQLConnection(connectionString);
				connection.Open();

				MySqlCommand cmd = new MySqlCommand(Query, connection);
				MySqlDataAdapter dbAdapter = new MySqlDataAdapter(cmd);

				DataTable dtRecords = new DataTable();
				dbAdapter.Fill(dtRecords);
				grid.DataSource = dtRecords; //dataGrid

			 
			}
			catch (Exception ex)
			{

				throw ex;
			}
			finally
			{
				connection.Close();
			}


		}
コード例 #4
0
 private void UserEdit_UsernameFilterButton_Click(object sender, EventArgs e)
 {
     UsersFilterObj = new UsersFilter()
     {
         State = UserEdit_UserStateFilterComboBox.SelectedIndex,
         Username = UserEdit_UsernameFilterTextBox.Text
     };
     database.fillUserDataGrid(this.dataGridView1, UsersFilterObj);
     dataGridView1.Rows[0].Cells[0].Selected = false;
 }