public FStudentInformationEdit(string strStudentId)
 {
     student = new CStudentEntity();
     this.student.StudentId = strStudentId;
     InitializeComponent();
     txtStudenId.Text = strStudentId;
 }
Example #2
0
 public static bool editStudent(CStudentEntity student)
 {
     try
     {
         dbContext = new StudentPlanManagementContext();
         //Todo dùng nhưng thất bại student.Account = CAccountBusiness.loadAccount(student.StudentId);
         //ToDo làm sao dung dươc nếu là quan hệ one to one dbContext.Entry(student).State = EntityState.Modified;
         var studentNew = dbContext.StudentEntities.Find(student.StudentId);
         studentNew.StudentName  = student.StudentName;
         studentNew.Genders      = student.Genders;
         studentNew.DateOfBirth  = student.DateOfBirth;
         studentNew.Address      = student.Address;
         studentNew.StudentImage = student.StudentImage;
         int countSave = dbContext.SaveChanges();
         if (countSave == 0)
         {
             return(false);
         }
     }
     catch (DbEntityValidationException)
     {
         return(false);
     }
     catch (DbUpdateException ex)
     {
         return(false);
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Example #3
0
 public static bool addStudent(CStudentEntity student)
 {
     try
     {
         dbContext = new StudentPlanManagementContext();
         dbContext.StudentEntities.Add(student);
         if (dbContext.SaveChanges() == 0)
         {
             return(false);
         }
     }
     catch (DbEntityValidationException)
     {
         return(false);
     }
     catch (DbUpdateException ex)
     {
         return(false);
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Example #4
0
        public static CStudentEntity loadStudentInfor(string strStudentId)
        {
            dbContext = new StudentPlanManagementContext();
            CStudentEntity student = new CStudentEntity();

            student = dbContext.StudentEntities.Where(st => st.StudentId == strStudentId).SingleOrDefault();
            return(student);
        }
 public FMain()
 {
     this.student               = null;
     this.semester              = new CSemesterEntity();
     this.semester.SemesterId   = "HK4";
     this.semester.SemesterName = "Học kỳ 4";
     this.semester.SchoolYears  = "2015-2016";
     InitializeComponent();
 }
 private void pbtnSignOut_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     student = null;
     this.barManagerAccount.SetPopupContextMenu(this.lblStudentName, null);
     foreach (var item in this.MdiChildren)
     {
         item.Close();
         item.Dispose();
     }
     loadHelloFormLogin();
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            CStudentEntity student = dataStudent();

            if (CStudentBusiness.editStudent(student) == false)
            {
                MessageBox.Show("Save failure!");
                return;
            }
            else
            {
                this.Close();
            }
        }
        private bool loadComponent()
        {
            this.student = CStudentBusiness.loadStudentInfor(this.strStudentId);
            if (student == null)
            {
                MessageBox.Show("Error load data!");
                return(false);
            }
            picStudentImage.Image = loadStudentImage();
            txtStudentName.Text   = student.StudentName;
            txtGenders.Text       = student.Genders?"Nam": "Nữ";
            txtDateOfBirth.Text   = student.DateOfBirth.Value.ToShortDateString();
            txtAddress.Text       = student.Address;

            return(true);
        }
 private void GetStudentId_Event(string strStudentId)
 {
     frmAccountSign.Hide();
     student = new CStudentEntity();
     student = CStudentBusiness.getStudentData(strStudentId);
     if (childThread.ThreadState == ThreadState.Aborted)
     {
         childThread.DisableComObjectEagerCleanup();
         ThreadStart childref = new ThreadStart(loadDelay);
         childThread = new Thread(childref);
     }
     childThread.Start();
     Thread.Sleep(600);
     reLblHelloInfor("Hello, " + student.StudentName);
     this.barManagerAccount.SetPopupContextMenu(this.lblStudentName, this.popupMenuAccount);
     loadFormTableTime();
 }
        private bool loadComponent()
        {
            this.student = CStudentBusiness.loadStudentInfor(student.StudentId);
            if (student == null)
            {
                MessageBox.Show("Error load data!");
                return(false);
            }
            picStudentImage.Image = loadStudentImage();
            txtStudentName.Text   = student.StudentName;
            if (student.Genders)
            {
                rdoGenders.SelectedIndex = 0;
            }
            else
            {
                rdoGenders.SelectedIndex = 1;
            }
            txtDateOfBirth.Text = student.DateOfBirth.Value.ToShortDateString();
            txtAddress.Text     = student.Address;

            return(true);
        }
 public FStudentInformationAdd(string strStudentId)
 {
     student = new CStudentEntity();
     this.student.StudentId = strStudentId;
     InitializeComponent();
 }