Пример #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_position = (from p in db.CpPositions where p.Code == code && p.SchoolId == VariableGlobal.school_id select p).SingleOrDefault();
                if (cp_position == null)
                {
                    CpPosition cp_position_new = new CpPosition();
                    cp_position_new.SchoolId = Convert.ToInt32( cbb_Schools.SelectedValue);
                    cp_position_new.Code = txt_Code.Text;
                    cp_position_new.Name = txt_Name.Text;
                    cp_position_new.Abbreviation = txt_Abbreviation.Text;

                    db.CpPositions.Add(cp_position_new);
                }
                else
                {
                    cp_position.Code = txt_Code.Text;
                    cp_position.Name = txt_Name.Text;
                    cp_position.Abbreviation = txt_Abbreviation.Text;
                }

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

            }
        }
Пример #2
0
 private void ShowPositionList()
 {
     FrmPositionList position_list = new FrmPositionList();
     position_list.ShowDialog();
 }
Пример #3
0
 private void ShowPositionList()
 {
     FrmPositionList positionList_Screen = new FrmPositionList();
     positionList_Screen.ShowDialog();
 }