コード例 #1
0
ファイル: StudentList.ascx.cs プロジェクト: nirshandileep/RHP
        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();
        }
コード例 #2
0
ファイル: Student.cs プロジェクト: tjsas1/RHP
        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);
        }
コード例 #3
0
ファイル: Search.aspx.cs プロジェクト: nirshandileep/RHP
        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;
            }
        }
コード例 #4
0
ファイル: Student.cs プロジェクト: nirshandileep/RHP
        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;
        }