private void btnAddLimit_Click(object sender, EventArgs e)//__________________________Add_______________________________ { if (isValid.isPlaneTypeValid(cbLimitType.SelectedIndex) && isValid.isStartFinishValid(tbSpeedLimitStart.Text, tbSpeedLimitFinish.Text) && isValid.isStartFinishValid(tbDistanceLimitStart.Text, tbDistanceLimitFinish.Text)) { if (limitsDataLink.Exists(cbLimitType.SelectedItem.ToString())) { MessageBox.Show("Для данного типа самолета уже введено ограничение"); } else { Limit limit = new Limit() { PlaneType = cbLimitType.Text, SpeedStart = Convert.ToInt32(tbSpeedLimitStart.Text), SpeedFinish = Convert.ToInt32(tbSpeedLimitFinish.Text), DistanceStart = Convert.ToInt32(tbDistanceLimitStart.Text), DistanceFinish = Convert.ToInt32(tbDistanceLimitFinish.Text) }; limitsDataLink.Add(limit); fillLimitTable(); } cbLimitType.SelectedIndex = -1; tbSpeedLimitStart.Text = ""; tbSpeedLimitFinish.Text = ""; tbDistanceLimitStart.Text = ""; tbDistanceLimitFinish.Text = ""; } }
private void btnLimitSave_Click(object sender, EventArgs e) { if (isValid.isPlaneTypeValid(cbEditLimitType.SelectedIndex) && isValid.isStartFinishValid(tbEditSpeedLimitStart.Text, tbEditSpeedLimitFinish.Text) && isValid.isStartFinishValid(tbEditDistanceLimitStart.Text, tbEditDistanceLimitFinish.Text)) { if (limitsDataLink.Exists(cbEditLimitType.SelectedItem.ToString()) && (limitToEdit.PlaneType != cbEditLimitType.SelectedItem.ToString())) { MessageBox.Show("Для данного типа самолета уже введено ограничение"); } else { Limit limit = limitsDataLink.Retrieve(limitToEdit.LimitID); limit.PlaneType = cbEditLimitType.SelectedItem.ToString(); limit.SpeedStart = Convert.ToInt32(tbEditSpeedLimitStart.Text); limit.SpeedFinish = Convert.ToInt32(tbEditSpeedLimitFinish.Text); limit.DistanceStart = Convert.ToInt32(tbEditDistanceLimitStart.Text); limit.DistanceFinish = Convert.ToInt32(tbEditDistanceLimitFinish.Text); limitsDataLink.Update(limit); this.Hide(); } } }