Пример #1
0
        void button1_Click(object sender, EventArgs e)
        {
            SampleClass s1 = new SampleClass();

            s1.ID   = textBox1.Text;
            s1.Name = textBoxImeOnHalf1.Text;
            if (ParentObject.BeforeSave != null)
            {
                SampleClass s2 = default(SampleClass);
                if (ParentObject.CurrentObject != null)
                {
                    s2 = new SampleClass();
                    ParentObject.CurrentObject.CopyTo(s2);
                }
                bool isclosed = true;
                if (ParentObject.BeforeSave(s1, s2, ref isclosed))
                {
                    if (isclosed)
                    {
                        ParentObject.SetObject(s1.ID, s1.Name);
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        textBox1.Text          = "";
                        textBoxImeOnHalf1.Text = "";
                        textBox1.Focus();
                    }
                }
            }
            else
            {
                s1.CopyTo(ParentObject.NewObject);
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }