private void Btn_teacher_save_Click(object sender, EventArgs e)
        {
            AcademyMngtSystem.Model.ClassRoom clsrm = new AcademyMngtSystem.Model.ClassRoom();


            Regex rgxName     = new Regex("[A-z]");
            Regex rgxCapacity = new Regex("[0-9A-z]");

            if (!rgxCapacity.IsMatch(clsrm_grp_capacity.Text))
            {
                MessageBox.Show("Not enter Letters");
            }
            if (!rgxName.IsMatch(clsrm_stdnt_name.Text))
            {
                MessageBox.Show("Fill in the form");
            }
            else
            {
                using (AcademyEntities aem = new AcademyEntities())
                {
                    AcademyMngtSystem.Model.Group group = aem.Groups.FirstOrDefault(c => c.Id == selectedId);
                    if (group != null)
                    {
                        clsrm.Groups.Add(group);
                    }
                    clsrm.Name     = clsrm_stdnt_name.Text;
                    clsrm.Capacity = clsrm_grp_capacity.Text;
                    aem.ClassRooms.Add(clsrm);
                    aem.SaveChanges();
                    clsrmdatagrid.DataSource = aem.ClassRooms.ToList();
                }
            }
        }
Example #2
0
        private void Btn_grpfrm_save_Click(object sender, EventArgs e)
        {
            Model.Group grp = new Model.Group();


            Regex rgxName = new Regex("[A-z]");
            //Regex rgxClassroom = new Regex("[A-z]");
            Regex rgxTeacher = new Regex("[A-z]");
            Regex rgxMentor  = new Regex("[A-z]");

            //Regex rgxCapacity = new Regex(@"\[0\-9\]\{0,15\}");


            if (!rgxName.IsMatch(frm_txtbox_Name.Text))
            {
                MessageBox.Show("Enter Name");
            }
            //else if (!rgxClassroom.IsMatch(frm_txtbox_ClassRoom.Text))
            //{
            //    MessageBox.Show("Enter ClassRoom");
            //}
            else if (!rgxTeacher.IsMatch(frm_txtbox_Teacher.Text))
            {
                MessageBox.Show("Fill in the form");
            }

            //else if (!rgxCapacity.IsMatch(frm_txtbox_Capacity.Text))
            //{
            //    MessageBox.Show("Enter Capactiy");
            //}
            else
            {
                using (AcademyEntities aem = new AcademyEntities())
                {
                    AcademyMngtSystem.Model.ClassRoom classrm = aem.ClassRooms.FirstOrDefault(c => c.Id == selectedClassRoomId);


                    //if (classrm != null)
                    //{
                    //    grp.ClassRoom.Add(classrm);
                    //}
                    grp.ClassRoom1 = classrm;
                    //grp.Classroom = frm_txtbox_ClassRoom.Text;
                    grp.Teacher = frm_txtbox_Teacher.Text;
                    grp.Mentor  = selectedMentorId;

                    //grp.Teacher = new i

                    grp.ClassRoom1 = classrm;
                    grp.Name       = frm_txtbox_Name.Text;
                    grp.Capacity   = Convert.ToInt32(frm_txtbox_Capacity.Text);
                    aem.Groups.Add(grp);
                    frm_grp_datagrid.DataSource = aem.Groups.ToList();
                    //grp.Employee
                    aem.SaveChanges();
                }
            }
        }