private void ResetSearch()//reset the searching
 {
     TxtNameSearch.Text    = string.Empty;
     TxtSurnameSearch.Text = string.Empty;
     TxtPhoneSearch.Text   = string.Empty;
     BtnCancelSearch.Hide();
 }
 private void TxtPhone_TextChanged(object sender, EventArgs e)//shows the result of the searching when the text changes
 {
     //searching for passive clients
     if (ChckPassive.Checked)
     {
         //check if the searching textboxes are empty
         if ((TxtPhone.Text == string.Empty && Txtname.Text == string.Empty))
         {
             DgvClientsSearch.Rows.Clear();
             foreach (Client item in _clientService.Clients())
             {
                 if (item.isActive == false)
                 {
                     DgvClientsSearch.Rows.Add(item.Id, item.Fullname, item.Phone);
                 }
             }
             Reset();
             return;
         }
         DgvClientsSearch.Rows.Clear();
         foreach (Client item in _clientService.Clients())
         {
             if ((item.Fullname.ToLower().Contains(Txtname.Text.ToLower()) ||
                  Txtname.Text == string.Empty) && (item.Phone.ToLower().Contains(TxtPhone.Text.ToLower()) ||
                                                    TxtPhone.Text == string.Empty) && item.isActive == false)
             {
                 DgvClientsSearch.Rows.Add(item.Id, item.Fullname, item.Phone);
             }
         }
         BtnCancelSearch.Show();
     }
     //searching for active clients
     else
     {
         if ((TxtPhone.Text == string.Empty && Txtname.Text == string.Empty))
         {
             DgvClientsSearch.Rows.Clear();
             FillClients();
             Reset();
             return;
         }
         DgvClientsSearch.Rows.Clear();
         foreach (Client item in _clientService.Clients())
         {
             if ((item.Fullname.ToLower().Contains(Txtname.Text.ToLower()) ||
                  Txtname.Text == string.Empty) && (item.Phone.ToLower().Contains(TxtPhone.Text.ToLower()) ||
                                                    TxtPhone.Text == string.Empty) && item.isActive == true)
             {
                 DgvClientsSearch.Rows.Add(item.Id, item.Fullname, item.Phone);
             }
         }
         BtnCancelSearch.Show();
     }
 }
 private void TxtNameSearch_TextChanged(object sender, EventArgs e)//shows the result of the searching when the text changes
 {
     //check if the searching textboxes is empty
     if ((TxtAuthorSearch.Text == string.Empty && TxtNameSearch.Text == string.Empty))
     {
         DgvBooks.Rows.Clear();
         FillBooks();
         ResetSearch();
         return;
     }
     DgvBooks.Rows.Clear();
     foreach (Book item in _bookService.All())
     {
         if ((item.Title.ToLower().Contains(TxtNameSearch.Text.ToLower()) ||
              TxtNameSearch.Text == string.Empty) && (item.Author.ToLower().Contains(TxtAuthorSearch.Text.ToLower()) ||
                                                      TxtAuthorSearch.Text == string.Empty) && item.isActive == true)
         {
             DgvBooks.Rows.Add(item.Id, item.Title, item.Price, item.Author, item.Count);
         }
     }
     BtnCancelSearch.Show();
 }
 private void TxtNameSearch_TextChanged(object sender, EventArgs e)//shows the result of the searching when the text change
 {
     //check if the searching textboxes is empty
     if ((TxtPhoneSearch.Text == string.Empty && TxtNameSearch.Text == string.Empty))
     {
         DgvClients.Rows.Clear();
         FillClients();
         ResetSearch();
         return;
     }
     DgvClients.Rows.Clear();
     foreach (Client item in _clientService.Clients())
     {
         if ((item.Fullname.ToLower().Contains(TxtNameSearch.Text.ToLower()) ||
              TxtNameSearch.Text == string.Empty) && (item.Phone.ToLower().Contains(TxtPhoneSearch.Text.ToLower()) ||
                                                      TxtPhoneSearch.Text == string.Empty) && item.isActive == true)
         {
             DgvClients.Rows.Add(item.Id, item.Fullname, item.Phone);
         }
     }
     BtnCancelSearch.Show();
 }
 private void Reset()//reset the changes on textboxes
 {
     Txtname.Text  = string.Empty;
     TxtPhone.Text = string.Empty;
     BtnCancelSearch.Hide();
 }