All pastes #11396 Raw Edit

Mine

public text v1 · immutable
#11396 ·published 2005-05-10 08:09 UTC
rendered paste body
		protected virtual bool SaveData(bool clear)
		{
			try

			{

				this.CurrencyManager.EndCurrentEdit();

				this.CheckFields();



				BusinessObject bo = RemotingClient.CreateInstance(businessObject);

				bo.Save(DataSource);

				if (clear) this.ClearData();

				return true;

			}

			catch (NoNullAllowedException e) 

			{ 

				DataRowView dr = (DataRowView) this.CurrencyManager.Current;
				Regex r = new Regex("'(\\S*)'", RegexOptions.IgnoreCase);

				string name = dr.Row.Table.Columns[r.Match(e.Message).Groups[1].Value].Caption;

				MessageBox.Show(this, "Campo " + name + " não pode conter valores nulos.", this.Text);

			}

			catch (RecursiveDataException e)

			{

				DataRowView dr = (DataRowView) this.CurrencyManager.Current;
				Regex r = new Regex("'(\\S*)'", RegexOptions.IgnoreCase);

				string name = dr.Row.Table.Columns[r.Match(e.Message).Groups[1].Value].Caption;

				MessageBox.Show(this, "Campo " + name + " não pode ser filho dele mesmo ou de um de seus filhos.", this.Text);

			}

			catch (ConstraintDataException e)

			{

				DataRowView dr = (DataRowView) this.CurrencyManager.Current;
				Regex r = new Regex("'(\\S*)'", RegexOptions.IgnoreCase);

				string name = dr.Row.Table.Columns[r.Match(e.Message).Groups[1].Value].Caption;

				MessageBox.Show(this, "O campo " + name + " contém um valor inválido.", this.Text);

			}

			catch (ConstraintException e) 

			{ 

				MessageBox.Show(this, "@@Constraint: "+e.Message, this.Text);

			}

			catch (DataException e) 

			{ 

				MessageBox.Show(this, "@@Data:"+e.Message, this.Text);

			}

			catch (Exception e) 

			{ 

				MessageBox.Show(this, e.Message, this.Text);

			}

			return false;

		}