Example #1
0
        public Customer GetByID(Guid id)
        {
            //refactor to fit DELETE stored procedure
            StudentDB database = new StudentDB("Student");
            DataTable dt       = new DataTable();

            //may not need try|catch here
            //try
            //{
            database.Command.Parameters.Clear();
            database.Command.CommandType = CommandType.StoredProcedure;
            database.Command.CommandText = "tblCustomer_GETBYID";
            database.Command.Parameters.Add("@ID", SqlDbType.UniqueIdentifier).Value = id;
            dt = database.ExecuteQuery();
            if (dt != null && dt.Rows.Count == 1)
            {
                DataRow dr = dt.Rows[0];
                base.Initialize(dr);
                InitializeBusinessData(dr);
                base.isNew   = false;
                base.isDirty = false;
            }
            return(this);
            //}
            //catch (Exception e)
            //{
            //    result = false;
            //    throw;
            //}
        }
Example #2
0
        public Student Login(string firstName, string lastName)
        {
            StudentDB database = new StudentDB("Student");
            DataTable dt       = new DataTable();

            database.Command.Parameters.Clear();
            database.Command.CommandType = CommandType.StoredProcedure;
            database.Command.CommandText = "tblStudent_Login";
            database.Command.Parameters.Add("@FNAME", SqlDbType.VarChar).Value = firstName;
            database.Command.Parameters.Add("@LNAME", SqlDbType.VarChar).Value = lastName;

            dt = database.ExecuteQuery();
            if (dt != null && dt.Rows.Count == 1)
            {
                {
                    DataRow dr = dt.Rows[0];
                    base.Initialize(dr);
                    InitializeBusinessData(dr);
                    base.isNew   = false;
                    base.isDirty = false;
                }
                return(this);
            }
            else
            {
                return(null);
            }
        }
Example #3
0
        public AddressTypeList GetAll()
        {
            StudentDB database = new StudentDB("Student");

            database.Command.Parameters.Clear();
            database.Command.CommandType = System.Data.CommandType.StoredProcedure;
            database.Command.CommandText = "tblAddressType_GETALL";
            DataTable dt = database.ExecuteQuery();

            foreach (DataRow dr in dt.Rows)
            {
                AddressType addresstype = new AddressType();
                addresstype.Initialize(dr);
                addresstype.InitializeBusinessData(dr);
                addresstype.isNew   = false;
                addresstype.isDirty = false;
                _List.Add(addresstype);
            }
            return(this);
        }
Example #4
0
        public CustomerList GetAll()
        {
            StudentDB database = new StudentDB("Student");

            database.Command.Parameters.Clear();
            database.Command.CommandType = System.Data.CommandType.StoredProcedure;
            database.Command.CommandText = "tblCustomer_GETALL";
            DataTable dt = database.ExecuteQuery();

            foreach (DataRow dr in dt.Rows)
            {
                Customer customer = new Customer();
                customer.Initialize(dr);
                customer.InitializeBusinessData(dr);
                customer.isNew   = false;
                customer.isDirty = false;
                _List.Add(customer);
            }
            return(this);
        }
Example #5
0
        public StudentList Search()
        {
            StudentDB database = new StudentDB("Student");

            database.Command.Parameters.Clear();
            database.Command.CommandType = System.Data.CommandType.Text;
            _Criteria.TableName          = "tblStudent";
            database.Command.CommandText = SQLHelper.Builder.Build(_Criteria);
            DataTable dt = database.ExecuteQuery();

            foreach (DataRow dr in dt.Rows)
            {
                Student student = new Student();
                student.Initialize(dr);
                student.InitializeBusinessData(dr);
                student.isNew   = false;
                student.isDirty = false;
                _List.Add(student);
            }
            return(this);
        }
        public StudentEmailList GetByStudentID(Guid id)
        {
            StudentDB database = new StudentDB("Student");

            database.Command.Parameters.Clear();
            database.Command.Parameters.Add("@STUDENTID", SqlDbType.UniqueIdentifier).Value = id;
            database.Command.CommandType = System.Data.CommandType.StoredProcedure;
            database.Command.CommandText = "tblStudentEmail_GETBYSTUDENTID";
            DataTable dt = database.ExecuteQuery();

            foreach (DataRow dr in dt.Rows)
            {
                StudentEmail studentemail = new StudentEmail();
                studentemail.Initialize(dr);
                studentemail.InitializeBusinessData(dr);
                studentemail.isNew   = false;
                studentemail.isDirty = false;
                _List.Add(studentemail);
            }
            return(this);
        }