Esempio n. 1
0
        private void LoadGrid()
        {
            DataSet ds;
            ds = new StudentDAO().SelectAllDataset();
            ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns["StudentId"] };

            gvStudentList.SettingsText.ConfirmDelete = Messages.Delete_Confirm;
            gvStudentList.DataSource = ds.Tables[0];
            gvStudentList.DataBind();
        }
Esempio n. 2
0
        public bool Save()
        {
            bool result = false;

            Database     db         = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING);
            DbConnection connection = db.CreateConnection();

            connection.Open();
            DbTransaction transaction = connection.BeginTransaction();

            try
            {
                StudentDAO studentDAO = new StudentDAO();
                if (studentDAO.IsStudentExist(this))
                {
                    result = studentDAO.Update(this, db, transaction);
                }
                else
                {
                    result = studentDAO.Insert(this, db, transaction);
                }

                transaction.Commit();
            }
            catch (System.Exception ex)
            {
                transaction.Rollback();
                result = false;
                throw ex;
            }
            finally
            {
                connection.Close();
            }
            return(result);
        }
Esempio n. 3
0
        protected void FindStudent_Click(object sender, EventArgs e)
        {
            HouseSearchresults.Visible = false;

            RHP.StudentManagement.StudentSearch student = new RHP.StudentManagement.StudentSearch();
            StudentDAO studentDAO = new StudentDAO();

            student.FirstName = string.IsNullOrEmpty(FirstName.Text.Trim()) ? null : FirstName.Text.Trim();
            student.MiddleName = string.IsNullOrEmpty(MiddleName.Text.Trim()) ? null : MiddleName.Text.Trim();
            student.LastName = string.IsNullOrEmpty(LastName.Text.Trim()) ? null : LastName.Text.Trim();
            student.SchoolName = string.IsNullOrEmpty(DrpSchoolName.Text.Trim()) ? null : DrpSchoolName.Text.Trim();
            student.Zip = string.IsNullOrEmpty(Zipcode2.Text.Trim()) ? null : Zipcode2.Text.Trim();

            if (DrpGender.SelectedItem.Value != "-1")
            {
                student.Gender = DrpGender.SelectedItem.Value;
            }
            else
            {
                student.Gender = null;
            }

            if (DrpStatus.SelectedItem.Value != "-1")
            {
                student.Status = DrpStatus.SelectedItem.Value;
            }
            else
            {
                student.Status = null;
            }

            DataSet ds;
            ds = studentDAO.Search(student);

            if (ds != null)
            {

                DataListStudentSearchresults.DataSource = ds.Tables[0];
                DataListStudentSearchresults.DataBind();
                StudentSearchresults.Visible = true;
            }
            else
            {
                Searchresults.Visible = true;
            }
        }
Esempio n. 4
0
        public bool Save()
        {
            bool result = false;

            Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING);
            DbConnection connection = db.CreateConnection();
            connection.Open();
            DbTransaction transaction = connection.BeginTransaction();

            try
            {
                StudentDAO studentDAO = new StudentDAO();
                if (studentDAO.IsStudentExist(this))
                {
                    result = studentDAO.Update(this, db, transaction);
                }
                else
                {
                    result = studentDAO.Insert(this, db, transaction);
                }

                transaction.Commit();
            }
            catch (System.Exception ex)
            {
                transaction.Rollback();
                result = false;
                throw ex;
            }
            finally
            {
                connection.Close();
            }
            return result;
        }