private void searchButton_Click(object sender, EventArgs e) { try { String searchText = searchImeiTextBox.Text; if (String.IsNullOrEmpty(searchText)) { MessageBox.Show("Insert imei number for Searching"); return; } if (searchImeiTextBox.Text.Length < 15) { MessageBox.Show("IMEI requires exact 15 characters!"); return; } _mobile = _mobileManager.SearchMobileByImei(searchText); if (!String.IsNullOrEmpty(_mobile.IMEI)) { MessageBox.Show("Mobile handset found!"); modelNameLabel.Text = _mobile.ModelName; imeiLabel.Text = _mobile.IMEI; priceLabel.Text = _mobile.Price; } else { MessageBox.Show("Mobile not found!!"); } } catch (Exception exception) { MessageBox.Show(exception.Message); _mobileManager.CloseConnection(); } }
private void Display() { try { List <Mobile> mobiles = _mobileManager.ShowData(); if (mobiles != null) { showMobileGridView.Columns.Add("SerialNumber", "SI#"); showMobileGridView.DataSource = mobiles; } else { showMobileGridView.Columns.Clear(); } } catch (Exception exception) { MessageBox.Show(exception.Message); _mobileManager.CloseConnection(); } }
private void saveButton_Click(object sender, EventArgs e) { try { _mobile.ModelName = modelNameTextBox.Text; _mobile.IMEI = imeiTextBox.Text; _mobile.Price = priceTextBox.Text; if (String.IsNullOrEmpty(_mobile.ModelName)) { MessageBox.Show("Insert Model Name!!"); return; } if (String.IsNullOrEmpty(_mobile.IMEI)) { MessageBox.Show("Insert IMEI!!"); return; } if (_mobile.IMEI.Length < 15) { MessageBox.Show("IMEI requires exact 15 characters!"); return; } if (String.IsNullOrEmpty(_mobile.Price)) { MessageBox.Show("Insert Price!!"); return; } if (_mobileManager.isIMEIExist(_mobile)) { MessageBox.Show("IMEI already exist!"); return; } if (_mobileManager.addMobile(_mobile)) { MessageBox.Show("Mobile Information Saved!"); } } catch (Exception exception) { MessageBox.Show(exception.Message); _mobileManager.CloseConnection(); } }