Пример #1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            DatabaseColumn        databaseColumn      = new DatabaseColumn();
            List <DatabaseColumn> list                = new List <DatabaseColumn>();
            CombineDataGridView   combineDataGridView = new CombineDataGridView();

            if (txtSearch.Text != "")
            {
                Connector connector = new MYSQLDatabaseConnection();
                connector.establish();


                if (redioBtnCategoryName.Checked == true)
                {
                    databaseColumn.category_name = txtSearch.Text.ToString();
                    connector.SetData(databaseColumn);
                    list = connector.SearchCategoryWithName();
                    combineDataGridView.SetDataGridViewList(list, mDgv);//connect main window datagridview
                }
                else if (redioBtnCategoryId.Checked == true)
                {
                    databaseColumn.category_id = txtSearch.Text.ToString();
                    connector.SetData(databaseColumn);
                    list = connector.SearchCategoryWithId();
                    combineDataGridView.SetDataGridViewList(list, mDgv);
                }
                if (list.Count > 0)
                {
                    txtCategoryId.Text   = list[0].category_id;
                    txtCategoryName.Text = list[0].category_name;
                }
                else
                {
                    txtCategoryName.Clear();
                    txtCategoryId.Clear();
                }
            }
            else
            {
                txtCategoryName.Clear();
                txtCategoryId.Clear();
            }
        }