Exemplo n.º 1
0
        private void SaveInforStudent( )
        {
            try {
                Student stu = new Student ( );
                stu.Stu_Code = txtCode.Text;
                stu.Stu_Name = txtName.Text;
                stu.Stu_DateOfBirth = editDate.Value;
                stu.Stu_HomeTown = txtHomeTown.Text;
                stu.Stu_Address = txtAddress.Text;
                stu.Stu_PhoneNumber = txtPhone.Text;

                stuEn.setValue ( stu );
                db.Students.InsertOnSubmit ( stu );
                db.SubmitChanges ( );
                int temp = db.Students.Count ( );
                if ( db.Students.Count ( ) == temp + 1 )
                {
                    MessageBox.Show ( "Sử thông tin thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information );
                    this.Visible = false;
                } else {
                    MessageBox.Show ( "Không thể sửa được thông tin.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error );
                }

            }
            catch ( Exception ex ) {
                MessageBox.Show ( ex.ToString ( ), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error );
            }
        }
Exemplo n.º 2
0
 // Insert new Student
 public void Insert(Student aStudent)
 {
     try {
         db.Students.InsertOnSubmit(aStudent);
         db.SubmitChanges();
     }
     catch (Exception ex) {
         throw new Exception("StudentBO.Insert:" + ex.ToString());
     }
 }
Exemplo n.º 3
0
		public void setValue(Student aStudent)
		{
			this.StudentCode = aStudent.Stu_Code;
			this.StudentName = aStudent.Stu_Name;
			this.StudentPhone = aStudent.Stu_PhoneNumber;
			this.StudentReligion = aStudent.Stu_Religion;
			this.StudentHomeTown = aStudent.Stu_HomeTown;
			this.StudentEthnic = aStudent.Stu_Ethnic;
			this.StudentDateOfBirth = aStudent.Stu_DateOfBirth;
			this.StudentAddress = aStudent.Stu_Address;
			this.StudentStatus = aStudent.Stu_StudyStatus;
		}
Exemplo n.º 4
0
 // Insert new Student
 public bool Insert(Student aStudent)
 {
     try {
         db.Students.InsertOnSubmit(aStudent);
         db.SubmitChanges();
         return true;
     }
     catch (Exception ex) {
         return false;
         throw new Exception("StudentBO.Insert:" + ex.ToString());
     }
 }
Exemplo n.º 5
0
        private void btnSearch_Click( object sender, EventArgs e )
        {
            aStudent = aStudentBO.Select_ById(txtCode.Text).First();
            if (aStudent != null) {
                txtName.Text = aStudent.Stu_Name;
                editDate.Text = aStudent.Stu_DateOfBirth.ToString();
                txtHomeTown.Text = aStudent.Stu_HomeTown;
                txtAddress.Text = aStudent.Stu_Address;
                txtPhone.Text = aStudent.Stu_PhoneNumber;
                txtEthnic.Text = aStudent.Stu_Ethnic;
                txtReligion.Text = aStudent.Stu_Religion;

            } else {
                MessageBox.Show("Không tìm thấy thông tin.", "Thất bại", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 7
0
        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;

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

                //if (cmbFaculty.SelectedItem != null && cmbSpecialization.SelectedItem != null) {

                //    stFa.Stu_Code = stu.Stu_Code;

                //    var q = from m in db.Faculties where m.Fac_Name == cmbFaculty.SelectedItem select m.Fac_Code;

                //    stFa.Fac_Code = Int32.Parse(q.ToString()); // convert from string to int

                //    var p = from m in db.Specializations where m.Spe_Name == cmbSpecialization.SelectedItem select m.Spe_Code;
                //    stFa.Spe_Code = Int32.Parse(p.ToString());

                //}

                stFa.Stu_Code = stu.Stu_Code;
                List<int> CurrentFaculty = db.Faculties.Where(b => b.Fac_Name == cmbFaculty.SelectedValue.ToString()).Select(b => b.Fac_Code).Distinct().ToList();
                List<int> CurrentSpecialization = db.Specializations.Where(b => b.Spe_Name == cmbSpecialization.SelectedValue.ToString()).Select(b => b.Spe_Code).Distinct().ToList();
                stFa.Fac_Code = CurrentFaculty[0];
                stFa.Spe_Code = CurrentSpecialization[0];

                // get data for StudentEN object
                //stEN.setValue(stu);

                if (txtStuCode.Text != "" && txtStuName.Text != "" && txtAddress.Text != "") {
                    db.Students.InsertOnSubmit(stu);
                    db.StudentFaculties.InsertOnSubmit(stFa);
                    db.SubmitChanges();
                    if (db.Students.Count() > 0) {
                        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);
            }
        }
Exemplo n.º 8
0
 // Update Student
 public void Update(Student aStudent)
 {
     try {
         var editObj = db.Students.Where(b => b.Stu_Code == aStudent.Stu_Code).ToList<Student>();
         foreach (Student temp in editObj) {
             temp.Stu_Name = aStudent.Stu_Name;
             temp.Stu_DateOfBirth = aStudent.Stu_DateOfBirth;
             temp.Stu_HomeTown = aStudent.Stu_HomeTown;
             temp.Stu_Address = aStudent.Stu_Address;
             temp.Stu_PhoneNumber = aStudent.Stu_PhoneNumber;
             temp.Stu_Religion = aStudent.Stu_Religion;
             temp.Stu_Ethnic = aStudent.Stu_Ethnic;
         }
         db.SubmitChanges();
     }
     catch (Exception ex) {
         throw new Exception("StudentBO.Update:" + ex.ToString());
     }
 }
Exemplo n.º 9
0
 private void SelectedStudentChanged(Student student)
 {
     selectedStudent = student;
     FillDataFields();
 }
Exemplo n.º 10
0
 // Update Student
 public bool Update(Student aStudent)
 {
     try {
         var editObj = db.Students.Where(b => b.Stu_Code == aStudent.Stu_Code).FirstOrDefault();
         editObj.Stu_Name = aStudent.Stu_Name;
         editObj.Stu_DateOfBirth = aStudent.Stu_DateOfBirth;
         editObj.Stu_HomeTown = aStudent.Stu_HomeTown;
         editObj.Stu_Address = aStudent.Stu_Address;
         editObj.Stu_PhoneNumber = aStudent.Stu_PhoneNumber;
         editObj.Stu_Religion = aStudent.Stu_Religion;
         editObj.Stu_Ethnic = aStudent.Stu_Ethnic;
         db.SubmitChanges();
         return true;
     }
     catch (Exception ex) {
         return false;
         throw new Exception("StudentBO.Update:" + ex.ToString());
     }
 }
Exemplo n.º 11
0
 partial void DeleteStudent(Student instance);
Exemplo n.º 12
0
 partial void UpdateStudent(Student instance);
Exemplo n.º 13
0
 partial void InsertStudent(Student instance);