Exemplo n.º 1
0
        public DAL.UniteDetails GetByID(int ID)
        {
            SqlConnection Connection = DBGate.GetConnection();
            string        SelectByID = "Select  *  from UniteDetails  where  ID = @ID ";
            SqlCommand    cmd        = new SqlCommand(SelectByID, Connection);

            cmd.Parameters.AddWithValue("@ID", ID);
            UniteDetails _obj = new UniteDetails();

            try
            {
                Connection.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    _obj.ID            = int.Parse(reader["ID"].ToString());
                    _obj.UnittypeID    = int.Parse(reader["UnittypeID"].ToString());
                    _obj.UniteName     = reader["UniteName"].ToString();
                    _obj.SmokingPolicy = bool.Parse(reader["SmokingPolicy"].ToString());
                    _obj.PoolPolicy    = bool.Parse(reader["PoolPolicy"].ToString());
                    _obj.Size          = reader["Size"].ToString();
                    //
                    _obj.ApartmentNumber       = int.Parse(reader["ApartmentNumber"].ToString());
                    _obj.GustNumber            = int.Parse(reader["GustNumber"].ToString());
                    _obj.BedRoomNumber         = int.Parse(reader["BedRoomNumber"].ToString());
                    _obj.LivingRoomNumber      = int.Parse(reader["LivingRoomNumber"].ToString());
                    _obj.BedKind               = int.Parse(reader["BedKind"].ToString());
                    _obj.BedNumber             = int.Parse(reader["BedNumber"].ToString());
                    _obj.SofaBedNumber         = int.Parse(reader["SofaBedNumber"].ToString());
                    _obj.BathroomNumber        = int.Parse(reader["BathroomNumber"].ToString());
                    _obj.PrivateBathRoomNumber = int.Parse(reader["PrivateBathRoomNumber"].ToString());
                }
            }
            catch (SqlException ex)
            {
                frmDone frmerror = new frmDone(ex.ToString());
                frmerror.ShowDialog();
            }
            finally
            {
                Connection.Close();
            }
            return(_obj);
        }
Exemplo n.º 2
0
        public List <UniteDetails> GetAll()
        {
            SqlConnection       Connection = DBGate.GetConnection();
            string              SelectAll  = " select * from UniteDetails ";
            SqlCommand          cmd        = new SqlCommand(SelectAll, Connection);
            List <UniteDetails> lst        = new List <UniteDetails>();

            try
            {
                Connection.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    UniteDetails _obj = new UniteDetails();
                    _obj.ID            = int.Parse(reader["ID"].ToString());
                    _obj.UnittypeID    = int.Parse(reader["UnittypeID"].ToString());
                    _obj.UniteName     = reader["UniteName"].ToString();
                    _obj.SmokingPolicy = bool.Parse(reader["SmokingPolicy"].ToString());
                    _obj.PoolPolicy    = bool.Parse(reader["PoolPolicy"].ToString());
                    _obj.Size          = reader["Size"].ToString();
                    //
                    _obj.ApartmentNumber       = int.Parse(reader["ApartmentNumber"].ToString());
                    _obj.GustNumber            = int.Parse(reader["GustNumber"].ToString());
                    _obj.BedRoomNumber         = int.Parse(reader["BedRoomNumber"].ToString());
                    _obj.LivingRoomNumber      = int.Parse(reader["LivingRoomNumber"].ToString());
                    _obj.BedKind               = int.Parse(reader["BedKind"].ToString());
                    _obj.BedNumber             = int.Parse(reader["BedNumber"].ToString());
                    _obj.SofaBedNumber         = int.Parse(reader["SofaBedNumber"].ToString());
                    _obj.BathroomNumber        = int.Parse(reader["BathroomNumber"].ToString());
                    _obj.PrivateBathRoomNumber = int.Parse(reader["PrivateBathRoomNumber"].ToString());
                    lst.Add(_obj);
                }
            }
            catch (SqlException ex)
            {
                frmDone frmerror = new frmDone(ex.ToString());
                frmerror.ShowDialog();
            }
            finally { Connection.Close(); }
            return(lst);
        }