private void buttonSearch_Click(object sender, EventArgs e) { _mobile.Imei = textBoxImei.Text; List <Mobile> mobiles = _mobileManager.SearchByImei(_mobile); if (mobiles.Count > 0) { labelModelName.Text = _mobile.ModelName; labelImei.Text = _mobile.Imei; labelPrice.Text = Convert.ToString(_mobile.Price); } else { MessageBox.Show("Not Found"); } }
private void SaveButton_Click(object sender, EventArgs e) { try { _mobile.ModelName = textBoxModelName.Text; _mobile.Imei = textBoxImei.Text; _mobile.Price = Convert.ToInt32(textBoxPrice.Text); List <Mobile> mobiles = _mobileManager.SearchByImei(_mobile); if (mobiles.Count > 0) { MessageBox.Show("Data Exists!"); } else if (_mobile.Imei.Length > 11) { MessageBox.Show("IMEI Is Not More Than 11 Character!"); } else if (_mobile.Imei.Length < 11) { MessageBox.Show("IMEI Is 11 Character!"); } else { bool isSaved = _mobileManager.SaveMobiles(_mobile); if (isSaved) { MessageBox.Show("Saved"); } else { MessageBox.Show("Not Saved"); } } } catch (Exception exception) { MessageBox.Show(exception.Message); } }