Ejemplo n.º 1
0
        private void FrmModify_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(SelectedID))
            {
                txtID.ReadOnly = true;
                //Lambda
                //SE selectedSe = Engineers
                //    .FirstOrDefault(c => c.ID == SelectedID);
                SE selectedSe = null;
                foreach (var item in Engineers)
                {
                    if (item.ID == SelectedID)
                    {
                        selectedSe = item;
                        break;
                    }
                }

                if (selectedSe != null)
                {
                    txtID.Text           = selectedSe.ID;
                    txtName.Text         = selectedSe.Name;
                    txtAge.Text          = selectedSe.Age.ToString();
                    radioButton1.Checked = !(radioButton1.Checked = selectedSe.Gender);
                }
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                if (string.IsNullOrEmpty(SelectedID))
                {
                    Engineers.Add(new SE
                    {
                        ID     = txtID.Text.Trim(),
                        Name   = txtName.Text.Trim(),
                        Age    = int.Parse(txtAge.Text.Trim()),
                        Gender = radioButton1.Checked
                    });
                }
                else
                {
                    SE selectedSe = Engineers
                                    .FirstOrDefault(c => c.ID == SelectedID);
                    //selectedSe.ID = txtID.Text.Trim();
                    selectedSe.Name   = txtName.Text.Trim();
                    selectedSe.Age    = int.Parse(txtAge.Text.Trim());
                    selectedSe.Gender = radioButton1.Checked;
                }

                if (RefreshMainForm != null)
                {
                    RefreshMainForm();
                }

                if (Handler != null)
                {
                    Handler();
                }

                Close();
            }
        }