Beispiel #1
0
        public async Task <IActionResult> PutStudentFaculty([FromRoute] int id, [FromBody] StudentFaculty studentFaculty)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != studentFaculty.FacultyId)
            {
                return(BadRequest());
            }

            _context.Entry(studentFaculty).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StudentFacultyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #2
0
        public ViewResult getmeData5(int id)
        {
            List <Student> listobj = new List <Student>();

            Student st = new Models.Student();

            st.studId      = 1;
            st.StudentName = "Krishna";
            st.Course      = "MVC";

            Student st1 = new Models.Student();

            st1.studId      = 2;
            st1.StudentName = "Sree";
            st1.Course      = "Angular";


            Student st2 = new Models.Student();

            st2.studId      = 3;
            st2.StudentName = "Vidhi";
            st2.Course      = "Phyton";

            listobj.Add(st);
            listobj.Add(st1);
            listobj.Add(st2);
            //--------------------------------
            List <Faculty> listfobj = new List <Faculty>();

            Faculty fobj = new Faculty();

            fobj.FacultyId = 1211;
            fobj.Name      = "Rahul";

            Faculty fobj1 = new Faculty();

            fobj1.FacultyId = 1212;
            fobj1.Name      = "james";

            listfobj.Add(fobj);
            listfobj.Add(fobj1);

            //  --------------------------------------------------
            StudentFaculty sft = new StudentFaculty();

            sft.st = listobj;
            sft.ft = listfobj;

            return(View(sft));
        }
Beispiel #3
0
        // Insert
        public bool Insert(StudentFaculty aStudentFaculty)
        {
            try
            {
                db.StudentFaculties.InsertOnSubmit(aStudentFaculty);
                db.SubmitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw new Exception("StudentFacultyBO.Insert" + ex.ToString());
            }
        }
Beispiel #4
0
        // Update
        public bool Update(StudentFaculty aStudentFaculty)
        {
            try
            {
                var editObj = db.StudentFaculties.Where(b => b.Stu_Code == aStudentFaculty.Stu_Code && b.Fac_Code == aStudentFaculty.Fac_Code && b.Spe_Code == aStudentFaculty.Spe_Code).FirstOrDefault();
                editObj.Sfa_Status = aStudentFaculty.Sfa_Status;
                db.SubmitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw new Exception("StudentFacultyBO.Update" + ex.ToString());
            }
        }
        private void SaveInforStudent()
        {
            try
            {
                Student stu = new Student();
                stu.Stu_Code        = txtStuCode.Text;
                stu.Stu_Name        = txtStuName.Text;
                stu.Stu_DateOfBirth = editDate.Value;
                stu.Stu_HomeTown    = txtNs.Text;
                stu.Stu_Address     = txtAddress.Text;
                stu.Stu_PhoneNumber = txtPhone.Text;
                stu.Stu_Ethnic      = txtEth.Text;
                stu.Stu_Religion    = txtReligion.Text;
                stu.Stu_StudyStatus = 1;

                // xu ly khoa va chuyen nganh
                StudentFaculty stFa = new StudentFaculty();

                stFa.Stu_Code = stu.Stu_Code;
                stFa.Fac_Code = aFacultyBO.Select_ByName(cmbFaculty.SelectedValue.ToString()).Select(b => b.Fac_Code).FirstOrDefault();
                stFa.Spe_Code = aSpecializationBO.Select_ByName(cmbSpecialization.SelectedValue.ToString()).Select(b => b.Spe_Code).FirstOrDefault();

                if (txtStuCode.Text != "" && txtStuName.Text != "" && txtAddress.Text != "")
                {
                    if (aStudentBO.Insert(stu) && aStudentFacultyBO.Insert(stFa))
                    {
                        MessageBox.Show("Thêm thành công", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Thêm thất bại", "Thất bại", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Không được để trống mã, tên sinh viên và địa chỉ.", "Thất bại", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public void setValue(StudentFaculty aStudentFaculty)
 {
     this.StudentFacultyStu_Code = aStudentFaculty.Stu_Code;
     this.StudentFacultyFac_Code = aStudentFaculty.Fac_Code;
     this.StudentFacultySpe_Code = aStudentFaculty.Spe_Code;
 }