Пример #1
0
 public ComponentControl(Component comp)
 {
     InitializeComponent();
     component            = comp;
     lblName.Text         = comp.ComponentName;
     lblPercentage.Text   = comp.Weightage.ToString() + "%";
     txtMark.Text         = comp.Marks.ToString();
     txtMark.TextChanged += delegate(object sender, EventArgs e)
     {
         ComponentChangedEvent changeEvent = new ComponentChangedEvent();
         changeEvent.component = component;
         componentChanged(sender, changeEvent);
     };
 }
Пример #2
0
        private void childComponentChangedCallback(object sender, ComponentChangedEvent changeEvent)
        {
            TextBox source = (TextBox)sender;
            Regex   reg    = new Regex("^(?:100|[1-9]?[0-9])$");
            String  marks  = source.Text;

            if (reg.IsMatch(marks))
            {
                changeEvent.component.Marks = Int32.Parse(marks);
                using (var db = new Entities())
                {
                    db.SaveChanges();
                }
                childComponentChanged(module);
            }
            else
            {
                MessageBox.Show("Invalid Mark", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }