Esempio n. 1
0
 private void ShowGroupList()
 {
     FrmGroupList group_list = new FrmGroupList();
     group_list.ShowDialog();
 }
Esempio n. 2
0
        private void btn_Register_Click(object sender, EventArgs e)
        {
            if (validate())
            {
                JavaScriptSerializer ser = new JavaScriptSerializer();

                //check data exit in database?
                string code = txt_Code.Text;
                var cp_group = (from p in db.CpGroups where p.Code == code && p.SchoolId == VariableGlobal.school_id select p).SingleOrDefault();
                if (cp_group == null)
                {
                    CpGroup cp_group_new = new CpGroup();
                    cp_group_new.SchoolId = Convert.ToInt32(cbb_Schools.SelectedValue);
                    cp_group_new.Code = txt_Code.Text;
                    cp_group_new.Name = txt_Name.Text;
                    cp_group_new.Abbreviation = txt_Abbreviation.Text;

                    if (VariableGlobal.StaffIds.Count > 0)
                    {
                        //xu ly add them id cua staff vao DB.
                        var data_staff = new Dictionary<string, string>();
                        int incre_up = 0;

                        foreach (int staff_id in VariableGlobal.StaffIds)
                        {
                            incre_up++;
                            data_staff.Add(Convert.ToString(incre_up), Convert.ToString(staff_id));

                        }

                        var JSONString = ser.Serialize(data_staff); //JSON encoded
                        cp_group_new.ListStaffId = JSONString;

                    }
                    db.CpGroups.Add(cp_group_new);
                }
                else
                {
                    cp_group.Code = txt_Code.Text;
                    cp_group.Name = txt_Name.Text;
                    cp_group.Abbreviation = txt_Abbreviation.Text;

                    if (VariableGlobal.StaffIds.Count > 0)
                    {
                        //xu ly add them id cua staff vao DB.
                        var data_staff = new Dictionary<string, string>();
                        int incre_up = 0;

                        foreach (int staff_id in VariableGlobal.StaffIds)
                        {
                            incre_up++;
                            data_staff.Add(Convert.ToString(incre_up), Convert.ToString(staff_id));

                        }

                        var JSONString = ser.Serialize(data_staff); //JSON encoded
                        cp_group.ListStaffId = JSONString;

                    }

                }

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

            }
        }
Esempio n. 3
0
 private void ShowGroupList()
 {
     FrmGroupList groupList_Screen = new FrmGroupList();
     groupList_Screen.ShowDialog();
 }