Пример #1
0
        private void btn_Register_Click(object sender, EventArgs e)
        {
            if (validate())
            {
                //check data exit in database?
                string code = txt_Code.Text;
                var cp_staff_type = (from st in db.CpStaffTypes where st.Code == code && st.SchoolId == VariableGlobal.school_id select st).SingleOrDefault();
                if (cp_staff_type == null)
                {
                    CpStaffType cp_staff_type_new = new CpStaffType();
                    cp_staff_type_new.SchoolId = Convert.ToInt32(cbb_Schools.SelectedValue);
                    cp_staff_type_new.Code = txt_Code.Text;
                    cp_staff_type_new.Name = txt_Name.Text;
                    cp_staff_type_new.Abbreviation = txt_Abbreviation.Text;

                    db.CpStaffTypes.Add(cp_staff_type_new);
                }
                else
                {
                    cp_staff_type.Code = txt_Code.Text;
                    cp_staff_type.Name = txt_Name.Text;
                    cp_staff_type.Abbreviation = txt_Abbreviation.Text;
                }

                //update or insert data into db.
                try
                {
                    db.SaveChanges();
                    this.Hide();
                    FrmStaffTypeList staff_type_list = new FrmStaffTypeList();
                    staff_type_list.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

            }
        }
Пример #2
0
 private void ShowStaffTypeList()
 {
     FrmStaffTypeList staff_type_list = new FrmStaffTypeList();
     staff_type_list.ShowDialog();
 }
Пример #3
0
 private void ShowStaffTypeList()
 {
     FrmStaffTypeList staffType_Screen = new FrmStaffTypeList();
     staffType_Screen.ShowDialog();
 }