Example #1
0
 //对话框载入
 private void EmployeeForm_Load(object sender, EventArgs e)
 {
     if (!newDepartment)
     {
         TextName.Text = m_Department.name;
         TextNote.Text = m_Department.note;
         TextName.SelectAll();
         TextName.Focus();
     }
 }
Example #2
0
 private void AddButton(object sender, RoutedEventArgs e)
 {
     ProgramPersons.Add(new Person());
     PeopleList.SelectedIndex = ProgramPersons.Count - 1;
     TextName.Text            = "Name";
     TextSalary.Text          = "0";
     TextAge.Text             = "0";
     TextName.SelectAll();
     TextSalary.SelectAll();
     TextAge.SelectAll();
     TextName.Focus();
 }
Example #3
0
        //确定
        private void okBtn_Click(object sender, EventArgs e)
        {
            if (TextName.Text.Trim() == "")
            {
                BathClass.printErrorMsg("需要输入部门名称");
                TextName.SelectAll();
                TextName.Focus();
                return;
            }

            m_Department.name = TextName.Text.Trim();

            if (TextNote.Text.Trim() != "")
            {
                m_Department.note = TextNote.Text.Trim();
            }

            if (newDepartment)
            {
                if (db.Department.FirstOrDefault(x => x.name == TextName.Text) != null)
                {
                    BathClass.printErrorMsg("已经存在此名称的部门");
                    TextName.SelectAll();
                    TextName.Focus();
                    return;
                }

                db.Department.InsertOnSubmit(m_Department);
                db.SubmitChanges();

                m_form.createTree();
                m_Department  = new Department();
                TextName.Text = "";
                TextNote.Text = "";
                TextName.Focus();
            }
            else
            {
                db.SubmitChanges();
                this.DialogResult = DialogResult.OK;
            }
        }