private InvestmentForm checkInput() { if (!String.IsNullOrEmpty(txtID.Text) || !String.IsNullOrEmpty(txtName.Text) || !String.IsNullOrEmpty(txtDesc.Text) || !String.IsNullOrEmpty(txtDep.Text) || !String.IsNullOrEmpty(txtDur.Text) || !String.IsNullOrEmpty(txtRev.Text)) { InvestmentForm a = new InvestmentForm(); int num; double dep; if (int.TryParse(txtID.Text, out num)) { a.Id = txtID.Text; if (int.TryParse(txtRev.Text, out num)) { a.Revenue = num; if (int.TryParse(txtDur.Text, out num)) { a.Min_duration = num; if (double.TryParse(txtDep.Text, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out dep)) { a.Min_deposit = dep; a.Description = txtDesc.Text; a.Name = txtName.Text; return(a); } } } } } return(null); }
private InvestmentForm checkInput() { if (!String.IsNullOrEmpty(txtID.Text) || !String.IsNullOrEmpty(txtName.Text) || !String.IsNullOrEmpty(txtDesc.Text) || !String.IsNullOrEmpty(txtDep.Text) || !String.IsNullOrEmpty(txtDur.Text) || !String.IsNullOrEmpty(txtRev.Text)) { InvestmentForm a = new InvestmentForm(); int num; double dep; if (int.TryParse(txtID.Text, out num)) { a.Id = txtID.Text; if (int.TryParse(txtRev.Text, out num)) { a.Revenue = num; if (int.TryParse(txtDur.Text, out num)) { a.Min_duration = num; if (double.TryParse(txtDep.Text,System.Globalization.NumberStyles.Any,CultureInfo.InvariantCulture, out dep)) { a.Min_deposit = dep; a.Description = txtDesc.Text; a.Name = txtName.Text; return a; } } } } } return null; }
private void cmdAdd_Click(object sender, EventArgs e) { InvestmentForm a = checkInput(); if (a != null) { this.list.Add(a); printList(); } else { MessageBox.Show("Please check your inputs"); } }